From 9f4fc18ed21d2d077cdb84e198d3fe263ede8ad8 Mon Sep 17 00:00:00 2001 From: KnorpelSenf Date: Fri, 16 Aug 2024 11:15:47 +0200 Subject: [PATCH 1/3] feat: support Bot API 7.9 --- manage.ts | 2 ++ message.ts | 20 ++++++++++++++++---- methods.ts | 36 ++++++++++++++++++++++++++++++------ payment.ts | 3 +++ 4 files changed, 51 insertions(+), 10 deletions(-) diff --git a/manage.ts b/manage.ts index 8cf0c10..4b9e4b9 100644 --- a/manage.ts +++ b/manage.ts @@ -690,6 +690,8 @@ export interface ChatMemberMember { status: "member"; /** Information about the user */ user: User; + /** Date when the user's subscription will expire; Unix time */ + until_date?: number; } /** Represents a chat member that is under certain restrictions in the chat. Supergroups only. */ diff --git a/message.ts b/message.ts index 3f1c1ea..39b666c 100644 --- a/message.ts +++ b/message.ts @@ -12,9 +12,9 @@ export declare namespace Message { message_id: number; /** Unique identifier of a message thread or a forum topic to which the message belongs; for supergroups only */ message_thread_id?: number; - /** Sender of the message; empty for messages sent to channels. For backward compatibility, the field contains a fake sender user in non-channel chats, if the message was sent on behalf of a chat. */ + /** Sender of the message; may be empty for messages sent to channels. For backward compatibility, if the message was sent on behalf of a chat, the field contains a fake sender user in non-channel chats */ from?: User; - /** Sender of the message, sent on behalf of a chat. For example, the channel itself for channel posts, the supergroup itself for messages from anonymous group administrators, the linked channel for messages automatically forwarded to the discussion group. For backward compatibility, the field from contains a fake sender user in non-channel chats, if the message was sent on behalf of a chat. */ + /** Sender of the message when sent on behalf of a chat. For example, the supergroup itself for messages sent by its anonymous administrators or a linked channel for messages automatically forwarded to the channel's discussion group. For backward compatibility, if the message was sent on behalf of a chat, the field from contains a fake sender user in non-channel chats. */ sender_chat?: Chat; /** Date the message was sent in Unix time. It is always a positive number, representing a valid date. */ date: number; @@ -191,6 +191,7 @@ export declare namespace Message { type ReplyMessage = Message & { reply_to_message: undefined }; +/** This object represents a message. */ export interface Message extends Message.MediaMessage { /** For text messages, the actual UTF-8 text of the message */ text?: string; @@ -1357,8 +1358,13 @@ export interface File { /** This object describes the type of a reaction. Currently, it can be one of - ReactionTypeEmoji -- ReactionTypeCustomEmoji */ -export type ReactionType = ReactionTypeEmoji | ReactionTypeCustomEmoji; +- ReactionTypeCustomEmoji +- ReactionTypePaid */ +export type ReactionType = + | ReactionTypeEmoji + | ReactionTypeCustomEmoji + | ReactionTypePaid + | ReactionTypePaid; /** The reaction is based on an emoji. */ export interface ReactionTypeEmoji { @@ -1449,6 +1455,12 @@ export interface ReactionTypeCustomEmoji { custom_emoji_id: string; } +/** The reaction is paid. */ +export interface ReactionTypePaid { + /** Type of the reaction, always “paid” */ + type: "paid"; +} + /** Represents a reaction added to a message along with the number of times it was added. */ export interface ReactionCount { /** Type of the reaction */ diff --git a/methods.ts b/methods.ts index ec980a6..98f513b 100644 --- a/methods.ts +++ b/methods.ts @@ -644,9 +644,11 @@ export type ApiMethods = { reply_markup?: InlineKeyboardMarkup; }): (Update.Edited & Message.LocationMessage) | true; - /** Use this method to send paid media to channel chats. On success, the sent Message is returned. */ + /** Use this method to send paid media. On success, the sent Message is returned. */ sendPaidMedia(args: { - /** Unique identifier for the target chat or username of the target channel (in the format @channelusername) */ + /** Unique identifier of the business connection on behalf of which the message to be edited was sent */ + business_connection_id?: string; + /** Unique identifier for the target chat or username of the target channel (in the format @channelusername). 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. */ chat_id: number | string; /** The number of Telegram Stars that must be paid to buy access to the media */ star_count: number; @@ -859,13 +861,13 @@ export type ApiMethods = { message_thread_id?: number; }): true; - /** Use this method to change the chosen reactions on a message. Service messages can't be reacted to. Automatically forwarded messages from a channel to its discussion group have the same available reactions as messages in the channel. In albums, bots must react to the first message. Returns True on success. */ + /** Use this method to change the chosen reactions on a message. Service messages can't be reacted to. Automatically forwarded messages from a channel to its discussion group have the same available reactions as messages in the channel. Bots can't use paid reactions. Returns True on success. */ setMessageReaction(args: { /** Unique identifier for the target chat or username of the target channel (in the format @channelusername) */ chat_id: number | string; /** Identifier of the target message */ message_id: number; - /** A 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. */ + /** A 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. */ reaction?: ReactionType[]; /** Pass True to set the reaction with a big animation */ is_big?: boolean; @@ -1041,6 +1043,28 @@ export type ApiMethods = { creates_join_request?: boolean; }): ChatInviteLink; + /** Use this method to create a subscription invite link for a channel chat. The bot must have the can_invite_users administrator rights. The link can be edited using the method editChatSubscriptionInviteLink or revoked using the method revokeChatInviteLink. Returns the new invite link as a ChatInviteLink object. */ + createChatSubscriptionInviteLink(args: { + /** Unique identifier for the target channel chat or username of the target channel (in the format @channelusername) */ + chat_id: number | string; + /** Invite link name; 0-32 characters */ + name?: string; + /** The number of seconds the subscription will be active for before the next payment. Currently, it must always be 2592000 (30 days). */ + subscription_period: number; + /** 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 */ + subscription_price: number; + }): ChatInviteLink; + + /** Use this method to edit a subscription invite link created by the bot. The bot must have the can_invite_users administrator rights. Returns the edited invite link as a ChatInviteLink object.*/ + editChatSubscriptionInviteLink(args: { + /** Unique identifier for the target chat or username of the target channel (in the format @channelusername) */ + chat_id: number | string; + /** The invite link to edit */ + invite_link: string; + /** Invite link name; 0-32 characters */ + name?: string; + }): ChatInviteLink; + /** Use this method to revoke an invite link created by the bot. If the primary link is revoked, a new link is automatically generated. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the revoked invite link as ChatInviteLink object. */ revokeChatInviteLink(args: { /** Unique identifier of the target chat or username of the target channel (in the format @channelusername) */ @@ -1193,7 +1217,7 @@ export type ApiMethods = { icon_custom_emoji_id?: string; }): ForumTopic; - /** Use this method to edit name and icon of a topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have can_manage_topics administrator rights, unless it is the creator of the topic. Returns True on success. */ + /** Use this method to edit name and icon of a topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights, unless it is the creator of the topic. Returns True on success. */ editForumTopic(args: { /** Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) */ chat_id: number | string; @@ -1237,7 +1261,7 @@ export type ApiMethods = { message_thread_id: number; }): true; - /** Use this method to edit the name of the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have can_manage_topics administrator rights. Returns True on success. */ + /** Use this method to edit the name of the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. Returns True on success. */ editGeneralForumTopic(args: { /** Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) */ chat_id: number | string; diff --git a/payment.ts b/payment.ts index a875474..499140e 100644 --- a/payment.ts +++ b/payment.ts @@ -1,4 +1,5 @@ import type { User } from "./manage.ts"; +import type { PaidMedia } from "./message.ts"; /** This object represents a portion of the price for goods or services. */ export interface LabeledPrice { @@ -174,6 +175,8 @@ export interface TransactionPartnerUser { user: User; /** Bot-specified invoice payload */ invoice_payload?: string; + /** Information about the paid media bought by the user */ + paid_media?: PaidMedia[]; } /** Describes a withdrawal transaction with Fragment. */ From 1fdcb8b52c887303cfbf5ee454cd69b18f88f8b7 Mon Sep 17 00:00:00 2001 From: KnorpelSenf Date: Fri, 16 Aug 2024 11:37:40 +0200 Subject: [PATCH 2/3] fix: remove duplicate union member ReactionTypePaid --- message.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/message.ts b/message.ts index 39b666c..6207bce 100644 --- a/message.ts +++ b/message.ts @@ -1363,7 +1363,6 @@ export interface File { export type ReactionType = | ReactionTypeEmoji | ReactionTypeCustomEmoji - | ReactionTypePaid | ReactionTypePaid; /** The reaction is based on an emoji. */ From bd2675b8369eeff750d2e8c6329c321dbe6f0197 Mon Sep 17 00:00:00 2001 From: KnorpelSenf Date: Fri, 16 Aug 2024 13:08:48 +0200 Subject: [PATCH 3/3] style: add missing space character in docs comment --- methods.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/methods.ts b/methods.ts index 98f513b..2d35397 100644 --- a/methods.ts +++ b/methods.ts @@ -1055,7 +1055,7 @@ export type ApiMethods = { subscription_price: number; }): ChatInviteLink; - /** Use this method to edit a subscription invite link created by the bot. The bot must have the can_invite_users administrator rights. Returns the edited invite link as a ChatInviteLink object.*/ + /** Use this method to edit a subscription invite link created by the bot. The bot must have the can_invite_users administrator rights. Returns the edited invite link as a ChatInviteLink object. */ editChatSubscriptionInviteLink(args: { /** Unique identifier for the target chat or username of the target channel (in the format @channelusername) */ chat_id: number | string;