From 3cc4077efd650ffd0bcd5a5b9e5cfaf1ed4d6081 Mon Sep 17 00:00:00 2001 From: Quetzal Rivera Date: Fri, 3 Jan 2025 21:52:32 -0600 Subject: [PATCH] feat: Update to Bot API 8.2 --- README.md | 8 +- src/examples/readme.md | 2 +- .../BackgroundType/BackgroundTypePattern.cs | 2 +- .../GettingUpdates/Args/GetUpdatesArgs.cs | 2 +- .../GettingUpdates/getUpdates.cs | 4 +- .../GettingUpdates/setWebhook.cs | 8 +- .../InlineQueryResultArticle.cs | 6 -- .../InlineQueryResult/InlineQueryResultGif.cs | 2 +- .../InlineQueryResultMpeg4Gif.cs | 2 +- src/library/Telegram.BotAPI/MethodNames.cs | 4 + src/library/Telegram.BotAPI/PropertyNames.cs | 4 +- src/library/Telegram.BotAPI/README.md | 8 +- .../Stickers/Args/SendGiftArgs.cs | 6 ++ .../Args/SetStickerSetThumbnailArgs.cs | 6 +- src/library/Telegram.BotAPI/Stickers/Gift.cs | 6 ++ .../Telegram.BotAPI/Stickers/InputSticker.cs | 2 +- .../Stickers/removeChatVerification.cs | 81 ++++++++++++++++ .../Stickers/removeUserVerification.cs | 46 +++++++++ .../Telegram.BotAPI/Stickers/sendGift.cs | 12 ++- .../Stickers/setStickerSetThumbnail.cs | 8 +- .../Telegram.BotAPI/Stickers/verifyChat.cs | 93 +++++++++++++++++++ .../Telegram.BotAPI/Stickers/verifyUser.cs | 52 +++++++++++ .../Telegram.BotAPI/Telegram.BotAPI.csproj | 6 +- 23 files changed, 330 insertions(+), 40 deletions(-) create mode 100644 src/library/Telegram.BotAPI/Stickers/removeChatVerification.cs create mode 100644 src/library/Telegram.BotAPI/Stickers/removeUserVerification.cs create mode 100644 src/library/Telegram.BotAPI/Stickers/verifyChat.cs create mode 100644 src/library/Telegram.BotAPI/Stickers/verifyUser.cs diff --git a/README.md b/README.md index a51f853..ab9d0aa 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,9 @@ | -------------------------------------------------- | -------------------------------- | [![NuGet version (Telegram.BotAPI)](https://img.shields.io/nuget/v/Telegram.BotAPI?style=flat-square&logo=nuget)](https://www.nuget.org/packages/Telegram.BotAPI/) -[![Compatible with Bot API v8.1](https://img.shields.io/badge/Bot%20API%20version-v8.1-blue?style=flat-square)](https://core.telegram.org/bots/api#december-4-2024) +[![Compatible with Bot API v8.2](https://img.shields.io/badge/Bot%20API%20version-v8.2-blue?style=flat-square)](https://core.telegram.org/bots/api#january-1-2025) -**Telegram.BotAPI** is one of the most complete libraries available to interact with the Telegram Bot API in your .NET projects. It contains all the methods and types available in the Bot API 8.1 released on December 4, 2024. +**Telegram.BotAPI** is one of the most complete libraries available to interact with the Telegram Bot API in your .NET projects. It contains all the methods and types available in the Bot API 8.2 released on January 1, 2025. [![Telegram Chat](https://img.shields.io/badge/Telegram.BotAPI%20--%20Chat-Join-blue?style=social&logo=telegram)](https://t.me/TBAPINET) @@ -12,8 +12,8 @@ ## Features -- Contains pre-defined methods for all Bot API 8.1 methods. -- Contains classes for each object type used in the Bot API 8.1. +- Contains pre-defined methods for all Bot API 8.2 methods. +- Contains classes for each object type used in the Bot API 8.2. - Sync and async methods. - Uses [System.Text.Json](https://www.nuget.org/packages/System.Text.Json/). diff --git a/src/examples/readme.md b/src/examples/readme.md index 77ed3ec..f7977da 100644 --- a/src/examples/readme.md +++ b/src/examples/readme.md @@ -1,7 +1,7 @@ # Telegram.BotAPI NET Examples [![NuGet version (Telegram.BotAPI)](https://img.shields.io/nuget/v/Telegram.BotAPI?style=flat-square&logo=nuget)](https://www.nuget.org/packages/Telegram.BotAPI/) -[![Compatible with Bot API v8.1](https://img.shields.io/badge/Bot%20API%20version-v8.1-blue?style=flat-square)](https://core.telegram.org/bots/api#december-4-2024) +[![Compatible with Bot API v8.2](https://img.shields.io/badge/Bot%20API%20version-v8.2-blue?style=flat-square)](https://core.telegram.org/bots/api#january-1-2025) ## Sample list diff --git a/src/library/Telegram.BotAPI/AvailableTypes/BackgroundType/BackgroundTypePattern.cs b/src/library/Telegram.BotAPI/AvailableTypes/BackgroundType/BackgroundTypePattern.cs index 687bb82..bcc8cd4 100644 --- a/src/library/Telegram.BotAPI/AvailableTypes/BackgroundType/BackgroundTypePattern.cs +++ b/src/library/Telegram.BotAPI/AvailableTypes/BackgroundType/BackgroundTypePattern.cs @@ -5,7 +5,7 @@ namespace Telegram.BotAPI.AvailableTypes; /// -/// The background is a PNG or TGV (gzipped subset of SVG with MIME type “application/x-tgwallpattern”) pattern to be combined with the background fill chosen by the user. +/// The background is a .PNG or .TGV (gzipped subset of SVG with MIME type “application/x-tgwallpattern”) pattern to be combined with the background fill chosen by the user. /// public class BackgroundTypePattern : BackgroundType { diff --git a/src/library/Telegram.BotAPI/GettingUpdates/Args/GetUpdatesArgs.cs b/src/library/Telegram.BotAPI/GettingUpdates/Args/GetUpdatesArgs.cs index df3b715..732ef65 100644 --- a/src/library/Telegram.BotAPI/GettingUpdates/Args/GetUpdatesArgs.cs +++ b/src/library/Telegram.BotAPI/GettingUpdates/Args/GetUpdatesArgs.cs @@ -28,7 +28,7 @@ public class GetUpdatesArgs public int? Timeout { get; set; } /// - /// A JSON-serialized list of the update types you want your bot to receive. For example, specify ["message", "edited_channel_post", "callback_query"] to only receive updates of these types. See for a complete list of available update types. Specify an empty list to receive all update types except chat_member, message_reaction, and message_reaction_count (default). If not specified, the previous setting will be used.

Please note that this parameter doesn't affect updates created before the call to the getUpdates, so unwanted updates may be received for a short period of time. + /// A JSON-serialized list of the update types you want your bot to receive. For example, specify ["message", "edited_channel_post", "callback_query"] to only receive updates of these types. See for a complete list of available update types. Specify an empty list to receive all update types except chat_member, message_reaction, and message_reaction_count (default). If not specified, the previous setting will be used.

Please note that this parameter doesn't affect updates created before the call to getUpdates, so unwanted updates may be received for a short period of time. ///
[JsonPropertyName(PropertyNames.AllowedUpdates)] public IEnumerable? AllowedUpdates { get; set; } diff --git a/src/library/Telegram.BotAPI/GettingUpdates/getUpdates.cs b/src/library/Telegram.BotAPI/GettingUpdates/getUpdates.cs index 6f54058..1d66959 100644 --- a/src/library/Telegram.BotAPI/GettingUpdates/getUpdates.cs +++ b/src/library/Telegram.BotAPI/GettingUpdates/getUpdates.cs @@ -46,7 +46,7 @@ public static Task> GetUpdatesAsync(this ITelegramBotClient /// Identifier of the first update to be returned. Must be greater by one than the highest among the identifiers of previously received updates. By default, updates starting with the earliest unconfirmed update are returned. An update is considered confirmed as soon as getUpdates is called with an offset higher than its update_id. The negative offset can be specified to retrieve updates starting from -offset update from the end of the updates queue. All previous updates will be forgotten. /// Limits the number of updates to be retrieved. Values between 1-100 are accepted. Defaults to 100. /// Timeout in seconds for long polling. Defaults to 0, i.e. usual short polling. Should be positive, short polling should be used for testing purposes only. - /// A JSON-serialized list of the update types you want your bot to receive. For example, specify ["message", "edited_channel_post", "callback_query"] to only receive updates of these types. See for a complete list of available update types. Specify an empty list to receive all update types except chat_member, message_reaction, and message_reaction_count (default). If not specified, the previous setting will be used.

Please note that this parameter doesn't affect updates created before the call to the getUpdates, so unwanted updates may be received for a short period of time. + /// A JSON-serialized list of the update types you want your bot to receive. For example, specify ["message", "edited_channel_post", "callback_query"] to only receive updates of these types. See for a complete list of available update types. Specify an empty list to receive all update types except chat_member, message_reaction, and message_reaction_count (default). If not specified, the previous setting will be used.

Please note that this parameter doesn't affect updates created before the call to getUpdates, so unwanted updates may be received for a short period of time. /// Thrown if is null. /// Thrown if the request to the Telegram Bot API fails. /// @@ -60,7 +60,7 @@ public static IEnumerable GetUpdates(this ITelegramBotClient client, int /// Identifier of the first update to be returned. Must be greater by one than the highest among the identifiers of previously received updates. By default, updates starting with the earliest unconfirmed update are returned. An update is considered confirmed as soon as getUpdates is called with an offset higher than its update_id. The negative offset can be specified to retrieve updates starting from -offset update from the end of the updates queue. All previous updates will be forgotten. /// Limits the number of updates to be retrieved. Values between 1-100 are accepted. Defaults to 100. /// Timeout in seconds for long polling. Defaults to 0, i.e. usual short polling. Should be positive, short polling should be used for testing purposes only. - /// A JSON-serialized list of the update types you want your bot to receive. For example, specify ["message", "edited_channel_post", "callback_query"] to only receive updates of these types. See for a complete list of available update types. Specify an empty list to receive all update types except chat_member, message_reaction, and message_reaction_count (default). If not specified, the previous setting will be used.

Please note that this parameter doesn't affect updates created before the call to the getUpdates, so unwanted updates may be received for a short period of time. + /// A JSON-serialized list of the update types you want your bot to receive. For example, specify ["message", "edited_channel_post", "callback_query"] to only receive updates of these types. See for a complete list of available update types. Specify an empty list to receive all update types except chat_member, message_reaction, and message_reaction_count (default). If not specified, the previous setting will be used.

Please note that this parameter doesn't affect updates created before the call to getUpdates, so unwanted updates may be received for a short period of time. /// The cancellation token to cancel operation. /// Thrown if is null. /// Thrown if the request to the Telegram Bot API fails. diff --git a/src/library/Telegram.BotAPI/GettingUpdates/setWebhook.cs b/src/library/Telegram.BotAPI/GettingUpdates/setWebhook.cs index 8102d68..c49e83c 100644 --- a/src/library/Telegram.BotAPI/GettingUpdates/setWebhook.cs +++ b/src/library/Telegram.BotAPI/GettingUpdates/setWebhook.cs @@ -12,7 +12,7 @@ namespace Telegram.BotAPI.GettingUpdates; public static partial class GettingUpdatesExtensions { /// - /// Use this method to specify a URL and receive incoming updates via an outgoing webhook. Whenever there is an update for the bot, we will send an HTTPS POST request to the specified URL, containing a JSON-serialized . In case of an unsuccessful request, we will give up after a reasonable amount of attempts. Returns True on success. + /// Use this method to specify a URL and receive incoming updates via an outgoing webhook. Whenever there is an update for the bot, we will send an HTTPS POST request to the specified URL, containing a JSON-serialized . In case of an unsuccessful request (a request with response HTTP status code different from 2XY), we will repeat the request and give up after a reasonable amount of attempts. Returns True on success. /// If you'd like to make sure that the webhook was set by you, you can specify secret data in the parameter secret_token. If specified, the request will contain a header “X-Telegram-Bot-Api-Secret-Token” with the secret token as content. /// /// The instance. @@ -24,7 +24,7 @@ public static bool SetWebhook(this ITelegramBotClient client, SetWebhookArgs arg client.SetWebhookAsync(args).GetAwaiter().GetResult(); /// - /// Use this method to specify a URL and receive incoming updates via an outgoing webhook. Whenever there is an update for the bot, we will send an HTTPS POST request to the specified URL, containing a JSON-serialized . In case of an unsuccessful request, we will give up after a reasonable amount of attempts. Returns True on success. + /// Use this method to specify a URL and receive incoming updates via an outgoing webhook. Whenever there is an update for the bot, we will send an HTTPS POST request to the specified URL, containing a JSON-serialized . In case of an unsuccessful request (a request with response HTTP status code different from 2XY), we will repeat the request and give up after a reasonable amount of attempts. Returns True on success. /// If you'd like to make sure that the webhook was set by you, you can specify secret data in the parameter secret_token. If specified, the request will contain a header “X-Telegram-Bot-Api-Secret-Token” with the secret token as content. /// /// The instance. @@ -44,7 +44,7 @@ public static Task SetWebhookAsync(this ITelegramBotClient client, SetWebh } /// - /// Use this method to specify a URL and receive incoming updates via an outgoing webhook. Whenever there is an update for the bot, we will send an HTTPS POST request to the specified URL, containing a JSON-serialized . In case of an unsuccessful request, we will give up after a reasonable amount of attempts. Returns True on success. + /// Use this method to specify a URL and receive incoming updates via an outgoing webhook. Whenever there is an update for the bot, we will send an HTTPS POST request to the specified URL, containing a JSON-serialized . In case of an unsuccessful request (a request with response HTTP status code different from 2XY), we will repeat the request and give up after a reasonable amount of attempts. Returns True on success. /// If you'd like to make sure that the webhook was set by you, you can specify secret data in the parameter secret_token. If specified, the request will contain a header “X-Telegram-Bot-Api-Secret-Token” with the secret token as content. /// /// The instance. @@ -62,7 +62,7 @@ public static bool SetWebhook(this ITelegramBotClient client, string url, InputF client.SetWebhookAsync(url, certificate, ipAddress, maxConnections, allowedUpdates, dropPendingUpdates, secretToken).GetAwaiter().GetResult(); /// - /// Use this method to specify a URL and receive incoming updates via an outgoing webhook. Whenever there is an update for the bot, we will send an HTTPS POST request to the specified URL, containing a JSON-serialized . In case of an unsuccessful request, we will give up after a reasonable amount of attempts. Returns True on success. + /// Use this method to specify a URL and receive incoming updates via an outgoing webhook. Whenever there is an update for the bot, we will send an HTTPS POST request to the specified URL, containing a JSON-serialized . In case of an unsuccessful request (a request with response HTTP status code different from 2XY), we will repeat the request and give up after a reasonable amount of attempts. Returns True on success. /// If you'd like to make sure that the webhook was set by you, you can specify secret data in the parameter secret_token. If specified, the request will contain a header “X-Telegram-Bot-Api-Secret-Token” with the secret token as content. /// /// The instance. diff --git a/src/library/Telegram.BotAPI/InlineMode/InlineQueryResult/InlineQueryResultArticle.cs b/src/library/Telegram.BotAPI/InlineMode/InlineQueryResult/InlineQueryResultArticle.cs index 0ff43f3..d481240 100644 --- a/src/library/Telegram.BotAPI/InlineMode/InlineQueryResult/InlineQueryResultArticle.cs +++ b/src/library/Telegram.BotAPI/InlineMode/InlineQueryResult/InlineQueryResultArticle.cs @@ -47,12 +47,6 @@ public class InlineQueryResultArticle : InlineQueryResult [JsonPropertyName(PropertyNames.Url)] public string? Url { get; set; } - /// - /// Optional. Pass True if you don't want the URL to be shown in the message - /// - [JsonPropertyName(PropertyNames.HideUrl)] - public bool? HideUrl { get; set; } - /// /// Optional. Short description of the result /// diff --git a/src/library/Telegram.BotAPI/InlineMode/InlineQueryResult/InlineQueryResultGif.cs b/src/library/Telegram.BotAPI/InlineMode/InlineQueryResult/InlineQueryResultGif.cs index f691d97..0e32745 100644 --- a/src/library/Telegram.BotAPI/InlineMode/InlineQueryResult/InlineQueryResultGif.cs +++ b/src/library/Telegram.BotAPI/InlineMode/InlineQueryResult/InlineQueryResultGif.cs @@ -24,7 +24,7 @@ public class InlineQueryResultGif : InlineQueryResult public override string Id { get; set; } = null!; /// - /// A valid URL for the GIF file. File size must not exceed 1MB + /// A valid URL for the GIF file /// [JsonPropertyName(PropertyNames.GifUrl)] public string GifUrl { get; set; } = null!; diff --git a/src/library/Telegram.BotAPI/InlineMode/InlineQueryResult/InlineQueryResultMpeg4Gif.cs b/src/library/Telegram.BotAPI/InlineMode/InlineQueryResult/InlineQueryResultMpeg4Gif.cs index debd0f0..1778072 100644 --- a/src/library/Telegram.BotAPI/InlineMode/InlineQueryResult/InlineQueryResultMpeg4Gif.cs +++ b/src/library/Telegram.BotAPI/InlineMode/InlineQueryResult/InlineQueryResultMpeg4Gif.cs @@ -24,7 +24,7 @@ public class InlineQueryResultMpeg4Gif : InlineQueryResult public override string Id { get; set; } = null!; /// - /// A valid URL for the MPEG4 file. File size must not exceed 1MB + /// A valid URL for the MPEG4 file /// [JsonPropertyName(PropertyNames.Mpeg4Url)] public string Mpeg4Url { get; set; } = null!; diff --git a/src/library/Telegram.BotAPI/MethodNames.cs b/src/library/Telegram.BotAPI/MethodNames.cs index cbc1a32..3df88df 100644 --- a/src/library/Telegram.BotAPI/MethodNames.cs +++ b/src/library/Telegram.BotAPI/MethodNames.cs @@ -81,6 +81,8 @@ public static partial class MethodNames public const string PinChatMessage = "pinChatMessage"; public const string PromoteChatMember = "promoteChatMember"; public const string RefundStarPayment = "refundStarPayment"; + public const string RemoveChatVerification = "removeChatVerification"; + public const string RemoveUserVerification = "removeUserVerification"; public const string ReopenForumTopic = "reopenForumTopic"; public const string ReopenGeneralForumTopic = "reopenGeneralForumTopic"; public const string ReplaceStickerInSet = "replaceStickerInSet"; @@ -141,5 +143,7 @@ public static partial class MethodNames public const string UnpinAllGeneralForumTopicMessages = "unpinAllGeneralForumTopicMessages"; public const string UnpinChatMessage = "unpinChatMessage"; public const string UploadStickerFile = "uploadStickerFile"; + public const string VerifyChat = "verifyChat"; + public const string VerifyUser = "verifyUser"; #pragma warning restore CS1591 // Missing XML comment for publicly visible type or member } diff --git a/src/library/Telegram.BotAPI/PropertyNames.cs b/src/library/Telegram.BotAPI/PropertyNames.cs index 5dcbd31..4e36df8 100644 --- a/src/library/Telegram.BotAPI/PropertyNames.cs +++ b/src/library/Telegram.BotAPI/PropertyNames.cs @@ -133,6 +133,7 @@ public static partial class PropertyNames public const string Creator = "creator"; public const string Credentials = "credentials"; public const string Currency = "currency"; + public const string CustomDescription = "custom_description"; public const string CustomEmojiId = "custom_emoji_id"; public const string CustomEmojiIds = "custom_emoji_ids"; public const string CustomEmojiStickerSetName = "custom_emoji_sticker_set_name"; @@ -239,7 +240,6 @@ public static partial class PropertyNames public const string Hash = "hash"; public const string Heading = "heading"; public const string Height = "height"; - public const string HideUrl = "hide_url"; public const string HorizontalAccuracy = "horizontal_accuracy"; public const string IconColor = "icon_color"; public const string IconCustomEmojiId = "icon_custom_emoji_id"; @@ -366,6 +366,7 @@ public static partial class PropertyNames public const string ParseMode = "parse_mode"; public const string PassportData = "passport_data"; public const string Pay = "pay"; + public const string PayForUpgrade = "pay_for_upgrade"; public const string Payload = "payload"; public const string PendingJoinRequestCount = "pending_join_request_count"; public const string PendingUpdateCount = "pending_update_count"; @@ -527,6 +528,7 @@ public static partial class PropertyNames public const string UnrestrictBoostCount = "unrestrict_boost_count"; public const string UntilDate = "until_date"; public const string UpdateId = "update_id"; + public const string UpgradeStarCount = "upgrade_star_count"; public const string Url = "url"; public const string UseIndependentChatPermissions = "use_independent_chat_permissions"; public const string User = "user"; diff --git a/src/library/Telegram.BotAPI/README.md b/src/library/Telegram.BotAPI/README.md index dcca387..6caba9e 100644 --- a/src/library/Telegram.BotAPI/README.md +++ b/src/library/Telegram.BotAPI/README.md @@ -1,17 +1,17 @@ # Telegram.BotAPI -[![Compatible with Bot API v8.1](https://img.shields.io/badge/Bot%20API%20version-v8.1-blue?style=flat-square)](https://core.telegram.org/bots/api#december-4-2024) +[![Compatible with Bot API v8.2](https://img.shields.io/badge/Bot%20API%20version-v8.2-blue?style=flat-square)](https://core.telegram.org/bots/api#january-1-2025) **Telegram.BotAPI** is one of the most complete libraries available to interact with the Telegram Bot API in your .NET projects. Free and open source. -It contains all the methods and types available in the Bot API 8.1 released on December 4, 2024. +It contains all the methods and types available in the Bot API 8.2 released on January 1, 2025. --- ## Features -- Contains pre-defined methods for all Bot API 8.1 methods. -- Contains classes for each object type used in the Bot API 8.1. +- Contains pre-defined methods for all Bot API 8.2 methods. +- Contains classes for each object type used in the Bot API 8.2. - Sync and async methods. - Uses [System.Text.Json](https://www.nuget.org/packages/System.Text.Json/). diff --git a/src/library/Telegram.BotAPI/Stickers/Args/SendGiftArgs.cs b/src/library/Telegram.BotAPI/Stickers/Args/SendGiftArgs.cs index f88c111..cbf744d 100644 --- a/src/library/Telegram.BotAPI/Stickers/Args/SendGiftArgs.cs +++ b/src/library/Telegram.BotAPI/Stickers/Args/SendGiftArgs.cs @@ -34,6 +34,12 @@ public SendGiftArgs(long userId, string giftId) [JsonPropertyName(PropertyNames.GiftId)] public string GiftId { get; set; } + /// + /// Pass True to pay for the gift upgrade from the bot's balance, thereby making the upgrade free for the receiver + /// + [JsonPropertyName(PropertyNames.PayForUpgrade)] + public bool? PayForUpgrade { get; set; } + /// /// Text that will be shown along with the gift; 0-255 characters /// diff --git a/src/library/Telegram.BotAPI/Stickers/Args/SetStickerSetThumbnailArgs.cs b/src/library/Telegram.BotAPI/Stickers/Args/SetStickerSetThumbnailArgs.cs index 2131160..7ba0542 100644 --- a/src/library/Telegram.BotAPI/Stickers/Args/SetStickerSetThumbnailArgs.cs +++ b/src/library/Telegram.BotAPI/Stickers/Args/SetStickerSetThumbnailArgs.cs @@ -16,7 +16,7 @@ public class SetStickerSetThumbnailArgs : AttachedFilesArgsBase /// /// Sticker set name /// User identifier of the sticker set owner - /// Format of the thumbnail, must be one of “static” for a .WEBP or .PNG image, “animated” for a .TGS animation, or “video” for a WEBM video + /// Format of the thumbnail, must be one of “static” for a .WEBP or .PNG image, “animated” for a .TGS animation, or “video” for a .WEBM video public SetStickerSetThumbnailArgs(string name, long userId, string format) { this.Name = name ?? throw new ArgumentNullException(nameof(name)); @@ -37,13 +37,13 @@ public SetStickerSetThumbnailArgs(string name, long userId, string format) public long UserId { get; set; } /// - /// A .WEBP or .PNG image with the thumbnail, must be up to 128 kilobytes in size and have a width and height of exactly 100px, or a .TGS animation with a thumbnail up to 32 kilobytes in size (see https://core.telegram.org/stickers#animation-requirements for animated sticker technical requirements), or a WEBM video with the thumbnail up to 32 kilobytes in size; see https://core.telegram.org/stickers#video-requirements for video sticker technical requirements. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. More information on Sending Files ». Animated and video sticker set thumbnails can't be uploaded via HTTP URL. If omitted, then the thumbnail is dropped and the first sticker is used as the thumbnail. + /// A .WEBP or .PNG image with the thumbnail, must be up to 128 kilobytes in size and have a width and height of exactly 100px, or a .TGS animation with a thumbnail up to 32 kilobytes in size (see https://core.telegram.org/stickers#animation-requirements for animated sticker technical requirements), or a .WEBM video with the thumbnail up to 32 kilobytes in size; see https://core.telegram.org/stickers#video-requirements for video sticker technical requirements. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. More information on Sending Files ». Animated and video sticker set thumbnails can't be uploaded via HTTP URL. If omitted, then the thumbnail is dropped and the first sticker is used as the thumbnail. /// [JsonPropertyName(PropertyNames.Thumbnail)] public object? Thumbnail { get; set; } /// - /// Format of the thumbnail, must be one of “static” for a .WEBP or .PNG image, “animated” for a .TGS animation, or “video” for a WEBM video + /// Format of the thumbnail, must be one of “static” for a .WEBP or .PNG image, “animated” for a .TGS animation, or “video” for a .WEBM video /// [JsonPropertyName(PropertyNames.Format)] public string Format { get; set; } diff --git a/src/library/Telegram.BotAPI/Stickers/Gift.cs b/src/library/Telegram.BotAPI/Stickers/Gift.cs index 4da611f..0fe252e 100644 --- a/src/library/Telegram.BotAPI/Stickers/Gift.cs +++ b/src/library/Telegram.BotAPI/Stickers/Gift.cs @@ -27,6 +27,12 @@ public class Gift [JsonPropertyName(PropertyNames.StarCount)] public int StarCount { get; set; } + /// + /// Optional. The number of Telegram Stars that must be paid to upgrade the gift to a unique one + /// + [JsonPropertyName(PropertyNames.UpgradeStarCount)] + public int? UpgradeStarCount { get; set; } + /// /// Optional. The total number of the gifts of this type that can be sent; for limited gifts only /// diff --git a/src/library/Telegram.BotAPI/Stickers/InputSticker.cs b/src/library/Telegram.BotAPI/Stickers/InputSticker.cs index ef3f450..0e8c447 100644 --- a/src/library/Telegram.BotAPI/Stickers/InputSticker.cs +++ b/src/library/Telegram.BotAPI/Stickers/InputSticker.cs @@ -16,7 +16,7 @@ public class InputSticker public object Sticker { get; set; } = null!; /// - /// Format of the added sticker, must be one of “static” for a .WEBP or .PNG image, “animated” for a .TGS animation, “video” for a WEBM video + /// Format of the added sticker, must be one of “static” for a .WEBP or .PNG image, “animated” for a .TGS animation, “video” for a .WEBM video /// [JsonPropertyName(PropertyNames.Format)] public string Format { get; set; } = null!; diff --git a/src/library/Telegram.BotAPI/Stickers/removeChatVerification.cs b/src/library/Telegram.BotAPI/Stickers/removeChatVerification.cs new file mode 100644 index 0000000..adab432 --- /dev/null +++ b/src/library/Telegram.BotAPI/Stickers/removeChatVerification.cs @@ -0,0 +1,81 @@ +// 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.Stickers; + +/// +/// Extension methods for the Telegram Bot API. +/// +public static partial class StickersExtensions +{ + /// + /// Removes verification from a chat that is currently verified on behalf of the organization represented by the bot. Returns True on success. + /// + /// The instance. + /// Unique identifier for the target chat or username of the target channel (in the format @channelusername) + /// Thrown if is null. + /// Thrown if the request to the Telegram Bot API fails. + /// + public static bool RemoveChatVerification(this ITelegramBotClient client, long chatId) => + client.RemoveChatVerificationAsync(chatId).GetAwaiter().GetResult(); + + /// + /// Removes verification from a chat that is currently verified on behalf of the organization represented by the bot. Returns True on success. + /// + /// The instance. + /// Unique identifier for the target chat or username of the target channel (in the format @channelusername) + /// The cancellation token to cancel operation. + /// Thrown if is null. + /// Thrown if the request to the Telegram Bot API fails. + /// + public static Task RemoveChatVerificationAsync(this ITelegramBotClient client, long chatId, CancellationToken cancellationToken = default) + { + if (client is null) + { + throw new ArgumentNullException(nameof(client)); + } + + var args = new Dictionary() + { + { PropertyNames.ChatId, chatId } + }; + + return client.CallMethodAsync(MethodNames.RemoveChatVerification, args, cancellationToken); + } + + /// + /// Removes verification from a chat that is currently verified on behalf of the organization represented by the bot. Returns True on success. + /// + /// The instance. + /// Unique identifier for the target chat or username of the target channel (in the format @channelusername) + /// Thrown if is null. + /// Thrown if the request to the Telegram Bot API fails. + /// + public static bool RemoveChatVerification(this ITelegramBotClient client, string chatId) => + client.RemoveChatVerificationAsync(chatId).GetAwaiter().GetResult(); + + /// + /// Removes verification from a chat that is currently verified on behalf of the organization represented by the bot. Returns True on success. + /// + /// The instance. + /// Unique identifier for the target chat or username of the target channel (in the format @channelusername) + /// The cancellation token to cancel operation. + /// Thrown if is null. + /// Thrown if the request to the Telegram Bot API fails. + /// + public static Task RemoveChatVerificationAsync(this ITelegramBotClient client, string chatId, CancellationToken cancellationToken = default) + { + if (client is null) + { + throw new ArgumentNullException(nameof(client)); + } + + var args = new Dictionary() + { + { PropertyNames.ChatId, chatId ?? throw new ArgumentNullException(nameof(chatId)) } + }; + + return client.CallMethodAsync(MethodNames.RemoveChatVerification, args, cancellationToken); + } +} diff --git a/src/library/Telegram.BotAPI/Stickers/removeUserVerification.cs b/src/library/Telegram.BotAPI/Stickers/removeUserVerification.cs new file mode 100644 index 0000000..5964983 --- /dev/null +++ b/src/library/Telegram.BotAPI/Stickers/removeUserVerification.cs @@ -0,0 +1,46 @@ +// 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.Stickers; + +/// +/// Extension methods for the Telegram Bot API. +/// +public static partial class StickersExtensions +{ + /// + /// Removes verification from a user who is currently verified on behalf of the organization represented by the bot. Returns True on success. + /// + /// The instance. + /// Unique identifier of the target user + /// Thrown if is null. + /// Thrown if the request to the Telegram Bot API fails. + /// + public static bool RemoveUserVerification(this ITelegramBotClient client, long userId) => + client.RemoveUserVerificationAsync(userId).GetAwaiter().GetResult(); + + /// + /// Removes verification from a user who is currently verified on behalf of the organization represented by the bot. Returns True on success. + /// + /// The instance. + /// Unique identifier of the target user + /// The cancellation token to cancel operation. + /// Thrown if is null. + /// Thrown if the request to the Telegram Bot API fails. + /// + public static Task RemoveUserVerificationAsync(this ITelegramBotClient client, long userId, CancellationToken cancellationToken = default) + { + if (client is null) + { + throw new ArgumentNullException(nameof(client)); + } + + var args = new Dictionary() + { + { PropertyNames.UserId, userId } + }; + + return client.CallMethodAsync(MethodNames.RemoveUserVerification, args, cancellationToken); + } +} diff --git a/src/library/Telegram.BotAPI/Stickers/sendGift.cs b/src/library/Telegram.BotAPI/Stickers/sendGift.cs index 706b9b6..1ddf54f 100644 --- a/src/library/Telegram.BotAPI/Stickers/sendGift.cs +++ b/src/library/Telegram.BotAPI/Stickers/sendGift.cs @@ -47,14 +47,15 @@ public static Task SendGiftAsync(this ITelegramBotClient client, SendGiftA /// The instance. /// Unique identifier of the target user that will receive the gift /// Identifier of the gift + /// Pass True to pay for the gift upgrade from the bot's balance, thereby making the upgrade free for the receiver /// Text that will be shown along with the gift; 0-255 characters /// Mode for parsing entities in the text. See formatting options for more details. Entities other than “bold”, “italic”, “underline”, “strikethrough”, “spoiler”, and “custom_emoji” are ignored. /// A JSON-serialized list of special entities that appear in the gift text. It can be specified instead of text_parse_mode. Entities other than “bold”, “italic”, “underline”, “strikethrough”, “spoiler”, and “custom_emoji” are ignored. /// Thrown if is null. /// Thrown if the request to the Telegram Bot API fails. /// - public static bool SendGift(this ITelegramBotClient client, long userId, string giftId, string? text = null, string? textParseMode = null, IEnumerable? textEntities = null) => - client.SendGiftAsync(userId, giftId, text, textParseMode, textEntities).GetAwaiter().GetResult(); + public static bool SendGift(this ITelegramBotClient client, long userId, string giftId, bool? payForUpgrade = null, string? text = null, string? textParseMode = null, IEnumerable? textEntities = null) => + client.SendGiftAsync(userId, giftId, payForUpgrade, text, textParseMode, textEntities).GetAwaiter().GetResult(); /// /// Sends a gift to the given user. The gift can't be converted to Telegram Stars by the user. Returns True on success. @@ -62,6 +63,7 @@ public static bool SendGift(this ITelegramBotClient client, long userId, string /// The instance. /// Unique identifier of the target user that will receive the gift /// Identifier of the gift + /// Pass True to pay for the gift upgrade from the bot's balance, thereby making the upgrade free for the receiver /// Text that will be shown along with the gift; 0-255 characters /// Mode for parsing entities in the text. See formatting options for more details. Entities other than “bold”, “italic”, “underline”, “strikethrough”, “spoiler”, and “custom_emoji” are ignored. /// A JSON-serialized list of special entities that appear in the gift text. It can be specified instead of text_parse_mode. Entities other than “bold”, “italic”, “underline”, “strikethrough”, “spoiler”, and “custom_emoji” are ignored. @@ -69,7 +71,7 @@ public static bool SendGift(this ITelegramBotClient client, long userId, string /// Thrown if is null. /// Thrown if the request to the Telegram Bot API fails. /// - public static Task SendGiftAsync(this ITelegramBotClient client, long userId, string giftId, string? text = null, string? textParseMode = null, IEnumerable? textEntities = null, CancellationToken cancellationToken = default) + public static Task SendGiftAsync(this ITelegramBotClient client, long userId, string giftId, bool? payForUpgrade = null, string? text = null, string? textParseMode = null, IEnumerable? textEntities = null, CancellationToken cancellationToken = default) { if (client is null) { @@ -81,6 +83,10 @@ public static Task SendGiftAsync(this ITelegramBotClient client, long user { PropertyNames.UserId, userId }, { PropertyNames.GiftId, giftId ?? throw new ArgumentNullException(nameof(giftId)) } }; + if (payForUpgrade is not null) + { + args.Add(PropertyNames.PayForUpgrade, payForUpgrade); + } if (text is not null) { args.Add(PropertyNames.Text, text); diff --git a/src/library/Telegram.BotAPI/Stickers/setStickerSetThumbnail.cs b/src/library/Telegram.BotAPI/Stickers/setStickerSetThumbnail.cs index 9c2f8de..43831a1 100644 --- a/src/library/Telegram.BotAPI/Stickers/setStickerSetThumbnail.cs +++ b/src/library/Telegram.BotAPI/Stickers/setStickerSetThumbnail.cs @@ -47,8 +47,8 @@ public static Task SetStickerSetThumbnailAsync(this ITelegramBotClient cli /// The instance. /// Sticker set name /// User identifier of the sticker set owner - /// Format of the thumbnail, must be one of “static” for a .WEBP or .PNG image, “animated” for a .TGS animation, or “video” for a WEBM video - /// A .WEBP or .PNG image with the thumbnail, must be up to 128 kilobytes in size and have a width and height of exactly 100px, or a .TGS animation with a thumbnail up to 32 kilobytes in size (see https://core.telegram.org/stickers#animation-requirements for animated sticker technical requirements), or a WEBM video with the thumbnail up to 32 kilobytes in size; see https://core.telegram.org/stickers#video-requirements for video sticker technical requirements. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. More information on Sending Files ». Animated and video sticker set thumbnails can't be uploaded via HTTP URL. If omitted, then the thumbnail is dropped and the first sticker is used as the thumbnail. + /// Format of the thumbnail, must be one of “static” for a .WEBP or .PNG image, “animated” for a .TGS animation, or “video” for a .WEBM video + /// A .WEBP or .PNG image with the thumbnail, must be up to 128 kilobytes in size and have a width and height of exactly 100px, or a .TGS animation with a thumbnail up to 32 kilobytes in size (see https://core.telegram.org/stickers#animation-requirements for animated sticker technical requirements), or a .WEBM video with the thumbnail up to 32 kilobytes in size; see https://core.telegram.org/stickers#video-requirements for video sticker technical requirements. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. More information on Sending Files ». Animated and video sticker set thumbnails can't be uploaded via HTTP URL. If omitted, then the thumbnail is dropped and the first sticker is used as the thumbnail. /// Thrown if is null. /// Thrown if the request to the Telegram Bot API fails. /// @@ -61,8 +61,8 @@ public static bool SetStickerSetThumbnail(this ITelegramBotClient client, string /// The instance. /// Sticker set name /// User identifier of the sticker set owner - /// Format of the thumbnail, must be one of “static” for a .WEBP or .PNG image, “animated” for a .TGS animation, or “video” for a WEBM video - /// A .WEBP or .PNG image with the thumbnail, must be up to 128 kilobytes in size and have a width and height of exactly 100px, or a .TGS animation with a thumbnail up to 32 kilobytes in size (see https://core.telegram.org/stickers#animation-requirements for animated sticker technical requirements), or a WEBM video with the thumbnail up to 32 kilobytes in size; see https://core.telegram.org/stickers#video-requirements for video sticker technical requirements. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. More information on Sending Files ». Animated and video sticker set thumbnails can't be uploaded via HTTP URL. If omitted, then the thumbnail is dropped and the first sticker is used as the thumbnail. + /// Format of the thumbnail, must be one of “static” for a .WEBP or .PNG image, “animated” for a .TGS animation, or “video” for a .WEBM video + /// A .WEBP or .PNG image with the thumbnail, must be up to 128 kilobytes in size and have a width and height of exactly 100px, or a .TGS animation with a thumbnail up to 32 kilobytes in size (see https://core.telegram.org/stickers#animation-requirements for animated sticker technical requirements), or a .WEBM video with the thumbnail up to 32 kilobytes in size; see https://core.telegram.org/stickers#video-requirements for video sticker technical requirements. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. More information on Sending Files ». Animated and video sticker set thumbnails can't be uploaded via HTTP URL. If omitted, then the thumbnail is dropped and the first sticker is used as the thumbnail. /// The cancellation token to cancel operation. /// Thrown if is null. /// Thrown if the request to the Telegram Bot API fails. diff --git a/src/library/Telegram.BotAPI/Stickers/verifyChat.cs b/src/library/Telegram.BotAPI/Stickers/verifyChat.cs new file mode 100644 index 0000000..74052fc --- /dev/null +++ b/src/library/Telegram.BotAPI/Stickers/verifyChat.cs @@ -0,0 +1,93 @@ +// 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.Stickers; + +/// +/// Extension methods for the Telegram Bot API. +/// +public static partial class StickersExtensions +{ + /// + /// Verifies a chat on behalf of the organization which is represented by the bot. Returns True on success. + /// + /// The instance. + /// Unique identifier for the target chat or username of the target channel (in the format @channelusername) + /// Custom description for the verification; 0-70 characters. Must be empty if the organization isn't allowed to provide a custom verification description. + /// Thrown if is null. + /// Thrown if the request to the Telegram Bot API fails. + /// + public static bool VerifyChat(this ITelegramBotClient client, long chatId, string? customDescription = null) => + client.VerifyChatAsync(chatId, customDescription).GetAwaiter().GetResult(); + + /// + /// Verifies a chat on behalf of the organization which is represented by the bot. Returns True on success. + /// + /// The instance. + /// Unique identifier for the target chat or username of the target channel (in the format @channelusername) + /// Custom description for the verification; 0-70 characters. Must be empty if the organization isn't allowed to provide a custom verification description. + /// The cancellation token to cancel operation. + /// Thrown if is null. + /// Thrown if the request to the Telegram Bot API fails. + /// + public static Task VerifyChatAsync(this ITelegramBotClient client, long chatId, string? customDescription = null, CancellationToken cancellationToken = default) + { + if (client is null) + { + throw new ArgumentNullException(nameof(client)); + } + + var args = new Dictionary() + { + { PropertyNames.ChatId, chatId } + }; + if (customDescription is not null) + { + args.Add(PropertyNames.CustomDescription, customDescription); + } + + return client.CallMethodAsync(MethodNames.VerifyChat, args, cancellationToken); + } + + /// + /// Verifies a chat on behalf of the organization which is represented by the bot. Returns True on success. + /// + /// The instance. + /// Unique identifier for the target chat or username of the target channel (in the format @channelusername) + /// Custom description for the verification; 0-70 characters. Must be empty if the organization isn't allowed to provide a custom verification description. + /// Thrown if is null. + /// Thrown if the request to the Telegram Bot API fails. + /// + public static bool VerifyChat(this ITelegramBotClient client, string chatId, string? customDescription = null) => + client.VerifyChatAsync(chatId, customDescription).GetAwaiter().GetResult(); + + /// + /// Verifies a chat on behalf of the organization which is represented by the bot. Returns True on success. + /// + /// The instance. + /// Unique identifier for the target chat or username of the target channel (in the format @channelusername) + /// Custom description for the verification; 0-70 characters. Must be empty if the organization isn't allowed to provide a custom verification description. + /// The cancellation token to cancel operation. + /// Thrown if is null. + /// Thrown if the request to the Telegram Bot API fails. + /// + public static Task VerifyChatAsync(this ITelegramBotClient client, string chatId, string? customDescription = null, CancellationToken cancellationToken = default) + { + if (client is null) + { + throw new ArgumentNullException(nameof(client)); + } + + var args = new Dictionary() + { + { PropertyNames.ChatId, chatId ?? throw new ArgumentNullException(nameof(chatId)) } + }; + if (customDescription is not null) + { + args.Add(PropertyNames.CustomDescription, customDescription); + } + + return client.CallMethodAsync(MethodNames.VerifyChat, args, cancellationToken); + } +} diff --git a/src/library/Telegram.BotAPI/Stickers/verifyUser.cs b/src/library/Telegram.BotAPI/Stickers/verifyUser.cs new file mode 100644 index 0000000..0d7c3ed --- /dev/null +++ b/src/library/Telegram.BotAPI/Stickers/verifyUser.cs @@ -0,0 +1,52 @@ +// 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.Stickers; + +/// +/// Extension methods for the Telegram Bot API. +/// +public static partial class StickersExtensions +{ + /// + /// Verifies a user on behalf of the organization which is represented by the bot. Returns True on success. + /// + /// The instance. + /// Unique identifier of the target user + /// Custom description for the verification; 0-70 characters. Must be empty if the organization isn't allowed to provide a custom verification description. + /// Thrown if is null. + /// Thrown if the request to the Telegram Bot API fails. + /// + public static bool VerifyUser(this ITelegramBotClient client, long userId, string? customDescription = null) => + client.VerifyUserAsync(userId, customDescription).GetAwaiter().GetResult(); + + /// + /// Verifies a user on behalf of the organization which is represented by the bot. Returns True on success. + /// + /// The instance. + /// Unique identifier of the target user + /// Custom description for the verification; 0-70 characters. Must be empty if the organization isn't allowed to provide a custom verification description. + /// The cancellation token to cancel operation. + /// Thrown if is null. + /// Thrown if the request to the Telegram Bot API fails. + /// + public static Task VerifyUserAsync(this ITelegramBotClient client, long userId, string? customDescription = null, CancellationToken cancellationToken = default) + { + if (client is null) + { + throw new ArgumentNullException(nameof(client)); + } + + var args = new Dictionary() + { + { PropertyNames.UserId, userId } + }; + if (customDescription is not null) + { + args.Add(PropertyNames.CustomDescription, customDescription); + } + + return client.CallMethodAsync(MethodNames.VerifyUser, args, cancellationToken); + } +} diff --git a/src/library/Telegram.BotAPI/Telegram.BotAPI.csproj b/src/library/Telegram.BotAPI/Telegram.BotAPI.csproj index e10688f..697f30e 100644 --- a/src/library/Telegram.BotAPI/Telegram.BotAPI.csproj +++ b/src/library/Telegram.BotAPI/Telegram.BotAPI.csproj @@ -2,7 +2,7 @@ netstandard2.0 - 8.1 + 8.2 $(AssemblyName) Quetzal Rivera true @@ -10,7 +10,7 @@ Quetzal Rivera 2024 © en true - A very complete library to use Telegram Bot API in your NET project. Full support for Bot API v8.1 (December 4, 2024). + A very complete library to use Telegram Bot API in your NET project. Full support for Bot API v8.2 (January 1, 2025). - Contains all classes and methods available from the Bot API. Telegram;Bot;API @@ -25,7 +25,7 @@ https://github.com/Eptagone/Telegram.BotAPI Telegram.BotAPI - Updated to Bot API v8.1 + Updated to Bot API v8.2 true latest-recommended README.md