Skip to content

Commit 533e0a3

Browse files
committed
feat: Update to Bot API 7.9
1 parent 3210af6 commit 533e0a3

19 files changed

+312
-52
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.8](https://img.shields.io/badge/Bot%20API%20version-v7.8-blue?style=flat-square)](https://core.telegram.org/bots/api#july-31-2024)
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)
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.8 released on July 31, 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.9 released on August 14, 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.8 methods.
16-
- Contains classes for each object type used in the Bot API 7.8.
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.
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.8](https://img.shields.io/badge/Bot%20API%20version-v7.8-blue?style=flat-square)](https://core.telegram.org/bots/api#july-31-2024)
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)
55

66
## Sample list
77

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

+9-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class SendPaidMediaArgs : AttachedFilesArgsBase
1414
/// <summary>
1515
/// Initializes a new instance of the <see cref="SendPaidMediaArgs"/> class.
1616
/// </summary>
17-
/// <param name="chatId">Unique identifier for the target chat or username of the target channel (in the format <em>@channelusername</em>)</param>
17+
/// <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>
1818
/// <param name="starCount">The number of Telegram Stars that must be paid to buy access to the media</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)
@@ -27,7 +27,7 @@ public SendPaidMediaArgs(long chatId, int starCount, IEnumerable<InputPaidMedia>
2727
/// <summary>
2828
/// Initializes a new instance of the <see cref="SendPaidMediaArgs"/> class.
2929
/// </summary>
30-
/// <param name="chatId">Unique identifier for the target chat or username of the target channel (in the format <em>@channelusername</em>)</param>
30+
/// <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>
3131
/// <param name="starCount">The number of Telegram Stars that must be paid to buy access to the media</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)
@@ -38,7 +38,13 @@ public SendPaidMediaArgs(string chatId, int starCount, IEnumerable<InputPaidMedi
3838
}
3939

4040
/// <summary>
41-
/// Unique identifier for the target chat or username of the target channel (in the format <em>@channelusername</em>)
41+
/// Unique identifier of the business connection on behalf of which the message will be sent
42+
/// </summary>
43+
[JsonPropertyName(PropertyNames.BusinessConnectionId)]
44+
public string? BusinessConnectionId { get; set; }
45+
46+
/// <summary>
47+
/// 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.
4248
/// </summary>
4349
[JsonPropertyName(PropertyNames.ChatId)]
4450
public object ChatId { get; set; }

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public SetMessageReactionArgs(string chatId, int messageId)
4646
public int MessageId { get; set; }
4747

4848
/// <summary>
49-
/// A JSON-serialized list of reaction types to set on the message. Currently, as non-premium users, bots can set up to one reaction per message. A custom emoji reaction can be used if it is either already present on the message or explicitly allowed by chat administrators.
49+
/// A JSON-serialized list of reaction types to set on the message. Currently, as non-premium users, bots can set up to one reaction per message. A custom emoji reaction can be used if it is either already present on the message or explicitly allowed by chat administrators. Paid reactions can't be used by bots.
5050
/// </summary>
5151
[JsonPropertyName(PropertyNames.Reaction)]
5252
public IEnumerable<ReactionType>? Reaction { get; set; }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
// Copyright (c) 2024 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+
using Telegram.BotAPI.AvailableTypes;
6+
7+
namespace Telegram.BotAPI.AvailableMethods;
8+
9+
/// <summary>
10+
/// Extension methods for the Telegram Bot API.
11+
/// </summary>
12+
public static partial class AvailableMethodsExtensions
13+
{
14+
/// <summary>
15+
/// Use this method to create a <a href="https://telegram.org/blog/superchannels-star-reactions-subscriptions#star-subscriptions">subscription invite link</a> for a channel chat. The bot must have the <em>can_invite_users</em> administrator rights. The link can be edited using the method <a href="https://core.telegram.org/bots/api#editchatsubscriptioninvitelink">editChatSubscriptionInviteLink</a> or revoked using the method <a href="https://core.telegram.org/bots/api#revokechatinvitelink">revokeChatInviteLink</a>. Returns the new invite link as a <see cref="ChatInviteLink"/> object.
16+
/// </summary>
17+
/// <param name="client">The <see cref="ITelegramBotClient"/> instance.</param>
18+
/// <param name="chatId">Unique identifier for the target channel chat or username of the target channel (in the format <em>@channelusername</em>)</param>
19+
/// <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>
21+
/// <param name="name">Invite link name; 0-32 characters</param>
22+
/// <exception cref="ArgumentNullException">Thrown if <paramref name="client"/> is <c>null</c>.</exception>
23+
/// <exception cref="BotRequestException">Thrown if the request to the Telegram Bot API fails.</exception>
24+
/// <returns></returns>
25+
public static ChatInviteLink CreateChatSubscriptionInviteLink(this ITelegramBotClient client, long chatId, int subscriptionPeriod, int subscriptionPrice, string? name = null) =>
26+
client.CreateChatSubscriptionInviteLinkAsync(chatId, subscriptionPeriod, subscriptionPrice, name).GetAwaiter().GetResult();
27+
28+
/// <summary>
29+
/// Use this method to create a <a href="https://telegram.org/blog/superchannels-star-reactions-subscriptions#star-subscriptions">subscription invite link</a> for a channel chat. The bot must have the <em>can_invite_users</em> administrator rights. The link can be edited using the method <a href="https://core.telegram.org/bots/api#editchatsubscriptioninvitelink">editChatSubscriptionInviteLink</a> or revoked using the method <a href="https://core.telegram.org/bots/api#revokechatinvitelink">revokeChatInviteLink</a>. Returns the new invite link as a <see cref="ChatInviteLink"/> object.
30+
/// </summary>
31+
/// <param name="client">The <see cref="ITelegramBotClient"/> instance.</param>
32+
/// <param name="chatId">Unique identifier for the target channel chat or username of the target channel (in the format <em>@channelusername</em>)</param>
33+
/// <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>
35+
/// <param name="name">Invite link name; 0-32 characters</param>
36+
/// <param name="cancellationToken">The cancellation token to cancel operation.</param>
37+
/// <exception cref="ArgumentNullException">Thrown if <paramref name="client"/> is <c>null</c>.</exception>
38+
/// <exception cref="BotRequestException">Thrown if the request to the Telegram Bot API fails.</exception>
39+
/// <returns></returns>
40+
public static Task<ChatInviteLink> CreateChatSubscriptionInviteLinkAsync(this ITelegramBotClient client, long chatId, int subscriptionPeriod, int subscriptionPrice, string? name = null, CancellationToken cancellationToken = default)
41+
{
42+
if (client is null)
43+
{
44+
throw new ArgumentNullException(nameof(client));
45+
}
46+
47+
var args = new Dictionary<string, object>()
48+
{
49+
{ PropertyNames.ChatId, chatId },
50+
{ PropertyNames.SubscriptionPeriod, subscriptionPeriod },
51+
{ PropertyNames.SubscriptionPrice, subscriptionPrice }
52+
};
53+
if (name is not null)
54+
{
55+
args.Add(PropertyNames.Name, name);
56+
}
57+
58+
return client.CallMethodAsync<ChatInviteLink>(MethodNames.CreateChatSubscriptionInviteLink, args, cancellationToken);
59+
}
60+
61+
/// <summary>
62+
/// Use this method to create a <a href="https://telegram.org/blog/superchannels-star-reactions-subscriptions#star-subscriptions">subscription invite link</a> for a channel chat. The bot must have the <em>can_invite_users</em> administrator rights. The link can be edited using the method <a href="https://core.telegram.org/bots/api#editchatsubscriptioninvitelink">editChatSubscriptionInviteLink</a> or revoked using the method <a href="https://core.telegram.org/bots/api#revokechatinvitelink">revokeChatInviteLink</a>. Returns the new invite link as a <see cref="ChatInviteLink"/> object.
63+
/// </summary>
64+
/// <param name="client">The <see cref="ITelegramBotClient"/> instance.</param>
65+
/// <param name="chatId">Unique identifier for the target channel chat or username of the target channel (in the format <em>@channelusername</em>)</param>
66+
/// <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>
68+
/// <param name="name">Invite link name; 0-32 characters</param>
69+
/// <exception cref="ArgumentNullException">Thrown if <paramref name="client"/> is <c>null</c>.</exception>
70+
/// <exception cref="BotRequestException">Thrown if the request to the Telegram Bot API fails.</exception>
71+
/// <returns></returns>
72+
public static ChatInviteLink CreateChatSubscriptionInviteLink(this ITelegramBotClient client, string chatId, int subscriptionPeriod, int subscriptionPrice, string? name = null) =>
73+
client.CreateChatSubscriptionInviteLinkAsync(chatId, subscriptionPeriod, subscriptionPrice, name).GetAwaiter().GetResult();
74+
75+
/// <summary>
76+
/// Use this method to create a <a href="https://telegram.org/blog/superchannels-star-reactions-subscriptions#star-subscriptions">subscription invite link</a> for a channel chat. The bot must have the <em>can_invite_users</em> administrator rights. The link can be edited using the method <a href="https://core.telegram.org/bots/api#editchatsubscriptioninvitelink">editChatSubscriptionInviteLink</a> or revoked using the method <a href="https://core.telegram.org/bots/api#revokechatinvitelink">revokeChatInviteLink</a>. Returns the new invite link as a <see cref="ChatInviteLink"/> object.
77+
/// </summary>
78+
/// <param name="client">The <see cref="ITelegramBotClient"/> instance.</param>
79+
/// <param name="chatId">Unique identifier for the target channel chat or username of the target channel (in the format <em>@channelusername</em>)</param>
80+
/// <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>
82+
/// <param name="name">Invite link name; 0-32 characters</param>
83+
/// <param name="cancellationToken">The cancellation token to cancel operation.</param>
84+
/// <exception cref="ArgumentNullException">Thrown if <paramref name="client"/> is <c>null</c>.</exception>
85+
/// <exception cref="BotRequestException">Thrown if the request to the Telegram Bot API fails.</exception>
86+
/// <returns></returns>
87+
public static Task<ChatInviteLink> CreateChatSubscriptionInviteLinkAsync(this ITelegramBotClient client, string chatId, int subscriptionPeriod, int subscriptionPrice, string? name = null, CancellationToken cancellationToken = default)
88+
{
89+
if (client is null)
90+
{
91+
throw new ArgumentNullException(nameof(client));
92+
}
93+
94+
var args = new Dictionary<string, object>()
95+
{
96+
{ PropertyNames.ChatId, chatId ?? throw new ArgumentNullException(nameof(chatId)) },
97+
{ PropertyNames.SubscriptionPeriod, subscriptionPeriod },
98+
{ PropertyNames.SubscriptionPrice, subscriptionPrice }
99+
};
100+
if (name is not null)
101+
{
102+
args.Add(PropertyNames.Name, name);
103+
}
104+
105+
return client.CallMethodAsync<ChatInviteLink>(MethodNames.CreateChatSubscriptionInviteLink, args, cancellationToken);
106+
}
107+
}

0 commit comments

Comments
 (0)