Skip to content

Commit 869a63a

Browse files
committed
1 parent 93173c7 commit 869a63a

33 files changed

Lines changed: 451 additions & 86 deletions

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# .NET Client for Telegram Bot API
22

33
[![Nuget](https://img.shields.io/nuget/vpre/Telegram.Bot.svg?label=Telegram.Bot&style=flat-square&color=d8b541)](https://www.nuget.org/packages/Telegram.Bot)
4-
[![Bot API 9.5](https://img.shields.io/badge/Bot_API-9.5-f36caf.svg?style=flat-square)](https://core.telegram.org/bots/api)
4+
[![Bot API 9.6](https://img.shields.io/badge/Bot_API-9.6-f36caf.svg?style=flat-square)](https://core.telegram.org/bots/api)
55
[![Documentations](https://img.shields.io/badge/Documentations-Book-orange.svg?style=flat-square)](https://telegrambots.github.io/book/)
66
[![Telegram Chat](https://img.shields.io/badge/Support_Chat-Telegram-blue.svg?style=flat-square)](https://t.me/joinchat/B35YY0QbLfd034CFnvCtCA)
77
[![Master build](https://img.shields.io/azure-devops/build/tgbots/14f9ab3f-313a-4339-8534-e8b96c7763cc/6?style=flat-square&label=master)](https://dev.azure.com/tgbots/Telegram.Bot/_build/latest?definitionId=6&branchName=master)

src/Telegram.Bot/Extend.Types.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,17 @@ public partial class BotCommandScope
221221
public static BotCommandScopeChatMember ChatMember(ChatId chatId, long userId) => new() { ChatId = chatId, UserId = userId };
222222
}
223223

224+
public partial class Poll
225+
{
226+
/// <summary><em>Optional</em>. 0-based identifier of the correct answer option. Available only for polls in the quiz mode, which are closed, or was sent (not forwarded) by the bot or to the private chat with the bot.</summary>
227+
[Obsolete("Use CorrectOptionIds instead")]
228+
public int? CorrectOptionId
229+
{
230+
get => CorrectOptionIds switch { null or [] => null, [int value] => value, _ => throw new InvalidOperationException("Multiple CorrectOptionIds") };
231+
set => CorrectOptionIds = value.HasValue ? [value.Value] : null;
232+
}
233+
}
234+
224235

225236
namespace Payments
226237
{

src/Telegram.Bot/Requests/Gifts/SendGiftRequest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ public partial class SendGiftRequest() : RequestBase<bool>("sendGift")
2525
/// <summary>Text that will be shown along with the gift; 0-128 characters</summary>
2626
public string? Text { get; set; }
2727

28-
/// <summary>Mode for parsing entities in the text. See <a href="https://core.telegram.org/bots/api#formatting-options">formatting options</a> for more details. Entities other than <see cref="MessageEntityType.Bold">Bold</see>, <see cref="MessageEntityType.Italic">Italic</see>, <see cref="MessageEntityType.Underline">Underline</see>, <see cref="MessageEntityType.Strikethrough">Strikethrough</see>, <see cref="MessageEntityType.Spoiler">Spoiler</see>, and <see cref="MessageEntityType.CustomEmoji">CustomEmoji</see> are ignored.</summary>
28+
/// <summary>Mode for parsing entities in the text. See <a href="https://core.telegram.org/bots/api#formatting-options">formatting options</a> for more details. Entities other than <see cref="MessageEntityType.Bold">Bold</see>, <see cref="MessageEntityType.Italic">Italic</see>, <see cref="MessageEntityType.Underline">Underline</see>, <see cref="MessageEntityType.Strikethrough">Strikethrough</see>, <see cref="MessageEntityType.Spoiler">Spoiler</see>, <see cref="MessageEntityType.CustomEmoji">CustomEmoji</see>, and <see cref="MessageEntityType.DateTime">DateTime</see> are ignored.</summary>
2929
[JsonPropertyName("text_parse_mode")]
3030
public ParseMode TextParseMode { get; set; }
3131

32-
/// <summary>A list of special entities that appear in the gift text. It can be specified instead of <see cref="TextParseMode">TextParseMode</see>. Entities other than <see cref="MessageEntityType.Bold">Bold</see>, <see cref="MessageEntityType.Italic">Italic</see>, <see cref="MessageEntityType.Underline">Underline</see>, <see cref="MessageEntityType.Strikethrough">Strikethrough</see>, <see cref="MessageEntityType.Spoiler">Spoiler</see>, and <see cref="MessageEntityType.CustomEmoji">CustomEmoji</see> are ignored.</summary>
32+
/// <summary>A list of special entities that appear in the gift text. It can be specified instead of <see cref="TextParseMode">TextParseMode</see>. Entities other than <see cref="MessageEntityType.Bold">Bold</see>, <see cref="MessageEntityType.Italic">Italic</see>, <see cref="MessageEntityType.Underline">Underline</see>, <see cref="MessageEntityType.Strikethrough">Strikethrough</see>, <see cref="MessageEntityType.Spoiler">Spoiler</see>, <see cref="MessageEntityType.CustomEmoji">CustomEmoji</see>, and <see cref="MessageEntityType.DateTime">DateTime</see> are ignored.</summary>
3333
[JsonPropertyName("text_entities")]
3434
public IEnumerable<MessageEntity>? TextEntities { get; set; }
3535
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// GENERATED FILE - DO NOT MODIFY MANUALLY
2+
namespace Telegram.Bot.Requests;
3+
4+
/// <summary>Use this method to get the token of a managed bot.<para>Returns: The token as <em>String</em> on success.</para></summary>
5+
[EditorBrowsable(EditorBrowsableState.Never)]
6+
public partial class GetManagedBotTokenRequest() : RequestBase<string>("getManagedBotToken"), IUserTargetable
7+
{
8+
/// <summary>User identifier of the managed bot whose token will be returned</summary>
9+
[JsonPropertyName("user_id")]
10+
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
11+
public required long UserId { get; set; }
12+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// GENERATED FILE - DO NOT MODIFY MANUALLY
2+
namespace Telegram.Bot.Requests;
3+
4+
/// <summary>Use this method to revoke the current token of a managed bot and generate a new one.<para>Returns: The new token as <em>String</em> on success.</para></summary>
5+
[EditorBrowsable(EditorBrowsableState.Never)]
6+
public partial class ReplaceManagedBotTokenRequest() : RequestBase<string>("replaceManagedBotToken"), IUserTargetable
7+
{
8+
/// <summary>User identifier of the managed bot whose token will be replaced</summary>
9+
[JsonPropertyName("user_id")]
10+
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
11+
public required long UserId { get; set; }
12+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// GENERATED FILE - DO NOT MODIFY MANUALLY
2+
namespace Telegram.Bot.Requests;
3+
4+
/// <summary>Stores a keyboard button that can be used by a user within a Mini App.<para>Returns: A <see cref="PreparedKeyboardButton"/> object.</para></summary>
5+
[EditorBrowsable(EditorBrowsableState.Never)]
6+
public partial class SavePreparedKeyboardButtonRequest() : RequestBase<PreparedKeyboardButton>("savePreparedKeyboardButton"), IUserTargetable
7+
{
8+
/// <summary>Unique identifier of the target user that can use the button</summary>
9+
[JsonPropertyName("user_id")]
10+
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
11+
public required long UserId { get; set; }
12+
13+
/// <summary>An object describing the button to be saved. The button must be of the type <em>RequestUsers</em>, <em>RequestChat</em>, or <em>RequestManagedBot</em></summary>
14+
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
15+
public required KeyboardButton Button { get; set; }
16+
}

src/Telegram.Bot/Requests/Payments/GiftPremiumSubscriptionRequest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ public partial class GiftPremiumSubscriptionRequest() : RequestBase<bool>("giftP
2323
/// <summary>Text that will be shown along with the service message about the subscription; 0-128 characters</summary>
2424
public string? Text { get; set; }
2525

26-
/// <summary>Mode for parsing entities in the text. See <a href="https://core.telegram.org/bots/api#formatting-options">formatting options</a> for more details. Entities other than <see cref="MessageEntityType.Bold">Bold</see>, <see cref="MessageEntityType.Italic">Italic</see>, <see cref="MessageEntityType.Underline">Underline</see>, <see cref="MessageEntityType.Strikethrough">Strikethrough</see>, <see cref="MessageEntityType.Spoiler">Spoiler</see>, and <see cref="MessageEntityType.CustomEmoji">CustomEmoji</see> are ignored.</summary>
26+
/// <summary>Mode for parsing entities in the text. See <a href="https://core.telegram.org/bots/api#formatting-options">formatting options</a> for more details. Entities other than <see cref="MessageEntityType.Bold">Bold</see>, <see cref="MessageEntityType.Italic">Italic</see>, <see cref="MessageEntityType.Underline">Underline</see>, <see cref="MessageEntityType.Strikethrough">Strikethrough</see>, <see cref="MessageEntityType.Spoiler">Spoiler</see>, <see cref="MessageEntityType.CustomEmoji">CustomEmoji</see>, and <see cref="MessageEntityType.DateTime">DateTime</see> are ignored.</summary>
2727
[JsonPropertyName("text_parse_mode")]
2828
public ParseMode TextParseMode { get; set; }
2929

30-
/// <summary>A list of special entities that appear in the gift text. It can be specified instead of <see cref="TextParseMode">TextParseMode</see>. Entities other than “bold”, “italic”, “underline”, “strikethrough”, “spoiler”, and “CustomEmoji” are ignored.</summary>
30+
/// <summary>A list of special entities that appear in the gift text. It can be specified instead of <see cref="TextParseMode">TextParseMode</see>. Entities other than “bold”, “italic”, “underline”, “strikethrough”, “spoiler”, “CustomEmoji”, and “DateTime” are ignored.</summary>
3131
[JsonPropertyName("text_entities")]
3232
public IEnumerable<MessageEntity>? TextEntities { get; set; }
3333
}

src/Telegram.Bot/Requests/Sending Messages/SendPollRequest.cs

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,29 @@ public partial class SendPollRequest() : RequestBase<Message>("sendPoll"), IChat
4141
/// <summary>Poll type, <see cref="PollType.Quiz">Quiz</see> or <see cref="PollType.Regular">Regular</see>, defaults to <see cref="PollType.Regular">Regular</see></summary>
4242
public PollType? Type { get; set; }
4343

44-
/// <summary><see langword="true"/>, if the poll allows multiple answers, ignored for polls in quiz mode, defaults to <see langword="false"/></summary>
44+
/// <summary>Pass <see langword="true"/>, if the poll allows multiple answers, defaults to <see langword="false"/></summary>
4545
[JsonPropertyName("allows_multiple_answers")]
4646
public bool AllowsMultipleAnswers { get; set; }
4747

48-
/// <summary>0-based identifier of the correct answer option, required for polls in quiz mode</summary>
49-
[JsonPropertyName("correct_option_id")]
50-
public int? CorrectOptionId { get; set; }
48+
/// <summary>Pass <see langword="true"/>, if the poll allows to change chosen answer options, defaults to <see langword="false"/> for quizzes and to <see langword="true"/> for regular polls</summary>
49+
[JsonPropertyName("allows_revoting")]
50+
public bool AllowsRevoting { get; set; }
51+
52+
/// <summary>Pass <see langword="true"/>, if the poll options must be shown in random order</summary>
53+
[JsonPropertyName("shuffle_options")]
54+
public bool ShuffleOptions { get; set; }
55+
56+
/// <summary>Pass <see langword="true"/>, if answer options can be added to the poll after creation; not supported for anonymous polls and quizzes</summary>
57+
[JsonPropertyName("allow_adding_options")]
58+
public bool AllowAddingOptions { get; set; }
59+
60+
/// <summary>Pass <see langword="true"/>, if poll results must be shown only after the poll closes</summary>
61+
[JsonPropertyName("hide_results_until_closes")]
62+
public bool HideResultsUntilCloses { get; set; }
63+
64+
/// <summary>A list of monotonically increasing 0-based identifiers of the correct answer options, required for polls in quiz mode</summary>
65+
[JsonPropertyName("correct_option_ids")]
66+
public IEnumerable<int>? CorrectOptionIds { get; set; }
5167

5268
/// <summary>Text that is shown when a user chooses an incorrect answer or taps on the lamp icon in a quiz-style poll, 0-200 characters with at most 2 line feeds after entities parsing</summary>
5369
public string? Explanation { get; set; }
@@ -60,11 +76,11 @@ public partial class SendPollRequest() : RequestBase<Message>("sendPoll"), IChat
6076
[JsonPropertyName("explanation_entities")]
6177
public IEnumerable<MessageEntity>? ExplanationEntities { get; set; }
6278

63-
/// <summary>Amount of time in seconds the poll will be active after creation, 5-600. Can't be used together with <see cref="CloseDate">CloseDate</see>.</summary>
79+
/// <summary>Amount of time in seconds the poll will be active after creation, 5-2628000. Can't be used together with <see cref="CloseDate">CloseDate</see>.</summary>
6480
[JsonPropertyName("open_period")]
6581
public int? OpenPeriod { get; set; }
6682

67-
/// <summary>Point in time when the poll will be automatically closed. Must be at least 5 and no more than 600 seconds in the future. Can't be used together with <see cref="OpenPeriod">OpenPeriod</see>.</summary>
83+
/// <summary>Point in time when the poll will be automatically closed. Must be at least 5 and no more than 2628000 seconds in the future. Can't be used together with <see cref="OpenPeriod">OpenPeriod</see>.</summary>
6884
[JsonPropertyName("close_date")]
6985
[JsonConverter(typeof(UnixDateTimeConverter))]
7086
public DateTime? CloseDate { get; set; }
@@ -73,6 +89,17 @@ public partial class SendPollRequest() : RequestBase<Message>("sendPoll"), IChat
7389
[JsonPropertyName("is_closed")]
7490
public bool IsClosed { get; set; }
7591

92+
/// <summary>Description of the poll to be sent, 0-1024 characters after entities parsing</summary>
93+
public string? Description { get; set; }
94+
95+
/// <summary>Mode for parsing entities in the poll description. See <a href="https://core.telegram.org/bots/api#formatting-options">formatting options</a> for more details.</summary>
96+
[JsonPropertyName("description_parse_mode")]
97+
public ParseMode DescriptionParseMode { get; set; }
98+
99+
/// <summary>A list of special entities that appear in the poll description, which can be specified instead of <see cref="DescriptionParseMode">DescriptionParseMode</see></summary>
100+
[JsonPropertyName("description_entities")]
101+
public IEnumerable<MessageEntity>? DescriptionEntities { get; set; }
102+
76103
/// <summary>Sends the message <a href="https://telegram.org/blog/channels-2-0#silent-messages">silently</a>. Users will receive a notification with no sound.</summary>
77104
[JsonPropertyName("disable_notification")]
78105
public bool DisableNotification { get; set; }

src/Telegram.Bot/Serialization/JsonBotSerializerContext.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ namespace Telegram.Bot;
8686
[JsonSerializable(typeof(AnswerCallbackQueryRequest))]
8787
[JsonSerializable(typeof(GetUserChatBoostsRequest))]
8888
[JsonSerializable(typeof(GetBusinessConnectionRequest))]
89+
[JsonSerializable(typeof(GetManagedBotTokenRequest))]
90+
[JsonSerializable(typeof(ReplaceManagedBotTokenRequest))]
8991
[JsonSerializable(typeof(SetMyCommandsRequest))]
9092
[JsonSerializable(typeof(DeleteMyCommandsRequest))]
9193
[JsonSerializable(typeof(GetMyCommandsRequest))]
@@ -128,6 +130,9 @@ namespace Telegram.Bot;
128130
[JsonSerializable(typeof(RepostStoryRequest))]
129131
[JsonSerializable(typeof(EditStoryRequest))]
130132
[JsonSerializable(typeof(DeleteStoryRequest))]
133+
[JsonSerializable(typeof(AnswerWebAppQueryRequest))]
134+
[JsonSerializable(typeof(SavePreparedInlineMessageRequest))]
135+
[JsonSerializable(typeof(SavePreparedKeyboardButtonRequest))]
131136
[JsonSerializable(typeof(EditMessageTextRequest))]
132137
[JsonSerializable(typeof(EditInlineMessageTextRequest))]
133138
[JsonSerializable(typeof(EditMessageCaptionRequest))]
@@ -163,8 +168,6 @@ namespace Telegram.Bot;
163168
[JsonSerializable(typeof(SetCustomEmojiStickerSetThumbnailRequest))]
164169
[JsonSerializable(typeof(DeleteStickerSetRequest))]
165170
[JsonSerializable(typeof(AnswerInlineQueryRequest))]
166-
[JsonSerializable(typeof(AnswerWebAppQueryRequest))]
167-
[JsonSerializable(typeof(SavePreparedInlineMessageRequest))]
168171
[JsonSerializable(typeof(SendInvoiceRequest))]
169172
[JsonSerializable(typeof(CreateInvoiceLinkRequest))]
170173
[JsonSerializable(typeof(AnswerShippingQueryRequest))]
@@ -211,10 +214,11 @@ namespace Telegram.Bot;
211214
[JsonSerializable(typeof(ApiResponse<StarAmount>))]
212215
[JsonSerializable(typeof(ApiResponse<OwnedGifts>))]
213216
[JsonSerializable(typeof(ApiResponse<Story>))]
214-
[JsonSerializable(typeof(ApiResponse<Poll>))]
215-
[JsonSerializable(typeof(ApiResponse<StickerSet>))]
216217
[JsonSerializable(typeof(ApiResponse<SentWebAppMessage>))]
217218
[JsonSerializable(typeof(ApiResponse<PreparedInlineMessage>))]
219+
[JsonSerializable(typeof(ApiResponse<PreparedKeyboardButton>))]
220+
[JsonSerializable(typeof(ApiResponse<Poll>))]
221+
[JsonSerializable(typeof(ApiResponse<StickerSet>))]
218222
[JsonSerializable(typeof(ApiResponse<StarTransactions>))]
219223
[JsonSerializable(typeof(ApiResponse<GameHighScore[]>))]
220224
[JsonSerializable(typeof(MessageOriginUser))]

0 commit comments

Comments
 (0)