Skip to content

Commit

Permalink
feat: support Bot API 7.9 (#53)
Browse files Browse the repository at this point in the history
* feat: support Bot API 7.9

* fix: remove duplicate union member ReactionTypePaid

* style: add missing space character in docs comment
  • Loading branch information
KnorpelSenf authored Aug 16, 2024
1 parent 7811e8a commit caa1972
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 10 deletions.
2 changes: 2 additions & 0 deletions manage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down
19 changes: 15 additions & 4 deletions message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -1357,8 +1358,12 @@ 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;

/** The reaction is based on an emoji. */
export interface ReactionTypeEmoji {
Expand Down Expand Up @@ -1449,6 +1454,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 */
Expand Down
36 changes: 30 additions & 6 deletions methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -644,9 +644,11 @@ export type ApiMethods<F> = {
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;
Expand Down Expand Up @@ -859,13 +861,13 @@ export type ApiMethods<F> = {
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;
Expand Down Expand Up @@ -1041,6 +1043,28 @@ export type ApiMethods<F> = {
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) */
Expand Down Expand Up @@ -1193,7 +1217,7 @@ export type ApiMethods<F> = {
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;
Expand Down Expand Up @@ -1237,7 +1261,7 @@ export type ApiMethods<F> = {
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;
Expand Down
3 changes: 3 additions & 0 deletions payment.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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. */
Expand Down

0 comments on commit caa1972

Please sign in to comment.