Skip to content

Commit 9468af6

Browse files
committed
feat: Update to Bot API 7.10
1 parent 533e0a3 commit 9468af6

21 files changed

+143
-43
lines changed

README.md

+4-4
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 v7.9](https://img.shields.io/badge/Bot%20API%20version-v7.9-blue?style=flat-square)](https://core.telegram.org/bots/api#august-14-2024)
5+
[![Compatible with Bot API v7.10](https://img.shields.io/badge/Bot%20API%20version-v7.10-blue?style=flat-square)](https://core.telegram.org/bots/api#september-6-2024)
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 7.9 released on August 14, 2024.
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 7.10 released on September 6, 2024.
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 7.9 methods.
16-
- Contains classes for each object type used in the Bot API 7.9.
15+
- Contains pre-defined methods for all Bot API 7.10 methods.
16+
- Contains classes for each object type used in the Bot API 7.10.
1717
- Sync and async methods.
1818
- Uses [System.Text.Json](https://www.nuget.org/packages/System.Text.Json/).
1919

src/examples/readme.md

+1-1
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 v7.9](https://img.shields.io/badge/Bot%20API%20version-v7.9-blue?style=flat-square)](https://core.telegram.org/bots/api#august-14-2024)
4+
[![Compatible with Bot API v7.10](https://img.shields.io/badge/Bot%20API%20version-v7.10-blue?style=flat-square)](https://core.telegram.org/bots/api#september-6-2024)
55

66
## Sample list
77

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

+9-3
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</param>
18+
/// <param name="starCount">The number of Telegram Stars that must be paid to buy access to the media; 1-2500</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</param>
31+
/// <param name="starCount">The number of Telegram Stars that must be paid to buy access to the media; 1-2500</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
53+
/// The number of Telegram Stars that must be paid to buy access to the media; 1-2500
5454
/// </summary>
5555
[JsonPropertyName(PropertyNames.StarCount)]
5656
public int StarCount { get; set; }
@@ -61,6 +61,12 @@ public SendPaidMediaArgs(string chatId, int starCount, IEnumerable<InputPaidMedi
6161
[JsonPropertyName(PropertyNames.Media)]
6262
public IEnumerable<InputPaidMedia> Media { get; set; }
6363

64+
/// <summary>
65+
/// Bot-defined paid media payload, 0-128 bytes. This will not be displayed to the user, use it for your internal processes.
66+
/// </summary>
67+
[JsonPropertyName(PropertyNames.Payload)]
68+
public string? Payload { get; set; }
69+
6470
/// <summary>
6571
/// Media caption, 0-1024 characters after entities parsing
6672
/// </summary>

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

+22-10
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,10 @@ 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</param>
49+
/// <param name="starCount">The number of Telegram Stars that must be paid to buy access to the media; 1-2500</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>
52+
/// <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>
5253
/// <param name="caption">Media caption, 0-1024 characters after entities parsing</param>
5354
/// <param name="parseMode">Mode for parsing entities in the media caption. See <a href="https://core.telegram.org/bots/api#formatting-options">formatting options</a> for more details.</param>
5455
/// <param name="captionEntities">A JSON-serialized list of special entities that appear in the caption, which can be specified instead of <em>parse_mode</em></param>
@@ -60,17 +61,18 @@ public static Task<Message> SendPaidMediaAsync(this ITelegramBotClient client, S
6061
/// <exception cref="ArgumentNullException">Thrown if <paramref name="client"/> is <c>null</c>.</exception>
6162
/// <exception cref="BotRequestException">Thrown if the request to the Telegram Bot API fails.</exception>
6263
/// <returns></returns>
63-
public static Message SendPaidMedia(this ITelegramBotClient client, long chatId, int starCount, IEnumerable<InputPaidMedia> media, string? businessConnectionId = null, string? caption = null, string? parseMode = null, IEnumerable<MessageEntity>? captionEntities = null, bool? showCaptionAboveMedia = null, bool? disableNotification = null, bool? protectContent = null, ReplyParameters? replyParameters = null, ReplyMarkup? replyMarkup = null) =>
64-
client.SendPaidMediaAsync(chatId, starCount, media, businessConnectionId, caption, parseMode, captionEntities, showCaptionAboveMedia, disableNotification, protectContent, replyParameters, replyMarkup).GetAwaiter().GetResult();
64+
public static Message SendPaidMedia(this ITelegramBotClient client, long chatId, int starCount, IEnumerable<InputPaidMedia> media, string? businessConnectionId = null, string? payload = null, string? caption = null, string? parseMode = null, IEnumerable<MessageEntity>? captionEntities = null, bool? showCaptionAboveMedia = null, bool? disableNotification = null, bool? protectContent = null, ReplyParameters? replyParameters = null, ReplyMarkup? replyMarkup = null) =>
65+
client.SendPaidMediaAsync(chatId, starCount, media, businessConnectionId, payload, caption, parseMode, captionEntities, showCaptionAboveMedia, disableNotification, protectContent, replyParameters, replyMarkup).GetAwaiter().GetResult();
6566

6667
/// <summary>
6768
/// Use this method to send paid media. On success, the sent <see cref="Message"/> is returned.
6869
/// </summary>
6970
/// <param name="client">The <see cref="ITelegramBotClient"/> instance.</param>
7071
/// <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>
71-
/// <param name="starCount">The number of Telegram Stars that must be paid to buy access to the media</param>
72+
/// <param name="starCount">The number of Telegram Stars that must be paid to buy access to the media; 1-2500</param>
7273
/// <param name="media">A JSON-serialized array describing the media to be sent; up to 10 items</param>
7374
/// <param name="businessConnectionId">Unique identifier of the business connection on behalf of which the message will be sent</param>
75+
/// <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>
7476
/// <param name="caption">Media caption, 0-1024 characters after entities parsing</param>
7577
/// <param name="parseMode">Mode for parsing entities in the media caption. See <a href="https://core.telegram.org/bots/api#formatting-options">formatting options</a> for more details.</param>
7678
/// <param name="captionEntities">A JSON-serialized list of special entities that appear in the caption, which can be specified instead of <em>parse_mode</em></param>
@@ -83,7 +85,7 @@ public static Message SendPaidMedia(this ITelegramBotClient client, long chatId,
8385
/// <exception cref="ArgumentNullException">Thrown if <paramref name="client"/> is <c>null</c>.</exception>
8486
/// <exception cref="BotRequestException">Thrown if the request to the Telegram Bot API fails.</exception>
8587
/// <returns></returns>
86-
public static Task<Message> SendPaidMediaAsync(this ITelegramBotClient client, long chatId, int starCount, IEnumerable<InputPaidMedia> media, string? businessConnectionId = null, string? caption = null, string? parseMode = null, IEnumerable<MessageEntity>? captionEntities = null, bool? showCaptionAboveMedia = null, bool? disableNotification = null, bool? protectContent = null, ReplyParameters? replyParameters = null, ReplyMarkup? replyMarkup = null, CancellationToken cancellationToken = default)
88+
public static Task<Message> SendPaidMediaAsync(this ITelegramBotClient client, long chatId, int starCount, IEnumerable<InputPaidMedia> media, string? businessConnectionId = null, string? payload = null, string? caption = null, string? parseMode = null, IEnumerable<MessageEntity>? captionEntities = null, bool? showCaptionAboveMedia = null, bool? disableNotification = null, bool? protectContent = null, ReplyParameters? replyParameters = null, ReplyMarkup? replyMarkup = null, CancellationToken cancellationToken = default)
8789
{
8890
if (client is null)
8991
{
@@ -100,6 +102,10 @@ public static Task<Message> SendPaidMediaAsync(this ITelegramBotClient client, l
100102
{
101103
args.Add(PropertyNames.BusinessConnectionId, businessConnectionId);
102104
}
105+
if (payload is not null)
106+
{
107+
args.Add(PropertyNames.Payload, payload);
108+
}
103109
if (caption is not null)
104110
{
105111
args.Add(PropertyNames.Caption, caption);
@@ -141,9 +147,10 @@ public static Task<Message> SendPaidMediaAsync(this ITelegramBotClient client, l
141147
/// </summary>
142148
/// <param name="client">The <see cref="ITelegramBotClient"/> instance.</param>
143149
/// <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>
144-
/// <param name="starCount">The number of Telegram Stars that must be paid to buy access to the media</param>
150+
/// <param name="starCount">The number of Telegram Stars that must be paid to buy access to the media; 1-2500</param>
145151
/// <param name="media">A JSON-serialized array describing the media to be sent; up to 10 items</param>
146152
/// <param name="businessConnectionId">Unique identifier of the business connection on behalf of which the message will be sent</param>
153+
/// <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>
147154
/// <param name="caption">Media caption, 0-1024 characters after entities parsing</param>
148155
/// <param name="parseMode">Mode for parsing entities in the media caption. See <a href="https://core.telegram.org/bots/api#formatting-options">formatting options</a> for more details.</param>
149156
/// <param name="captionEntities">A JSON-serialized list of special entities that appear in the caption, which can be specified instead of <em>parse_mode</em></param>
@@ -155,17 +162,18 @@ public static Task<Message> SendPaidMediaAsync(this ITelegramBotClient client, l
155162
/// <exception cref="ArgumentNullException">Thrown if <paramref name="client"/> is <c>null</c>.</exception>
156163
/// <exception cref="BotRequestException">Thrown if the request to the Telegram Bot API fails.</exception>
157164
/// <returns></returns>
158-
public static Message SendPaidMedia(this ITelegramBotClient client, string chatId, int starCount, IEnumerable<InputPaidMedia> media, string? businessConnectionId = null, string? caption = null, string? parseMode = null, IEnumerable<MessageEntity>? captionEntities = null, bool? showCaptionAboveMedia = null, bool? disableNotification = null, bool? protectContent = null, ReplyParameters? replyParameters = null, ReplyMarkup? replyMarkup = null) =>
159-
client.SendPaidMediaAsync(chatId, starCount, media, businessConnectionId, caption, parseMode, captionEntities, showCaptionAboveMedia, disableNotification, protectContent, replyParameters, replyMarkup).GetAwaiter().GetResult();
165+
public static Message SendPaidMedia(this ITelegramBotClient client, string chatId, int starCount, IEnumerable<InputPaidMedia> media, string? businessConnectionId = null, string? payload = null, string? caption = null, string? parseMode = null, IEnumerable<MessageEntity>? captionEntities = null, bool? showCaptionAboveMedia = null, bool? disableNotification = null, bool? protectContent = null, ReplyParameters? replyParameters = null, ReplyMarkup? replyMarkup = null) =>
166+
client.SendPaidMediaAsync(chatId, starCount, media, businessConnectionId, payload, caption, parseMode, captionEntities, showCaptionAboveMedia, disableNotification, protectContent, replyParameters, replyMarkup).GetAwaiter().GetResult();
160167

161168
/// <summary>
162169
/// Use this method to send paid media. On success, the sent <see cref="Message"/> is returned.
163170
/// </summary>
164171
/// <param name="client">The <see cref="ITelegramBotClient"/> instance.</param>
165172
/// <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>
166-
/// <param name="starCount">The number of Telegram Stars that must be paid to buy access to the media</param>
173+
/// <param name="starCount">The number of Telegram Stars that must be paid to buy access to the media; 1-2500</param>
167174
/// <param name="media">A JSON-serialized array describing the media to be sent; up to 10 items</param>
168175
/// <param name="businessConnectionId">Unique identifier of the business connection on behalf of which the message will be sent</param>
176+
/// <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>
169177
/// <param name="caption">Media caption, 0-1024 characters after entities parsing</param>
170178
/// <param name="parseMode">Mode for parsing entities in the media caption. See <a href="https://core.telegram.org/bots/api#formatting-options">formatting options</a> for more details.</param>
171179
/// <param name="captionEntities">A JSON-serialized list of special entities that appear in the caption, which can be specified instead of <em>parse_mode</em></param>
@@ -178,7 +186,7 @@ public static Message SendPaidMedia(this ITelegramBotClient client, string chatI
178186
/// <exception cref="ArgumentNullException">Thrown if <paramref name="client"/> is <c>null</c>.</exception>
179187
/// <exception cref="BotRequestException">Thrown if the request to the Telegram Bot API fails.</exception>
180188
/// <returns></returns>
181-
public static Task<Message> SendPaidMediaAsync(this ITelegramBotClient client, string chatId, int starCount, IEnumerable<InputPaidMedia> media, string? businessConnectionId = null, string? caption = null, string? parseMode = null, IEnumerable<MessageEntity>? captionEntities = null, bool? showCaptionAboveMedia = null, bool? disableNotification = null, bool? protectContent = null, ReplyParameters? replyParameters = null, ReplyMarkup? replyMarkup = null, CancellationToken cancellationToken = default)
189+
public static Task<Message> SendPaidMediaAsync(this ITelegramBotClient client, string chatId, int starCount, IEnumerable<InputPaidMedia> media, string? businessConnectionId = null, string? payload = null, string? caption = null, string? parseMode = null, IEnumerable<MessageEntity>? captionEntities = null, bool? showCaptionAboveMedia = null, bool? disableNotification = null, bool? protectContent = null, ReplyParameters? replyParameters = null, ReplyMarkup? replyMarkup = null, CancellationToken cancellationToken = default)
182190
{
183191
if (client is null)
184192
{
@@ -195,6 +203,10 @@ public static Task<Message> SendPaidMediaAsync(this ITelegramBotClient client, s
195203
{
196204
args.Add(PropertyNames.BusinessConnectionId, businessConnectionId);
197205
}
206+
if (payload is not null)
207+
{
208+
args.Add(PropertyNames.Payload, payload);
209+
}
198210
if (caption is not null)
199211
{
200212
args.Add(PropertyNames.Caption, caption);

src/library/Telegram.BotAPI/AvailableTypes/ChatBoostSource/ChatBoostSourceGiveaway.cs

+8-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
namespace Telegram.BotAPI.AvailableTypes;
66

77
/// <summary>
8-
/// The boost was obtained by the creation of a Telegram Premium giveaway. This boosts the chat 4 times for the duration of the corresponding Telegram Premium subscription.
8+
/// The boost was obtained by the creation of a Telegram Premium or a Telegram Star giveaway. This boosts the chat 4 times for the duration of the corresponding Telegram Premium subscription for Telegram Premium giveaways and <em>prize_star_count</em> / 500 times for one year for Telegram Star giveaways.
99
/// </summary>
1010
public class ChatBoostSourceGiveaway : ChatBoostSource
1111
{
@@ -22,11 +22,17 @@ public class ChatBoostSourceGiveaway : ChatBoostSource
2222
public int GiveawayMessageId { get; set; }
2323

2424
/// <summary>
25-
/// Optional. User that won the prize in the giveaway if any
25+
/// Optional. User that won the prize in the giveaway if any; for Telegram Premium giveaways only
2626
/// </summary>
2727
[JsonPropertyName(PropertyNames.User)]
2828
public User? User { get; set; }
2929

30+
/// <summary>
31+
/// Optional. The number of Telegram Stars to be split between giveaway winners; for Telegram Star giveaways only
32+
/// </summary>
33+
[JsonPropertyName(PropertyNames.PrizeStarCount)]
34+
public int? PrizeStarCount { get; set; }
35+
3036
/// <summary>
3137
/// Optional. True, if the giveaway was completed, but there was no user to win the prize
3238
/// </summary>

0 commit comments

Comments
 (0)