-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
627 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
src/library/Telegram.BotAPI/AvailableMethods/setUserEmojiStatus.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// Copyright (c) 2024 Quetzal Rivera. | ||
// Licensed under the MIT License, See LICENCE in the project root for license information. | ||
//* This file is auto-generated. Don't edit it manually! | ||
|
||
namespace Telegram.BotAPI.AvailableMethods; | ||
|
||
/// <summary> | ||
/// Extension methods for the Telegram Bot API. | ||
/// </summary> | ||
public static partial class AvailableMethodsExtensions | ||
{ | ||
/// <summary> | ||
/// Changes the emoji status for a given user that previously allowed the bot to manage their emoji status via the Mini App method <a href="https://core.telegram.org/bots/webapps#initializing-mini-apps">requestEmojiStatusAccess</a>. Returns <em>True</em> on success. | ||
/// </summary> | ||
/// <param name="client">The <see cref="ITelegramBotClient"/> instance.</param> | ||
/// <param name="userId">Unique identifier of the target user</param> | ||
/// <param name="emojiStatusCustomEmojiId">Custom emoji identifier of the emoji status to set. Pass an empty string to remove the status.</param> | ||
/// <param name="emojiStatusExpirationDate">Expiration date of the emoji status, if any</param> | ||
/// <exception cref="ArgumentNullException">Thrown if <paramref name="client"/> is <c>null</c>.</exception> | ||
/// <exception cref="BotRequestException">Thrown if the request to the Telegram Bot API fails.</exception> | ||
/// <returns></returns> | ||
public static bool SetUserEmojiStatus(this ITelegramBotClient client, long userId, string? emojiStatusCustomEmojiId = null, int? emojiStatusExpirationDate = null) => | ||
client.SetUserEmojiStatusAsync(userId, emojiStatusCustomEmojiId, emojiStatusExpirationDate).GetAwaiter().GetResult(); | ||
|
||
/// <summary> | ||
/// Changes the emoji status for a given user that previously allowed the bot to manage their emoji status via the Mini App method <a href="https://core.telegram.org/bots/webapps#initializing-mini-apps">requestEmojiStatusAccess</a>. Returns <em>True</em> on success. | ||
/// </summary> | ||
/// <param name="client">The <see cref="ITelegramBotClient"/> instance.</param> | ||
/// <param name="userId">Unique identifier of the target user</param> | ||
/// <param name="emojiStatusCustomEmojiId">Custom emoji identifier of the emoji status to set. Pass an empty string to remove the status.</param> | ||
/// <param name="emojiStatusExpirationDate">Expiration date of the emoji status, if any</param> | ||
/// <param name="cancellationToken">The cancellation token to cancel operation.</param> | ||
/// <exception cref="ArgumentNullException">Thrown if <paramref name="client"/> is <c>null</c>.</exception> | ||
/// <exception cref="BotRequestException">Thrown if the request to the Telegram Bot API fails.</exception> | ||
/// <returns></returns> | ||
public static Task<bool> SetUserEmojiStatusAsync(this ITelegramBotClient client, long userId, string? emojiStatusCustomEmojiId = null, int? emojiStatusExpirationDate = null, CancellationToken cancellationToken = default) | ||
{ | ||
if (client is null) | ||
{ | ||
throw new ArgumentNullException(nameof(client)); | ||
} | ||
|
||
var args = new Dictionary<string, object>() | ||
{ | ||
{ PropertyNames.UserId, userId } | ||
}; | ||
if (emojiStatusCustomEmojiId is not null) | ||
{ | ||
args.Add(PropertyNames.EmojiStatusCustomEmojiId, emojiStatusCustomEmojiId); | ||
} | ||
if (emojiStatusExpirationDate is not null) | ||
{ | ||
args.Add(PropertyNames.EmojiStatusExpirationDate, emojiStatusExpirationDate); | ||
} | ||
|
||
return client.CallMethodAsync<bool>(MethodNames.SetUserEmojiStatus, args, cancellationToken); | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
src/library/Telegram.BotAPI/InlineMode/Args/SavePreparedInlineMessageArgs.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// Copyright (c) 2024 Quetzal Rivera. | ||
// Licensed under the MIT License, See LICENCE in the project root for license information. | ||
//* This file is auto-generated. Don't edit it manually! | ||
|
||
namespace Telegram.BotAPI.InlineMode; | ||
|
||
/// <summary> | ||
/// Represents the arguments of the "SavePreparedInlineMessage" method. | ||
/// </summary> | ||
public class SavePreparedInlineMessageArgs | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="SavePreparedInlineMessageArgs"/> class. | ||
/// </summary> | ||
/// <param name="userId">Unique identifier of the target user that can use the prepared message</param> | ||
/// <param name="result">A JSON-serialized object describing the message to be sent</param> | ||
public SavePreparedInlineMessageArgs(long userId, InlineQueryResult result) | ||
{ | ||
this.UserId = userId; | ||
this.Result = result ?? throw new ArgumentNullException(nameof(result)); | ||
} | ||
|
||
/// <summary> | ||
/// Unique identifier of the target user that can use the prepared message | ||
/// </summary> | ||
[JsonPropertyName(PropertyNames.UserId)] | ||
public long UserId { get; set; } | ||
|
||
/// <summary> | ||
/// A JSON-serialized object describing the message to be sent | ||
/// </summary> | ||
[JsonPropertyName(PropertyNames.Result)] | ||
public InlineQueryResult Result { get; set; } | ||
|
||
/// <summary> | ||
/// Pass <em>True</em> if the message can be sent to private chats with users | ||
/// </summary> | ||
[JsonPropertyName(PropertyNames.AllowUserChats)] | ||
public bool? AllowUserChats { get; set; } | ||
|
||
/// <summary> | ||
/// Pass <em>True</em> if the message can be sent to private chats with bots | ||
/// </summary> | ||
[JsonPropertyName(PropertyNames.AllowBotChats)] | ||
public bool? AllowBotChats { get; set; } | ||
|
||
/// <summary> | ||
/// Pass <em>True</em> if the message can be sent to group and supergroup chats | ||
/// </summary> | ||
[JsonPropertyName(PropertyNames.AllowGroupChats)] | ||
public bool? AllowGroupChats { get; set; } | ||
|
||
/// <summary> | ||
/// Pass <em>True</em> if the message can be sent to channel chats | ||
/// </summary> | ||
[JsonPropertyName(PropertyNames.AllowChannelChats)] | ||
public bool? AllowChannelChats { get; set; } | ||
} |
23 changes: 23 additions & 0 deletions
23
src/library/Telegram.BotAPI/InlineMode/PreparedInlineMessage.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Copyright (c) 2024 Quetzal Rivera. | ||
// Licensed under the MIT License, See LICENCE in the project root for license information. | ||
//* This file is auto-generated. Don't edit it manually! | ||
|
||
namespace Telegram.BotAPI.InlineMode; | ||
|
||
/// <summary> | ||
/// Describes an inline message to be sent by a user of a Mini App. | ||
/// </summary> | ||
public class PreparedInlineMessage | ||
{ | ||
/// <summary> | ||
/// Unique identifier of the prepared message | ||
/// </summary> | ||
[JsonPropertyName(PropertyNames.Id)] | ||
public string Id { get; set; } = null!; | ||
|
||
/// <summary> | ||
/// Expiration date of the prepared message, in Unix time. Expired prepared messages can no longer be used | ||
/// </summary> | ||
[JsonPropertyName(PropertyNames.ExpirationDate)] | ||
public int ExpirationDate { get; set; } | ||
} |
103 changes: 103 additions & 0 deletions
103
src/library/Telegram.BotAPI/InlineMode/savePreparedInlineMessage.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
// Copyright (c) 2024 Quetzal Rivera. | ||
// Licensed under the MIT License, See LICENCE in the project root for license information. | ||
//* This file is auto-generated. Don't edit it manually! | ||
|
||
namespace Telegram.BotAPI.InlineMode; | ||
|
||
/// <summary> | ||
/// Extension methods for the Telegram Bot API. | ||
/// </summary> | ||
public static partial class InlineModeExtensions | ||
{ | ||
/// <summary> | ||
/// Stores a message that can be sent by a user of a Mini App. Returns a <see cref="PreparedInlineMessage"/> object. | ||
/// </summary> | ||
/// <param name="client">The <see cref="ITelegramBotClient"/> instance.</param> | ||
/// <param name="args">The arguments for the "SavePreparedInlineMessage" method.</param> | ||
/// <exception cref="ArgumentNullException">Thrown if <paramref name="client"/> is <c>null</c>.</exception> | ||
/// <exception cref="BotRequestException">Thrown if the request to the Telegram Bot API fails.</exception> | ||
/// <returns></returns> | ||
public static PreparedInlineMessage SavePreparedInlineMessage(this ITelegramBotClient client, SavePreparedInlineMessageArgs args) => | ||
client.SavePreparedInlineMessageAsync(args).GetAwaiter().GetResult(); | ||
|
||
/// <summary> | ||
/// Stores a message that can be sent by a user of a Mini App. Returns a <see cref="PreparedInlineMessage"/> object. | ||
/// </summary> | ||
/// <param name="client">The <see cref="ITelegramBotClient"/> instance.</param> | ||
/// <param name="args">The arguments for the "SavePreparedInlineMessage" method.</param> | ||
/// <param name="cancellationToken">The cancellation token to cancel operation.</param> | ||
/// <exception cref="ArgumentNullException">Thrown if <paramref name="client"/> is <c>null</c>.</exception> | ||
/// <exception cref="BotRequestException">Thrown if the request to the Telegram Bot API fails.</exception> | ||
/// <returns></returns> | ||
public static Task<PreparedInlineMessage> SavePreparedInlineMessageAsync(this ITelegramBotClient client, SavePreparedInlineMessageArgs args, CancellationToken cancellationToken = default) | ||
{ | ||
if (client is null) | ||
{ | ||
throw new ArgumentNullException(nameof(client)); | ||
} | ||
|
||
return client.CallMethodAsync<PreparedInlineMessage>(MethodNames.SavePreparedInlineMessage, args, cancellationToken); | ||
} | ||
|
||
/// <summary> | ||
/// Stores a message that can be sent by a user of a Mini App. Returns a <see cref="PreparedInlineMessage"/> object. | ||
/// </summary> | ||
/// <param name="client">The <see cref="ITelegramBotClient"/> instance.</param> | ||
/// <param name="userId">Unique identifier of the target user that can use the prepared message</param> | ||
/// <param name="result">A JSON-serialized object describing the message to be sent</param> | ||
/// <param name="allowUserChats">Pass <em>True</em> if the message can be sent to private chats with users</param> | ||
/// <param name="allowBotChats">Pass <em>True</em> if the message can be sent to private chats with bots</param> | ||
/// <param name="allowGroupChats">Pass <em>True</em> if the message can be sent to group and supergroup chats</param> | ||
/// <param name="allowChannelChats">Pass <em>True</em> if the message can be sent to channel chats</param> | ||
/// <exception cref="ArgumentNullException">Thrown if <paramref name="client"/> is <c>null</c>.</exception> | ||
/// <exception cref="BotRequestException">Thrown if the request to the Telegram Bot API fails.</exception> | ||
/// <returns></returns> | ||
public static PreparedInlineMessage SavePreparedInlineMessage(this ITelegramBotClient client, long userId, InlineQueryResult result, bool? allowUserChats = null, bool? allowBotChats = null, bool? allowGroupChats = null, bool? allowChannelChats = null) => | ||
client.SavePreparedInlineMessageAsync(userId, result, allowUserChats, allowBotChats, allowGroupChats, allowChannelChats).GetAwaiter().GetResult(); | ||
|
||
/// <summary> | ||
/// Stores a message that can be sent by a user of a Mini App. Returns a <see cref="PreparedInlineMessage"/> object. | ||
/// </summary> | ||
/// <param name="client">The <see cref="ITelegramBotClient"/> instance.</param> | ||
/// <param name="userId">Unique identifier of the target user that can use the prepared message</param> | ||
/// <param name="result">A JSON-serialized object describing the message to be sent</param> | ||
/// <param name="allowUserChats">Pass <em>True</em> if the message can be sent to private chats with users</param> | ||
/// <param name="allowBotChats">Pass <em>True</em> if the message can be sent to private chats with bots</param> | ||
/// <param name="allowGroupChats">Pass <em>True</em> if the message can be sent to group and supergroup chats</param> | ||
/// <param name="allowChannelChats">Pass <em>True</em> if the message can be sent to channel chats</param> | ||
/// <param name="cancellationToken">The cancellation token to cancel operation.</param> | ||
/// <exception cref="ArgumentNullException">Thrown if <paramref name="client"/> is <c>null</c>.</exception> | ||
/// <exception cref="BotRequestException">Thrown if the request to the Telegram Bot API fails.</exception> | ||
/// <returns></returns> | ||
public static Task<PreparedInlineMessage> SavePreparedInlineMessageAsync(this ITelegramBotClient client, long userId, InlineQueryResult result, bool? allowUserChats = null, bool? allowBotChats = null, bool? allowGroupChats = null, bool? allowChannelChats = null, CancellationToken cancellationToken = default) | ||
{ | ||
if (client is null) | ||
{ | ||
throw new ArgumentNullException(nameof(client)); | ||
} | ||
|
||
var args = new Dictionary<string, object>() | ||
{ | ||
{ PropertyNames.UserId, userId }, | ||
{ PropertyNames.Result, result ?? throw new ArgumentNullException(nameof(result)) } | ||
}; | ||
if (allowUserChats is not null) | ||
{ | ||
args.Add(PropertyNames.AllowUserChats, allowUserChats); | ||
} | ||
if (allowBotChats is not null) | ||
{ | ||
args.Add(PropertyNames.AllowBotChats, allowBotChats); | ||
} | ||
if (allowGroupChats is not null) | ||
{ | ||
args.Add(PropertyNames.AllowGroupChats, allowGroupChats); | ||
} | ||
if (allowChannelChats is not null) | ||
{ | ||
args.Add(PropertyNames.AllowChannelChats, allowChannelChats); | ||
} | ||
|
||
return client.CallMethodAsync<PreparedInlineMessage>(MethodNames.SavePreparedInlineMessage, args, cancellationToken); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.