|
| 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