Skip to content

Commit

Permalink
feat: Update to Bot API 8.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Eptagone committed Jan 4, 2025
1 parent c45240d commit 3cc4077
Show file tree
Hide file tree
Showing 23 changed files with 330 additions and 40 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
| -------------------------------------------------- | -------------------------------- |

[![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)

---

## 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/).

Expand Down
2 changes: 1 addition & 1 deletion src/examples/readme.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace Telegram.BotAPI.AvailableTypes;

/// <summary>
/// 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.
/// </summary>
public class BackgroundTypePattern : BackgroundType
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class GetUpdatesArgs
public int? Timeout { get; set; }

/// <summary>
/// A JSON-serialized list of the update types you want your bot to receive. For example, specify <em>["message", "edited_channel_post", "callback_query"]</em> to only receive updates of these types. See <see cref="Update"/> for a complete list of available update types. Specify an empty list to receive all update types except <em>chat_member</em>, <em>message_reaction</em>, and <em>message_reaction_count</em> (default). If not specified, the previous setting will be used.<br /><br />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 <em>["message", "edited_channel_post", "callback_query"]</em> to only receive updates of these types. See <see cref="Update"/> for a complete list of available update types. Specify an empty list to receive all update types except <em>chat_member</em>, <em>message_reaction</em>, and <em>message_reaction_count</em> (default). If not specified, the previous setting will be used.<br /><br />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.
/// </summary>
[JsonPropertyName(PropertyNames.AllowedUpdates)]
public IEnumerable<string>? AllowedUpdates { get; set; }
Expand Down
4 changes: 2 additions & 2 deletions src/library/Telegram.BotAPI/GettingUpdates/getUpdates.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public static Task<IEnumerable<Update>> GetUpdatesAsync(this ITelegramBotClient
/// <param name="offset">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 <a href="https://core.telegram.org/bots/api#getupdates">getUpdates</a> is called with an <em>offset</em> higher than its <em>update_id</em>. The negative offset can be specified to retrieve updates starting from <em>-offset</em> update from the end of the updates queue. All previous updates will be forgotten.</param>
/// <param name="limit">Limits the number of updates to be retrieved. Values between 1-100 are accepted. Defaults to 100.</param>
/// <param name="timeout">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.</param>
/// <param name="allowedUpdates">A JSON-serialized list of the update types you want your bot to receive. For example, specify <em>["message", "edited_channel_post", "callback_query"]</em> to only receive updates of these types. See <see cref="Update"/> for a complete list of available update types. Specify an empty list to receive all update types except <em>chat_member</em>, <em>message_reaction</em>, and <em>message_reaction_count</em> (default). If not specified, the previous setting will be used.<br /><br />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.</param>
/// <param name="allowedUpdates">A JSON-serialized list of the update types you want your bot to receive. For example, specify <em>["message", "edited_channel_post", "callback_query"]</em> to only receive updates of these types. See <see cref="Update"/> for a complete list of available update types. Specify an empty list to receive all update types except <em>chat_member</em>, <em>message_reaction</em>, and <em>message_reaction_count</em> (default). If not specified, the previous setting will be used.<br /><br />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.</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>
Expand All @@ -60,7 +60,7 @@ public static IEnumerable<Update> GetUpdates(this ITelegramBotClient client, int
/// <param name="offset">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 <a href="https://core.telegram.org/bots/api#getupdates">getUpdates</a> is called with an <em>offset</em> higher than its <em>update_id</em>. The negative offset can be specified to retrieve updates starting from <em>-offset</em> update from the end of the updates queue. All previous updates will be forgotten.</param>
/// <param name="limit">Limits the number of updates to be retrieved. Values between 1-100 are accepted. Defaults to 100.</param>
/// <param name="timeout">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.</param>
/// <param name="allowedUpdates">A JSON-serialized list of the update types you want your bot to receive. For example, specify <em>["message", "edited_channel_post", "callback_query"]</em> to only receive updates of these types. See <see cref="Update"/> for a complete list of available update types. Specify an empty list to receive all update types except <em>chat_member</em>, <em>message_reaction</em>, and <em>message_reaction_count</em> (default). If not specified, the previous setting will be used.<br /><br />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.</param>
/// <param name="allowedUpdates">A JSON-serialized list of the update types you want your bot to receive. For example, specify <em>["message", "edited_channel_post", "callback_query"]</em> to only receive updates of these types. See <see cref="Update"/> for a complete list of available update types. Specify an empty list to receive all update types except <em>chat_member</em>, <em>message_reaction</em>, and <em>message_reaction_count</em> (default). If not specified, the previous setting will be used.<br /><br />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.</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>
Expand Down
8 changes: 4 additions & 4 deletions src/library/Telegram.BotAPI/GettingUpdates/setWebhook.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Telegram.BotAPI.GettingUpdates;
public static partial class GettingUpdatesExtensions
{
/// <summary>
/// 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 <see cref="Update"/>. In case of an unsuccessful request, we will give up after a reasonable amount of attempts. Returns <em>True</em> 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 <see cref="Update"/>. In case of an unsuccessful request (a request with response <a href="https://en.wikipedia.org/wiki/List_of_HTTP_status_codes">HTTP status code</a> different from <em>2XY</em>), we will repeat the request and give up after a reasonable amount of attempts. Returns <em>True</em> on success.
/// If you'd like to make sure that the webhook was set by you, you can specify secret data in the parameter <em>secret_token</em>. If specified, the request will contain a header “X-Telegram-Bot-Api-Secret-Token” with the secret token as content.
/// </summary>
/// <param name="client">The <see cref="ITelegramBotClient"/> instance.</param>
Expand All @@ -24,7 +24,7 @@ public static bool SetWebhook(this ITelegramBotClient client, SetWebhookArgs arg
client.SetWebhookAsync(args).GetAwaiter().GetResult();

/// <summary>
/// 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 <see cref="Update"/>. In case of an unsuccessful request, we will give up after a reasonable amount of attempts. Returns <em>True</em> 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 <see cref="Update"/>. In case of an unsuccessful request (a request with response <a href="https://en.wikipedia.org/wiki/List_of_HTTP_status_codes">HTTP status code</a> different from <em>2XY</em>), we will repeat the request and give up after a reasonable amount of attempts. Returns <em>True</em> on success.
/// If you'd like to make sure that the webhook was set by you, you can specify secret data in the parameter <em>secret_token</em>. If specified, the request will contain a header “X-Telegram-Bot-Api-Secret-Token” with the secret token as content.
/// </summary>
/// <param name="client">The <see cref="ITelegramBotClient"/> instance.</param>
Expand All @@ -44,7 +44,7 @@ public static Task<bool> SetWebhookAsync(this ITelegramBotClient client, SetWebh
}

/// <summary>
/// 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 <see cref="Update"/>. In case of an unsuccessful request, we will give up after a reasonable amount of attempts. Returns <em>True</em> 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 <see cref="Update"/>. In case of an unsuccessful request (a request with response <a href="https://en.wikipedia.org/wiki/List_of_HTTP_status_codes">HTTP status code</a> different from <em>2XY</em>), we will repeat the request and give up after a reasonable amount of attempts. Returns <em>True</em> on success.
/// If you'd like to make sure that the webhook was set by you, you can specify secret data in the parameter <em>secret_token</em>. If specified, the request will contain a header “X-Telegram-Bot-Api-Secret-Token” with the secret token as content.
/// </summary>
/// <param name="client">The <see cref="ITelegramBotClient"/> instance.</param>
Expand All @@ -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();

/// <summary>
/// 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 <see cref="Update"/>. In case of an unsuccessful request, we will give up after a reasonable amount of attempts. Returns <em>True</em> 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 <see cref="Update"/>. In case of an unsuccessful request (a request with response <a href="https://en.wikipedia.org/wiki/List_of_HTTP_status_codes">HTTP status code</a> different from <em>2XY</em>), we will repeat the request and give up after a reasonable amount of attempts. Returns <em>True</em> on success.
/// If you'd like to make sure that the webhook was set by you, you can specify secret data in the parameter <em>secret_token</em>. If specified, the request will contain a header “X-Telegram-Bot-Api-Secret-Token” with the secret token as content.
/// </summary>
/// <param name="client">The <see cref="ITelegramBotClient"/> instance.</param>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,6 @@ public class InlineQueryResultArticle : InlineQueryResult
[JsonPropertyName(PropertyNames.Url)]
public string? Url { get; set; }

/// <summary>
/// Optional. Pass <em>True</em> if you don't want the URL to be shown in the message
/// </summary>
[JsonPropertyName(PropertyNames.HideUrl)]
public bool? HideUrl { get; set; }

/// <summary>
/// Optional. Short description of the result
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class InlineQueryResultGif : InlineQueryResult
public override string Id { get; set; } = null!;

/// <summary>
/// A valid URL for the GIF file. File size must not exceed 1MB
/// A valid URL for the GIF file
/// </summary>
[JsonPropertyName(PropertyNames.GifUrl)]
public string GifUrl { get; set; } = null!;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class InlineQueryResultMpeg4Gif : InlineQueryResult
public override string Id { get; set; } = null!;

/// <summary>
/// A valid URL for the MPEG4 file. File size must not exceed 1MB
/// A valid URL for the MPEG4 file
/// </summary>
[JsonPropertyName(PropertyNames.Mpeg4Url)]
public string Mpeg4Url { get; set; } = null!;
Expand Down
4 changes: 4 additions & 0 deletions src/library/Telegram.BotAPI/MethodNames.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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
}
4 changes: 3 additions & 1 deletion src/library/Telegram.BotAPI/PropertyNames.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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";
Expand Down
Loading

0 comments on commit 3cc4077

Please sign in to comment.