Skip to content

Commit 68d6b52

Browse files
committed
feat: update to bot api 9.0
1 parent 7c4bfa0 commit 68d6b52

File tree

88 files changed

+3545
-79
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+3545
-79
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22
| -------------------------------------------------- | -------------------------------- |
33

44
[![NuGet version (Telegram.BotAPI)](https://img.shields.io/nuget/v/Telegram.BotAPI?style=flat-square&logo=nuget)](https://www.nuget.org/packages/Telegram.BotAPI/)
5-
[![Compatible with Bot API v8.3](https://img.shields.io/badge/Bot%20API%20version-v8.3-blue?style=flat-square)](https://core.telegram.org/bots/api#february-12-2025)
5+
[![Compatible with Bot API v9.0](https://img.shields.io/badge/Bot%20API%20version-v9.0-blue?style=flat-square)](https://core.telegram.org/bots/api#april-11-2025)
66

7-
**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.3 released on January 1, 2025.
7+
**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 9.0 released on April 11, 2025.
88

99
[![Telegram Chat](https://img.shields.io/badge/Telegram.BotAPI%20--%20Chat-Join-blue?style=social&logo=telegram)](https://t.me/TBAPINET)
1010

1111
---
1212

1313
## Features
1414

15-
- Contains pre-defined methods for all Bot API 8.3 methods.
16-
- Contains classes for each object type used in the Bot API 8.3.
15+
- Contains pre-defined methods for all Bot API 9.0 methods.
16+
- Contains classes for each object type used in the Bot API 9.0.
1717
- Sync and async methods.
1818
- Uses [System.Text.Json](https://www.nuget.org/packages/System.Text.Json/).
1919

src/examples/readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Telegram.BotAPI NET Examples
22

33
[![NuGet version (Telegram.BotAPI)](https://img.shields.io/nuget/v/Telegram.BotAPI?style=flat-square&logo=nuget)](https://www.nuget.org/packages/Telegram.BotAPI/)
4-
[![Compatible with Bot API v8.3](https://img.shields.io/badge/Bot%20API%20version-v8.3-blue?style=flat-square)](https://core.telegram.org/bots/api#february-12-2025)
4+
[![Compatible with Bot API v9.0](https://img.shields.io/badge/Bot%20API%20version-v9.0-blue?style=flat-square)](https://core.telegram.org/bots/api#april-11-2025)
55

66
## Sample list
77

src/library/Telegram.BotAPI/AvailableMethods/Args/SendPaidMediaArgs.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public class SendPaidMediaArgs : AttachedFilesArgsBase
1515
/// Initializes a new instance of the <see cref="SendPaidMediaArgs"/> class.
1616
/// </summary>
1717
/// <param name="chatId">Unique identifier for the target chat or username of the target channel (in the format <em>@channelusername</em>). If the chat is a channel, all Telegram Star proceeds from this media will be credited to the chat's balance. Otherwise, they will be credited to the bot's balance.</param>
18-
/// <param name="starCount">The number of Telegram Stars that must be paid to buy access to the media; 1-2500</param>
18+
/// <param name="starCount">The number of Telegram Stars that must be paid to buy access to the media; 1-10000</param>
1919
/// <param name="media">A JSON-serialized array describing the media to be sent; up to 10 items</param>
2020
public SendPaidMediaArgs(long chatId, int starCount, IEnumerable<InputPaidMedia> media)
2121
{
@@ -28,7 +28,7 @@ public SendPaidMediaArgs(long chatId, int starCount, IEnumerable<InputPaidMedia>
2828
/// Initializes a new instance of the <see cref="SendPaidMediaArgs"/> class.
2929
/// </summary>
3030
/// <param name="chatId">Unique identifier for the target chat or username of the target channel (in the format <em>@channelusername</em>). If the chat is a channel, all Telegram Star proceeds from this media will be credited to the chat's balance. Otherwise, they will be credited to the bot's balance.</param>
31-
/// <param name="starCount">The number of Telegram Stars that must be paid to buy access to the media; 1-2500</param>
31+
/// <param name="starCount">The number of Telegram Stars that must be paid to buy access to the media; 1-10000</param>
3232
/// <param name="media">A JSON-serialized array describing the media to be sent; up to 10 items</param>
3333
public SendPaidMediaArgs(string chatId, int starCount, IEnumerable<InputPaidMedia> media)
3434
{
@@ -50,7 +50,7 @@ public SendPaidMediaArgs(string chatId, int starCount, IEnumerable<InputPaidMedi
5050
public object ChatId { get; set; }
5151

5252
/// <summary>
53-
/// The number of Telegram Stars that must be paid to buy access to the media; 1-2500
53+
/// The number of Telegram Stars that must be paid to buy access to the media; 1-10000
5454
/// </summary>
5555
[JsonPropertyName(PropertyNames.StarCount)]
5656
public int StarCount { get; set; }

src/library/Telegram.BotAPI/AvailableMethods/createChatSubscriptionInviteLink.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public static partial class AvailableMethodsExtensions
1717
/// <param name="client">The <see cref="ITelegramBotClient"/> instance.</param>
1818
/// <param name="chatId">Unique identifier for the target channel chat or username of the target channel (in the format <em>@channelusername</em>)</param>
1919
/// <param name="subscriptionPeriod">The number of seconds the subscription will be active for before the next payment. Currently, it must always be 2592000 (30 days).</param>
20-
/// <param name="subscriptionPrice">The amount of Telegram Stars a user must pay initially and after each subsequent subscription period to be a member of the chat; 1-2500</param>
20+
/// <param name="subscriptionPrice">The amount of Telegram Stars a user must pay initially and after each subsequent subscription period to be a member of the chat; 1-10000</param>
2121
/// <param name="name">Invite link name; 0-32 characters</param>
2222
/// <exception cref="ArgumentNullException">Thrown if <paramref name="client"/> is <c>null</c>.</exception>
2323
/// <exception cref="BotRequestException">Thrown if the request to the Telegram Bot API fails.</exception>
@@ -31,7 +31,7 @@ public static ChatInviteLink CreateChatSubscriptionInviteLink(this ITelegramBotC
3131
/// <param name="client">The <see cref="ITelegramBotClient"/> instance.</param>
3232
/// <param name="chatId">Unique identifier for the target channel chat or username of the target channel (in the format <em>@channelusername</em>)</param>
3333
/// <param name="subscriptionPeriod">The number of seconds the subscription will be active for before the next payment. Currently, it must always be 2592000 (30 days).</param>
34-
/// <param name="subscriptionPrice">The amount of Telegram Stars a user must pay initially and after each subsequent subscription period to be a member of the chat; 1-2500</param>
34+
/// <param name="subscriptionPrice">The amount of Telegram Stars a user must pay initially and after each subsequent subscription period to be a member of the chat; 1-10000</param>
3535
/// <param name="name">Invite link name; 0-32 characters</param>
3636
/// <param name="cancellationToken">The cancellation token to cancel operation.</param>
3737
/// <exception cref="ArgumentNullException">Thrown if <paramref name="client"/> is <c>null</c>.</exception>
@@ -64,7 +64,7 @@ public static Task<ChatInviteLink> CreateChatSubscriptionInviteLinkAsync(this IT
6464
/// <param name="client">The <see cref="ITelegramBotClient"/> instance.</param>
6565
/// <param name="chatId">Unique identifier for the target channel chat or username of the target channel (in the format <em>@channelusername</em>)</param>
6666
/// <param name="subscriptionPeriod">The number of seconds the subscription will be active for before the next payment. Currently, it must always be 2592000 (30 days).</param>
67-
/// <param name="subscriptionPrice">The amount of Telegram Stars a user must pay initially and after each subsequent subscription period to be a member of the chat; 1-2500</param>
67+
/// <param name="subscriptionPrice">The amount of Telegram Stars a user must pay initially and after each subsequent subscription period to be a member of the chat; 1-10000</param>
6868
/// <param name="name">Invite link name; 0-32 characters</param>
6969
/// <exception cref="ArgumentNullException">Thrown if <paramref name="client"/> is <c>null</c>.</exception>
7070
/// <exception cref="BotRequestException">Thrown if the request to the Telegram Bot API fails.</exception>
@@ -78,7 +78,7 @@ public static ChatInviteLink CreateChatSubscriptionInviteLink(this ITelegramBotC
7878
/// <param name="client">The <see cref="ITelegramBotClient"/> instance.</param>
7979
/// <param name="chatId">Unique identifier for the target channel chat or username of the target channel (in the format <em>@channelusername</em>)</param>
8080
/// <param name="subscriptionPeriod">The number of seconds the subscription will be active for before the next payment. Currently, it must always be 2592000 (30 days).</param>
81-
/// <param name="subscriptionPrice">The amount of Telegram Stars a user must pay initially and after each subsequent subscription period to be a member of the chat; 1-2500</param>
81+
/// <param name="subscriptionPrice">The amount of Telegram Stars a user must pay initially and after each subsequent subscription period to be a member of the chat; 1-10000</param>
8282
/// <param name="name">Invite link name; 0-32 characters</param>
8383
/// <param name="cancellationToken">The cancellation token to cancel operation.</param>
8484
/// <exception cref="ArgumentNullException">Thrown if <paramref name="client"/> is <c>null</c>.</exception>

src/library/Telegram.BotAPI/AvailableMethods/sendPaidMedia.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public static Task<Message> SendPaidMediaAsync(this ITelegramBotClient client, S
4646
/// </summary>
4747
/// <param name="client">The <see cref="ITelegramBotClient"/> instance.</param>
4848
/// <param name="chatId">Unique identifier for the target chat or username of the target channel (in the format <em>@channelusername</em>). If the chat is a channel, all Telegram Star proceeds from this media will be credited to the chat's balance. Otherwise, they will be credited to the bot's balance.</param>
49-
/// <param name="starCount">The number of Telegram Stars that must be paid to buy access to the media; 1-2500</param>
49+
/// <param name="starCount">The number of Telegram Stars that must be paid to buy access to the media; 1-10000</param>
5050
/// <param name="media">A JSON-serialized array describing the media to be sent; up to 10 items</param>
5151
/// <param name="businessConnectionId">Unique identifier of the business connection on behalf of which the message will be sent</param>
5252
/// <param name="payload">Bot-defined paid media payload, 0-128 bytes. This will not be displayed to the user, use it for your internal processes.</param>
@@ -70,7 +70,7 @@ public static Message SendPaidMedia(this ITelegramBotClient client, long chatId,
7070
/// </summary>
7171
/// <param name="client">The <see cref="ITelegramBotClient"/> instance.</param>
7272
/// <param name="chatId">Unique identifier for the target chat or username of the target channel (in the format <em>@channelusername</em>). If the chat is a channel, all Telegram Star proceeds from this media will be credited to the chat's balance. Otherwise, they will be credited to the bot's balance.</param>
73-
/// <param name="starCount">The number of Telegram Stars that must be paid to buy access to the media; 1-2500</param>
73+
/// <param name="starCount">The number of Telegram Stars that must be paid to buy access to the media; 1-10000</param>
7474
/// <param name="media">A JSON-serialized array describing the media to be sent; up to 10 items</param>
7575
/// <param name="businessConnectionId">Unique identifier of the business connection on behalf of which the message will be sent</param>
7676
/// <param name="payload">Bot-defined paid media payload, 0-128 bytes. This will not be displayed to the user, use it for your internal processes.</param>
@@ -153,7 +153,7 @@ public static Task<Message> SendPaidMediaAsync(this ITelegramBotClient client, l
153153
/// </summary>
154154
/// <param name="client">The <see cref="ITelegramBotClient"/> instance.</param>
155155
/// <param name="chatId">Unique identifier for the target chat or username of the target channel (in the format <em>@channelusername</em>). If the chat is a channel, all Telegram Star proceeds from this media will be credited to the chat's balance. Otherwise, they will be credited to the bot's balance.</param>
156-
/// <param name="starCount">The number of Telegram Stars that must be paid to buy access to the media; 1-2500</param>
156+
/// <param name="starCount">The number of Telegram Stars that must be paid to buy access to the media; 1-10000</param>
157157
/// <param name="media">A JSON-serialized array describing the media to be sent; up to 10 items</param>
158158
/// <param name="businessConnectionId">Unique identifier of the business connection on behalf of which the message will be sent</param>
159159
/// <param name="payload">Bot-defined paid media payload, 0-128 bytes. This will not be displayed to the user, use it for your internal processes.</param>
@@ -177,7 +177,7 @@ public static Message SendPaidMedia(this ITelegramBotClient client, string chatI
177177
/// </summary>
178178
/// <param name="client">The <see cref="ITelegramBotClient"/> instance.</param>
179179
/// <param name="chatId">Unique identifier for the target chat or username of the target channel (in the format <em>@channelusername</em>). If the chat is a channel, all Telegram Star proceeds from this media will be credited to the chat's balance. Otherwise, they will be credited to the bot's balance.</param>
180-
/// <param name="starCount">The number of Telegram Stars that must be paid to buy access to the media; 1-2500</param>
180+
/// <param name="starCount">The number of Telegram Stars that must be paid to buy access to the media; 1-10000</param>
181181
/// <param name="media">A JSON-serialized array describing the media to be sent; up to 10 items</param>
182182
/// <param name="businessConnectionId">Unique identifier of the business connection on behalf of which the message will be sent</param>
183183
/// <param name="payload">Bot-defined paid media payload, 0-128 bytes. This will not be displayed to the user, use it for your internal processes.</param>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Copyright (c) 2025 Quetzal Rivera.
2+
// Licensed under the MIT License, See LICENCE in the project root for license information.
3+
//* This file is auto-generated. Don't edit it manually!
4+
5+
namespace Telegram.BotAPI.AvailableTypes;
6+
7+
/// <summary>
8+
/// This object describes the types of gifts that can be gifted to a user or a chat.
9+
/// </summary>
10+
public class AcceptedGiftTypes
11+
{
12+
/// <summary>
13+
/// True, if unlimited regular gifts are accepted
14+
/// </summary>
15+
[JsonPropertyName(PropertyNames.UnlimitedGifts)]
16+
public bool UnlimitedGifts { get; set; }
17+
18+
/// <summary>
19+
/// True, if limited regular gifts are accepted
20+
/// </summary>
21+
[JsonPropertyName(PropertyNames.LimitedGifts)]
22+
public bool LimitedGifts { get; set; }
23+
24+
/// <summary>
25+
/// True, if unique gifts or gifts that can be upgraded to unique for free are accepted
26+
/// </summary>
27+
[JsonPropertyName(PropertyNames.UniqueGifts)]
28+
public bool UniqueGifts { get; set; }
29+
30+
/// <summary>
31+
/// True, if a Telegram Premium subscription is accepted
32+
/// </summary>
33+
[JsonPropertyName(PropertyNames.PremiumSubscription)]
34+
public bool PremiumSubscription { get; set; }
35+
}
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
// Copyright (c) 2025 Quetzal Rivera.
2+
// Licensed under the MIT License, See LICENCE in the project root for license information.
3+
//* This file is auto-generated. Don't edit it manually!
4+
5+
namespace Telegram.BotAPI.AvailableTypes;
6+
7+
/// <summary>
8+
/// Represents the rights of a business bot.
9+
/// </summary>
10+
public class BusinessBotRights
11+
{
12+
/// <summary>
13+
/// Optional. True, if the bot can send and edit messages in the private chats that had incoming messages in the last 24 hours
14+
/// </summary>
15+
[JsonPropertyName(PropertyNames.CanReply)]
16+
public bool? CanReply { get; set; }
17+
18+
/// <summary>
19+
/// Optional. True, if the bot can mark incoming private messages as read
20+
/// </summary>
21+
[JsonPropertyName(PropertyNames.CanReadMessages)]
22+
public bool? CanReadMessages { get; set; }
23+
24+
/// <summary>
25+
/// Optional. True, if the bot can delete messages sent by the bot
26+
/// </summary>
27+
[JsonPropertyName(PropertyNames.CanDeleteOutgoingMessages)]
28+
public bool? CanDeleteOutgoingMessages { get; set; }
29+
30+
/// <summary>
31+
/// Optional. True, if the bot can delete all private messages in managed chats
32+
/// </summary>
33+
[JsonPropertyName(PropertyNames.CanDeleteAllMessages)]
34+
public bool? CanDeleteAllMessages { get; set; }
35+
36+
/// <summary>
37+
/// Optional. True, if the bot can edit the first and last name of the business account
38+
/// </summary>
39+
[JsonPropertyName(PropertyNames.CanEditName)]
40+
public bool? CanEditName { get; set; }
41+
42+
/// <summary>
43+
/// Optional. True, if the bot can edit the bio of the business account
44+
/// </summary>
45+
[JsonPropertyName(PropertyNames.CanEditBio)]
46+
public bool? CanEditBio { get; set; }
47+
48+
/// <summary>
49+
/// Optional. True, if the bot can edit the profile photo of the business account
50+
/// </summary>
51+
[JsonPropertyName(PropertyNames.CanEditProfilePhoto)]
52+
public bool? CanEditProfilePhoto { get; set; }
53+
54+
/// <summary>
55+
/// Optional. True, if the bot can edit the username of the business account
56+
/// </summary>
57+
[JsonPropertyName(PropertyNames.CanEditUsername)]
58+
public bool? CanEditUsername { get; set; }
59+
60+
/// <summary>
61+
/// Optional. True, if the bot can change the privacy settings pertaining to gifts for the business account
62+
/// </summary>
63+
[JsonPropertyName(PropertyNames.CanChangeGiftSettings)]
64+
public bool? CanChangeGiftSettings { get; set; }
65+
66+
/// <summary>
67+
/// Optional. True, if the bot can view gifts and the amount of Telegram Stars owned by the business account
68+
/// </summary>
69+
[JsonPropertyName(PropertyNames.CanViewGiftsAndStars)]
70+
public bool? CanViewGiftsAndStars { get; set; }
71+
72+
/// <summary>
73+
/// Optional. True, if the bot can convert regular gifts owned by the business account to Telegram Stars
74+
/// </summary>
75+
[JsonPropertyName(PropertyNames.CanConvertGiftsToStars)]
76+
public bool? CanConvertGiftsToStars { get; set; }
77+
78+
/// <summary>
79+
/// Optional. True, if the bot can transfer and upgrade gifts owned by the business account
80+
/// </summary>
81+
[JsonPropertyName(PropertyNames.CanTransferAndUpgradeGifts)]
82+
public bool? CanTransferAndUpgradeGifts { get; set; }
83+
84+
/// <summary>
85+
/// Optional. True, if the bot can transfer Telegram Stars received by the business account to its own account, or use them to upgrade and transfer gifts
86+
/// </summary>
87+
[JsonPropertyName(PropertyNames.CanTransferStars)]
88+
public bool? CanTransferStars { get; set; }
89+
90+
/// <summary>
91+
/// Optional. True, if the bot can post, edit and delete stories on behalf of the business account
92+
/// </summary>
93+
[JsonPropertyName(PropertyNames.CanManageStories)]
94+
public bool? CanManageStories { get; set; }
95+
}

src/library/Telegram.BotAPI/AvailableTypes/BusinessConnection.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ public class BusinessConnection
3434
public int Date { get; set; }
3535

3636
/// <summary>
37-
/// True, if the bot can act on behalf of the business account in chats that were active in the last 24 hours
37+
/// Optional. Rights of the business bot
3838
/// </summary>
39-
[JsonPropertyName(PropertyNames.CanReply)]
40-
public bool CanReply { get; set; }
39+
[JsonPropertyName(PropertyNames.Rights)]
40+
public BusinessBotRights? Rights { get; set; }
4141

4242
/// <summary>
4343
/// True, if the connection is active

src/library/Telegram.BotAPI/AvailableTypes/Chat/ChatFullInfo.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,10 @@ public class ChatFullInfo : Chat
154154
public ChatPermissions? Permissions { get; set; }
155155

156156
/// <summary>
157-
/// Optional. <em>True</em>, if gifts can be sent to the chat
157+
/// Information about types of gifts that are accepted by the chat or by the corresponding user for private chats
158158
/// </summary>
159-
[JsonPropertyName(PropertyNames.CanSendGift)]
160-
public bool? CanSendGift { get; set; }
159+
[JsonPropertyName(PropertyNames.AcceptedGiftTypes)]
160+
public AcceptedGiftTypes AcceptedGiftTypes { get; set; } = null!;
161161

162162
/// <summary>
163163
/// Optional. <em>True</em>, if paid media messages can be sent or forwarded to the channel chat. The field is available only for channel chats.

0 commit comments

Comments
 (0)