@grammyjs/types
Version:
Telegram Bot API type declarations for grammY
820 lines (818 loc) • 85.8 kB
TypeScript
import type { Checklist, ChecklistTasksAdded, ChecklistTasksDone } from "./checklist.js";
import type { Chat, ChatOwnerChanged, ChatOwnerLeft, ManagedBotCreated, User } from "./manage.js";
import type { InlineKeyboardMarkup } from "./markup.js";
import type { PassportData } from "./passport.js";
import type { GiftInfo, Invoice, PaidMessagePriceChanged, RefundedPayment, SuccessfulPayment, SuggestedPostApprovalFailed, SuggestedPostApproved, SuggestedPostDeclined, SuggestedPostInfo, SuggestedPostPaid, SuggestedPostPrice, SuggestedPostRefunded, UniqueGiftInfo } from "./payment.js";
import type { RichBlock } from "./rich.js";
type MsgWith<P extends keyof Message> = Record<P, NonNullable<Message[P]>>;
export declare namespace Message {
interface ServiceMessage {
/** Unique message identifier inside this chat. In specific instances (e.g., message containing a video sent to a big chat), the server might automatically schedule a message instead of sending it immediately. In such cases, this field will be 0 and the relevant message will be unusable until it is actually sent. */
message_id: number;
/** Unique identifier of a message thread or forum topic to which the message belongs; for supergroups and private chats only */
message_thread_id?: number;
/** 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 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;
/** The unique identifier for the guest query. Use this identifier with the method answerGuestQuery to send a response message. If non-empty, the message belongs to the chat where the guest bot was summoned, which may not coincide with other existing bot chats sharing the same identifier. */
guest_query_id?: string;
/** Unique identifier of the business connection from which the message was received. If non-empty, the message belongs to a chat of the corresponding business account that is independent from any potential bot chat which might share the same identifier. */
business_connection_id?: string;
/** Chat the message belongs to */
chat: Chat;
/** True, if the message is sent to a topic in a forum supergroup or a private chat with the bot */
is_topic_message?: boolean;
/** Information about the direct messages chat topic that contains the message */
direct_messages_topic?: DirectMessagesTopic;
}
interface CommonMessage extends ServiceMessage {
/** Tag or custom title of the sender of the message; for supergroups only */
sender_tag?: string;
/** If the sender of the message boosted the chat, the number of boosts added by the user */
sender_boost_count?: number;
/** The bot that actually sent the message on behalf of the business account. Available only for outgoing messages sent on behalf of the connected business account. */
sender_business_bot?: User;
/** Information about the original message for forwarded messages */
forward_origin?: MessageOrigin;
/** True, if the message is a channel post that was automatically forwarded to the connected discussion group */
is_automatic_forward?: true;
/** For replies in the same chat and message thread, the original message. Note that the Message object in this field will not contain further reply_to_message fields even if it itself is a reply. */
reply_to_message?: ReplyMessage;
/** Identifier of the specific checklist task that is being replied to */
reply_to_checklist_task_id?: number;
/** Persistent identifier of the specific poll option that is being replied to */
reply_to_poll_option_id?: string;
/** True, if the message is a paid post. Note that such posts must not be deleted for 24 hours to receive the payment and can't be edited. */
is_paid_post?: true;
/** Information about the message that is being replied to, which may come from another chat or forum topic */
external_reply?: ExternalReplyInfo;
/** For replies that quote part of the original message, the quoted part of the message */
quote?: TextQuote;
/** For replies to a story, the original message */
reply_to_story?: Story;
/** Bot through which the message was sent */
via_bot?: User;
/** For a message sent by a guest bot, this is the user whose original message triggered the bot's response. */
guest_bot_caller_user?: User;
/** For a message sent by a guest bot, this is the chat whose original message triggered the bot's response. */
guest_bot_caller_chat?: Chat;
/** Date the message was last edited in Unix time */
edit_date?: number;
/** True, if the message can't be forwarded */
has_protected_content?: true;
/** True, if the caption must be shown above the message media */
show_caption_above_media?: true;
/** True, if the message was sent by an implicit action, for example, as an away or a greeting business message, or as a scheduled message */
is_from_offline?: true;
/** Signature of the post author for messages in channels, or the custom title of an anonymous group administrator */
author_signature?: string;
/** Options used for link preview generation for the message, if it is a text message and link preview options were changed */
link_preview_options?: LinkPreviewOptions;
/** Unique identifier of the message effect added to the message */
effect_id?: string;
/** The number of Telegram Stars that were paid by the sender of the message to send it */
paid_star_count?: number;
/** Inline keyboard attached to the message. login_url buttons are represented as ordinary url buttons. */
reply_markup?: InlineKeyboardMarkup;
}
interface CaptionableMessage extends CommonMessage {
/** Caption for the animation, audio, document, photo, video or voice */
caption?: string;
/** For messages with a caption, special entities like usernames, URLs, bot commands, etc. that appear in the caption */
caption_entities?: MessageEntity[];
}
interface MediaMessage extends CaptionableMessage {
/** The unique identifier inside this chat of a media message group this message belongs to */
media_group_id?: string;
/** True, if the message media is covered by a spoiler animation */
has_media_spoiler?: true;
}
type TextMessage = CommonMessage & MsgWith<"text"> & Partial<MsgWith<"entities">>;
type RichMessageMessage = CommonMessage & MsgWith<"rich_message">;
type AnimationMessage = DocumentMessage & MsgWith<"animation">;
type AudioMessage = CaptionableMessage & MsgWith<"audio">;
type DocumentMessage = CaptionableMessage & MsgWith<"document">;
type LivePhotoMessage = MediaMessage & MsgWith<"live_photo">;
type PaidMediaMessage = CommonMessage & MsgWith<"paid_media">;
type PhotoMessage = MediaMessage & MsgWith<"photo">;
type StickerMessage = CommonMessage & MsgWith<"sticker">;
type StoryMessage = CommonMessage & MsgWith<"story">;
type VideoMessage = MediaMessage & MsgWith<"video">;
type VideoNoteMessage = CommonMessage & MsgWith<"video_note">;
type VoiceMessage = CaptionableMessage & MsgWith<"voice">;
type ContactMessage = CommonMessage & MsgWith<"contact">;
type DiceMessage = CommonMessage & MsgWith<"dice">;
type GameMessage = CommonMessage & MsgWith<"game">;
type PollMessage = CommonMessage & MsgWith<"poll">;
type VenueMessage = LocationMessage & MsgWith<"venue">;
type LocationMessage = CommonMessage & MsgWith<"location">;
type DirectMessagePriceChangedMessage = ServiceMessage & MsgWith<"direct_message_price_changed">;
type ChecklistMessage = CommonMessage & MsgWith<"checklist">;
type ChecklistTasksDoneMessage = ServiceMessage & MsgWith<"checklist_tasks_done">;
type ChecklistTasksAddedMessage = ServiceMessage & MsgWith<"checklist_tasks_added">;
type SuggestedPostInfoMessage = ServiceMessage & MsgWith<"suggested_post_info">;
type SuggestedPostApprovedMessage = ServiceMessage & MsgWith<"suggested_post_approved">;
type SuggestedPostApprovalFailedMessage = ServiceMessage & MsgWith<"suggested_post_approval_failed">;
type SuggestedPostDeclinedMessage = ServiceMessage & MsgWith<"suggested_post_declined">;
type SuggestedPostPaidMessage = ServiceMessage & MsgWith<"suggested_post_paid">;
type SuggestedPostRefundedMessage = ServiceMessage & MsgWith<"suggested_post_refunded">;
type ChatOwnerLeftMessage = ServiceMessage & MsgWith<"chat_owner_left">;
type ChatOwnerChangedMessage = ServiceMessage & MsgWith<"chat_owner_changed">;
type NewChatMembersMessage = ServiceMessage & MsgWith<"new_chat_members">;
type LeftChatMemberMessage = ServiceMessage & MsgWith<"left_chat_member">;
type NewChatTitleMessage = ServiceMessage & MsgWith<"new_chat_title">;
type NewChatPhotoMessage = ServiceMessage & MsgWith<"new_chat_photo">;
type DeleteChatPhotoMessage = ServiceMessage & MsgWith<"delete_chat_photo">;
type GroupChatCreatedMessage = ServiceMessage & MsgWith<"group_chat_created">;
type SupergroupChatCreated = ServiceMessage & MsgWith<"supergroup_chat_created">;
type ChannelChatCreatedMessage = ServiceMessage & MsgWith<"channel_chat_created">;
type ManagedBotCreatedMessage = ServiceMessage & MsgWith<"managed_bot_created">;
type PollOptionAddedMessage = ServiceMessage & MsgWith<"poll_option_added">;
type PollOptionDeletedMessage = ServiceMessage & MsgWith<"poll_option_deleted">;
type MessageAutoDeleteTimerChangedMessage = ServiceMessage & MsgWith<"message_auto_delete_timer_changed">;
type MigrateToChatIdMessage = ServiceMessage & MsgWith<"migrate_to_chat_id">;
type MigrateFromChatIdMessage = ServiceMessage & MsgWith<"migrate_from_chat_id">;
type PinnedMessageMessage = ServiceMessage & MsgWith<"pinned_message">;
type InvoiceMessage = ServiceMessage & MsgWith<"invoice">;
type SuccessfulPaymentMessage = ServiceMessage & MsgWith<"successful_payment">;
type RefundedPaymentMessage = ServiceMessage & MsgWith<"refunded_payment">;
type UsersSharedMessage = ServiceMessage & MsgWith<"users_shared">;
type ChatSharedMessage = ServiceMessage & MsgWith<"chat_shared">;
type ConnectedWebsiteMessage = ServiceMessage & MsgWith<"connected_website">;
type WriteAccessAllowedMessage = ServiceMessage & MsgWith<"write_access_allowed">;
type PassportDataMessage = ServiceMessage & MsgWith<"passport_data">;
type ProximityAlertTriggeredMessage = ServiceMessage & MsgWith<"proximity_alert_triggered">;
type BoostAddedMessage = ServiceMessage & MsgWith<"boost_added">;
type ChatBackgroundSetMessage = ServiceMessage & MsgWith<"chat_background_set">;
type ForumTopicCreatedMessage = ServiceMessage & MsgWith<"forum_topic_created">;
type ForumTopicEditedMessage = ServiceMessage & MsgWith<"forum_topic_edited">;
type ForumTopicClosedMessage = ServiceMessage & MsgWith<"forum_topic_closed">;
type ForumTopicReopenedMessage = ServiceMessage & MsgWith<"forum_topic_reopened">;
type GeneralForumTopicHiddenMessage = ServiceMessage & MsgWith<"general_forum_topic_hidden">;
type GeneralForumTopicUnhiddenMessage = ServiceMessage & MsgWith<"general_forum_topic_unhidden">;
type GiveawayCreatedMessage = ServiceMessage & MsgWith<"giveaway_created">;
type GiveawayMessage = ServiceMessage & MsgWith<"giveaway">;
type GiveawayWinnersMessage = ServiceMessage & MsgWith<"giveaway_winners">;
type GiveawayCompletedMessage = ServiceMessage & MsgWith<"giveaway_completed">;
type GiftMessage = ServiceMessage & MsgWith<"gift">;
type UniqueGiftMessage = ServiceMessage & MsgWith<"unique_gift">;
type GiftUpgradeSentMessage = ServiceMessage & MsgWith<"gift_upgrade_sent">;
type PaidMessagePriceChangedMessage = ServiceMessage & MsgWith<"paid_message_price_changed">;
type VideoChatScheduledMessage = ServiceMessage & MsgWith<"video_chat_scheduled">;
type VideoChatStartedMessage = ServiceMessage & MsgWith<"video_chat_started">;
type VideoChatEndedMessage = ServiceMessage & MsgWith<"video_chat_ended">;
type VideoChatParticipantsInvitedMessage = ServiceMessage & MsgWith<"video_chat_participants_invited">;
type WebAppDataMessage = ServiceMessage & MsgWith<"web_app_data">;
}
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;
/** For text messages, special entities like usernames, URLs, bot commands, etc. that appear in the text */
entities?: MessageEntity[];
/** Message is a rich formatted message */
rich_message?: RichMessage;
/** Message is an animation, information about the animation. For backward compatibility, when this field is set, the document field will also be set. */
animation?: Animation;
/** Message is an audio file, information about the file */
audio?: Audio;
/** Message is a general file, information about the file */
document?: Document;
/** Message is a live photo, information about the live photo. For backward compatibility, when this field is set, the photo field will also be set */
live_photo?: LivePhoto;
/** Message contains paid media; information about the paid media */
paid_media?: PaidMediaInfo;
/** Message is a photo, available sizes of the photo */
photo?: PhotoSize[];
/** Message is a sticker, information about the sticker */
sticker?: Sticker;
/** Message is a forwarded story */
story?: Story;
/** Message is a video, information about the video */
video?: Video;
/** Message is a video note, information about the video message */
video_note?: VideoNote;
/** Message is a voice message, information about the file */
voice?: Voice;
/** Message is a shared contact, information about the contact */
contact?: Contact;
/** Message is a dice with random value */
dice?: Dice;
/** Message is a game, information about the game. */
game?: Game;
/** Message is a native poll, information about the poll */
poll?: Poll;
/** Message is a venue, information about the venue. For backward compatibility, when this field is set, the location field will also be set. */
venue?: Venue;
/** Message is a shared location, information about the location */
location?: Location;
/** Message is a checklist */
checklist?: Checklist;
/** Service message: some tasks in a checklist were marked as done or not done */
checklist_tasks_done?: ChecklistTasksDone;
/** Service message: tasks were added to a checklist */
checklist_tasks_added?: ChecklistTasksAdded;
/** Information about suggested post parameters if the message is a suggested post in a channel direct messages chat. If the message is an approved or declined suggested post, then it can't be edited. */
suggested_post_info?: SuggestedPostInfo;
/** Service message: a suggested post was approved */
suggested_post_approved?: SuggestedPostApproved;
/** Service message: approval of a suggested post has failed */
suggested_post_approval_failed?: SuggestedPostApprovalFailed;
/** Service message: a suggested post was declined */
suggested_post_declined?: SuggestedPostDeclined;
/** Service message: payment for a suggested post was received */
suggested_post_paid?: SuggestedPostPaid;
/** Service message: payment for a suggested post was refunded */
suggested_post_refunded?: SuggestedPostRefunded;
/** Service message: chat owner has left */
chat_owner_left?: ChatOwnerLeft;
/** Service message: chat owner has changed */
chat_owner_changed?: ChatOwnerChanged;
/** New members that were added to the group or supergroup and information about them (the bot itself may be one of these members) */
new_chat_members?: User[];
/** A member was removed from the group, information about them (this member may be the bot itself) */
left_chat_member?: User;
/** A chat title was changed to this value */
new_chat_title?: string;
/** A chat photo was change to this value */
new_chat_photo?: PhotoSize[];
/** Service message: the chat photo was deleted */
delete_chat_photo?: true;
/** Service message: the group has been created */
group_chat_created?: true;
/** Service message: the supergroup has been created. This field can't be received in a message coming through updates, because bot can't be a member of a supergroup when it is created. It can only be found in reply_to_message if someone replies to a very first message in a directly created supergroup. */
supergroup_chat_created?: true;
/** Service message: the channel has been created. This field can't be received in a message coming through updates, because bot can't be a member of a channel when it is created. It can only be found in reply_to_message if someone replies to a very first message in a channel. */
channel_chat_created?: true;
/** Service message: user created a bot that will be managed by the current bot */
managed_bot_created?: ManagedBotCreated;
/** Service message: answer option was added to a poll */
poll_option_added?: PollOptionAdded;
/** Service message: answer option was deleted from a poll */
poll_option_deleted?: PollOptionDeleted;
/** Service message: auto-delete timer settings changed in the chat */
message_auto_delete_timer_changed?: MessageAutoDeleteTimerChanged;
/** The group has been migrated to a supergroup with the specified identifier. */
migrate_to_chat_id?: number;
/** The supergroup has been migrated from a group with the specified identifier. */
migrate_from_chat_id?: number;
/** Specified message was pinned. Note that the Message object in this field will not contain further reply_to_message fields even if it itself is a reply. */
pinned_message?: MaybeInaccessibleMessage;
/** Message is an invoice for a payment, information about the invoice. */
invoice?: Invoice;
/** Message is a service message about a successful payment, information about the payment. */
successful_payment?: SuccessfulPayment;
/** Message is a service message about a refunded payment, information about the payment. */
refunded_payment?: RefundedPayment;
/** Service message: users were shared with the bot */
users_shared?: UsersShared;
/** Service message: a chat was shared with the bot */
chat_shared?: ChatShared;
/** The domain name of the website on which the user has logged in. */
connected_website?: string;
/** Service message: the user allowed the bot to write messages after adding it to the attachment or side menu, launching a Web App from a link, or accepting an explicit request from a Web App sent by the method requestWriteAccess */
write_access_allowed?: WriteAccessAllowed;
/** Telegram Passport data */
passport_data?: PassportData;
/** Service message. A user in the chat triggered another user's proximity alert while sharing Live Location. */
proximity_alert_triggered?: ProximityAlertTriggered;
/** Service message: user boosted the chat */
boost_added?: ChatBoostAdded;
chat_background_set?: ChatBackground;
/** Service message: forum topic created */
forum_topic_created?: ForumTopicCreated;
/** Service message: forum topic edited */
forum_topic_edited?: ForumTopicEdited;
/** Service message: forum topic closed */
forum_topic_closed?: ForumTopicClosed;
/** Service message: forum topic reopened */
forum_topic_reopened?: ForumTopicReopened;
/** Service message: the 'General' forum topic hidden */
general_forum_topic_hidden?: GeneralForumTopicHidden;
/** Service message: the 'General' forum topic unhidden */
general_forum_topic_unhidden?: GeneralForumTopicUnhidden;
/** Service message: a scheduled giveaway was created */
giveaway_created?: GiveawayCreated;
/** The message is a scheduled giveaway message */
giveaway?: Giveaway;
/** A giveaway with public winners was completed */
giveaway_winners?: GiveawayWinners;
/** Service message: a giveaway without public winners was completed */
giveaway_completed?: GiveawayCompleted;
/** Service message: a regular gift was sent or received */
gift?: GiftInfo;
/** Service message: upgrade of a gift was purchased after the gift was sent */
gift_upgrade_sent?: GiftInfo;
/** Service message: a unique gift was sent or received */
unique_gift?: UniqueGiftInfo;
/** Service message: the price for paid messages has changed in the chat */
paid_message_price_changed?: PaidMessagePriceChanged;
/** Service message: the price for paid messages in the corresponding direct messages chat of a channel has changed */
direct_message_price_changed?: DirectMessagePriceChanged;
/** Service message: video chat scheduled */
video_chat_scheduled?: VideoChatScheduled;
/** Service message: video chat started */
video_chat_started?: VideoChatStarted;
/** Service message: video chat ended */
video_chat_ended?: VideoChatEnded;
/** Service message: new participants invited to a video chat */
video_chat_participants_invited?: VideoChatParticipantsInvited;
/** Service message: data sent by a Web App */
web_app_data?: WebAppData;
}
/** This object represents a unique message identifier. */
export interface MessageId {
/** Unique message identifier. In specific instances (e.g., message containing a video sent to a big chat), the server might automatically schedule a message instead of sending it immediately. In such cases, this field will be 0 and the relevant message will be unusable until it is actually sent. */
message_id: number;
}
/** Describes an inline message sent by a Web App on behalf of a user. */
export interface SentWebAppMessage {
/** Identifier of the sent inline message. Available only if there is an inline keyboard attached to the message. */
inline_message_id: string;
}
/** Describes an inline message sent by a guest bot. */
export interface SentGuestMessage {
/** Identifier of the sent inline message */
inline_message_id: string;
}
/** Describes an inline message to be sent by a user of a Mini App. */
export interface PreparedInlineMessage {
/** Unique identifier of the prepared message */
id: string;
/** Expiration date of the prepared message, in Unix time. Expired prepared messages can no longer be used. */
expiration_date: number;
}
/** This object describes a message that was deleted or is otherwise inaccessible to the bot. */
export interface InaccessibleMessage extends Omit<Message, "chat" | "message_id" | "date"> {
/** Chat the message belonged to */
chat: Chat;
/** Unique message identifier inside the chat */
message_id: number;
/** Always 0. The field can be used to differentiate regular and inaccessible messages. */
date: 0;
}
/** This object describes a message that can be inaccessible to the bot. It can be one of
- Message
- InaccessibleMessage */
export type MaybeInaccessibleMessage = Message | InaccessibleMessage;
/** The Bot API supports basic formatting for messages. You can use bold, italic, underlined, strikethrough, spoiler text, block quotations as well as inline links and pre-formatted code in your bots' messages. Telegram clients will render them accordingly. You can specify text entities directly, or use markdown-style or HTML-style formatting.
*
* Note that Telegram clients will display an **alert** to the user before opening an inline link ('Open this link?' together with the full URL).
*
* Message entities can be nested, providing following restrictions are met:
* - If two entities have common characters, then one of them is fully contained inside another.
* - bold, italic, underline, strikethrough, and spoiler entities can contain and can be part of any other entities, except pre and code.
* - blockquote and expandable_blockquote entities can't be nested.
* - All other entities can't contain each other.
*
* Links `tg://user?id=<user_id>` can be used to mention a user by their identifier without using a username. Please note:
*
* - These links will work only if they are used inside an inline link or in an inline keyboard button. For example, they will not work, when used in a message text.
* - Unless the user is a member of the chat where they were mentioned, these mentions are only guaranteed to work if the user has contacted the bot in private in the past or has sent a callback query to the bot via an inline button and doesn't have Forwarded Messages privacy enabled for the bot.
*
* You can find the list of programming and markup languages for which syntax highlighting is supported at [libprisma#supported-languages](https://github.com/TelegramMessenger/libprisma#supported-languages).
*
* #### Date-time entity formatting
*
* Date-time entity formatting is specified by a format string, which must adhere to the following regular expression: `r|w?[dD]?[tT]?`.
*
* If the format string is empty, the underlying text is displayed as-is; however, the user can still receive the underlying date in their local format. When populated, the format string determines the output based on the presence of the following control characters:
*
* - `r`: Displays the time relative to the current time. Cannot be combined with any other control characters.
* - `w`: Displays the day of the week in the user's localized language.
* - `d`: Displays the date in short form (e.g., “17.03.22”).
* - `D`: Displays the date in long form (e.g., “March 17, 2022”).
* - `t`: Displays the time in short form (e.g., “22:45”).
* - `T`: Displays the time in long form (e.g., “22:45:00”).
*
* #### MarkdownV2 style
* To use this mode, pass *MarkdownV2* in the *parse_mode* field. Use the following syntax in your message:
*
* ````markdown
* *bold \*text*
* _italic \*text_
* __underline__
* ~strikethrough~
* ||spoiler||
* *bold _italic bold ~italic bold strikethrough ||italic bold strikethrough spoiler||~ __underline italic bold___ bold*
* [inline URL](http://www.example.com/)
* [inline mention of a user](tg://user?id=123456789)
* 
* 
* 
* 
* 
* `inline fixed-width code`
* ```
* pre-formatted fixed-width code block
* ```
* ```python
* pre-formatted fixed-width code block written in the Python programming language
* ```
* >Block quotation started
* >Block quotation continued
* >Block quotation continued
* >Block quotation continued
* >The last line of the block quotation
* ***>The second expandable block quotation started right after the previous
* >It is separated from the previous block quotation by an empty bold entity
* >Expandable block quotation continued
* >Hidden by default part of the expandable block quotation started
* >Expandable block quotation continued
* >The last line of the expandable block quotation with the expandability mark||
* ````
* Please note:
*
* - Any character with code between 1 and 126 inclusively can be escaped anywhere with a preceding '\' character, in which case it is treated as an ordinary character and not a part of the markup. This implies that '\' character usually must be escaped with a preceding '\' character.
* - Inside `pre` and `code` entities, all '`' and '\' characters must be escaped with a preceding '\' character.
* - Inside the `(...)` part of the inline link and custom emoji definition, all ')' and '\' must be escaped with a preceding '\' character.
* - In all other places characters '_', '*', '[', ']', '(', ')', '~', '`', '>', '#', '+', '-', '=', '|', '{', '}', '.', '!' must be escaped with the preceding character '\'.
* - In case of ambiguity between `italic` and `underline` entities `__` is always greedily treated from left to right as beginning or end of an `underline` entity, so instead of `___italic underline___` use `___italic underline_**__`, adding an empty bold entity as a separator.
* - A valid emoji must be provided as an alternative value for the custom emoji. The emoji will be shown instead of the custom emoji in places where a custom emoji cannot be displayed (e.g., system notifications) or if the message is forwarded by a non-premium user. It is recommended to use the emoji from the emoji field of the custom emoji sticker.
* - Custom emoji entities can only be used by bots that purchased additional usernames on Fragment.
* - See date-time entity formatting for more details about supported date-time formats.
*
* #### HTML style
* To use this mode, pass *HTML* in the *parse_mode* field. The following tags are currently supported:
*
* ```html
* <b>bold</b>, <strong>bold</strong>
* <i>italic</i>, <em>italic</em>
* <u>underline</u>, <ins>underline</ins>
* <s>strikethrough</s>, <strike>strikethrough</strike>, <del>strikethrough</del>
* <span class="tg-spoiler">spoiler</span>, <tg-spoiler>spoiler</tg-spoiler>
* <b>bold <i>italic bold <s>italic bold strikethrough <span class="tg-spoiler">italic bold strikethrough spoiler</span></s> <u>underline italic bold</u></i> bold</b>
* <a href="http://www.example.com/">inline URL</a>
* <a href="tg://user?id=123456789">inline mention of a user</a>
* <tg-emoji emoji-id="5368324170671202286">👍</tg-emoji>
* <tg-time unix="1647531900" format="wDT">22:45 tomorrow</tg-time>
* <tg-time unix="1647531900" format="t">22:45 tomorrow</tg-time>
* <tg-time unix="1647531900" format="r">22:45 tomorrow</tg-time>
* <tg-time unix="1647531900">22:45 tomorrow</tg-time>
* <code>inline fixed-width code</code>
* <pre>pre-formatted fixed-width code block</pre>
* <pre><code class="language-python">pre-formatted fixed-width code block written in the Python programming language</code></pre>
* <blockquote>Block quotation started\nBlock quotation continued\nThe last line of the block quotation</blockquote>
* <blockquote expandable>Expandable block quotation started\nExpandable block quotation continued\nExpandable block quotation continued\nHidden by default part of the block quotation started\nExpandable block quotation continued\nThe last line of the block quotation</blockquote>
* ```
* Please note:
*
* - Only the tags mentioned above are currently supported.
* - All `<`, `>` and `&` symbols that are not a part of a tag or an HTML entity must be replaced with the corresponding HTML entities (`<` with `<`, `>` with `>` and `&` with `&`).
* - All numerical HTML entities are supported.
* - The API currently supports only the following named HTML entities: `<`, `>`, `&` and `"`.
* - Use nested `pre` and `code` tags, to define programming language for pre entity.
* - Programming language can't be specified for standalone `code` tags.
* - A valid emoji must be used as the content of the tg-emoji tag. The emoji will be shown instead of the custom emoji in places where a custom emoji cannot be displayed (e.g., system notifications) or if the message is forwarded by a non-premium user. It is recommended to use the emoji from the emoji field of the custom emoji sticker.
* - Custom emoji entities can only be used by bots that purchased additional usernames on Fragment.
* - See date-time entity formatting for more details about supported date-time formats.
*
* #### Markdown style
* This is a legacy mode, retained for backward compatibility. To use this mode, pass *Markdown* in the *parse_mode* field. Use the following syntax in your message:
*
* ````markdown
* *bold text*
* _italic text_
* [inline URL](http://www.example.com/)
* [inline mention of a user](tg://user?id=123456789)
* `inline fixed-width code`
* ```
* pre-formatted fixed-width code block
* ```
* ```python
* pre-formatted fixed-width code block written in the Python programming language
* ```
* ````
* Please note:
*
* - Entities must not be nested, use parse mode MarkdownV2 instead.
* - There is no way to specify “underline”, “strikethrough”, “spoiler”, “blockquote”, “expandable_blockquote”, “custom_emoji”, and “date_time” entities, use parse mode MarkdownV2 instead.
* - To escape characters '_', '*', '`', '[' outside of an entity, prepend the character '\' before them.
* - Escaping inside entities is not allowed, so entity must be closed first and reopened again: use `_snake_\__case_` for italic `snake_case` and `*2*\**2=4*` for bold `2*2=4`. */
export type ParseMode = "Markdown" | "MarkdownV2" | "HTML";
export declare namespace MessageEntity {
interface AbstractMessageEntity {
/** Type of the entity. Currently, can be “mention” (@username), “hashtag” (#hashtag or #hashtag@chatusername), “cashtag” ($USD or $USD@chatusername), “bot_command” (/start@jobs_bot), “url” (https://telegram.org), “email” (do-not-reply@telegram.org), “phone_number” (+1-212-555-0123), “bold” (bold text), “italic” (italic text), “underline” (underlined text), “strikethrough” (strikethrough text), “spoiler” (spoiler message), “blockquote” (block quotation), “expandable_blockquote” (collapsed-by-default block quotation), “code” (monowidth string), “pre” (monowidth block), “text_link” (for clickable text URLs), “text_mention” (for users without usernames), “custom_emoji” (for inline custom emoji stickers), or “date_time” (for formatted date and time). */
type: string;
/** Offset in UTF-16 code units to the start of the entity */
offset: number;
/** Length of the entity in UTF-16 code units */
length: number;
}
interface CommonMessageEntity extends AbstractMessageEntity {
type: "mention" | "hashtag" | "cashtag" | "bot_command" | "url" | "email" | "phone_number" | "bold" | "italic" | "underline" | "strikethrough" | "spoiler" | "blockquote" | "expandable_blockquote" | "code";
}
interface PreMessageEntity extends AbstractMessageEntity {
type: "pre";
/** For “pre” only, the programming language of the entity text */
language?: string;
}
interface TextLinkMessageEntity extends AbstractMessageEntity {
type: "text_link";
/** For “text_link” only, URL that will be opened after user taps on the text */
url: string;
}
interface TextMentionMessageEntity extends AbstractMessageEntity {
type: "text_mention";
/** For “text_mention” only, the mentioned user */
user: User;
}
interface CustomEmojiMessageEntity extends AbstractMessageEntity {
type: "custom_emoji";
/** For “custom_emoji” only, unique identifier of the custom emoji. Use getCustomEmojiStickers to get full information about the sticker. */
custom_emoji_id: string;
}
interface DateTimeMessageEntity extends AbstractMessageEntity {
type: "date_time";
/** For “date_time” only, the Unix time associated with the entity */
unix_time: number;
/** For “date_time” only, the string that defines the formatting of the date and time. See date-time entity formatting for more details. */
date_time_format: "r" | `${"w" | ""}${"d" | "D" | ""}${"t" | "T" | ""}`;
}
}
/** This object represents one special entity in a text message. For example, hashtags, usernames, URLs, etc. */
export type MessageEntity = MessageEntity.CommonMessageEntity | MessageEntity.CustomEmojiMessageEntity | MessageEntity.PreMessageEntity | MessageEntity.TextLinkMessageEntity | MessageEntity.TextMentionMessageEntity | MessageEntity.DateTimeMessageEntity;
/** This object contains information about the quoted part of a message that is replied to by the given message. */
export interface TextQuote {
/** Text of the quoted part of a message that is replied to by the given message */
text: string;
/** Special entities that appear in the quote. Currently, only bold, italic, underline, strikethrough, spoiler, custom_emoji, and date_time entities are kept in quotes. */
entities?: MessageEntity[];
/** Approximate quote position in the original message in UTF-16 code units as specified by the sender */
position: number;
/** True, if the quote was chosen manually by the message sender. Otherwise, the quote was added automatically by the server. */
is_manual?: true;
}
/** This object contains information about a message that is being replied to, which may come from another chat or forum topic. */
export interface ExternalReplyInfo {
/** Origin of the message replied to by the given message */
origin: MessageOrigin;
/** Chat the original message belongs to. Available only if the chat is a supergroup or a channel. */
chat?: Chat;
/** Unique message identifier inside the original chat. Available only if the original chat is a supergroup or a channel. */
message_id?: number;
/** Options used for link preview generation for the original message, if it is a text message */
link_preview_options?: LinkPreviewOptions;
/** Message is an animation, information about the animation */
animation?: Animation;
/** Message is an audio file, information about the file */
audio?: Audio;
/** Message is a general file, information about the file */
document?: Document;
/** Message is a live photo, information about the live photo */
live_photo?: LivePhoto;
/** Message is a photo, available sizes of the photo */
photo?: PhotoSize[];
/** Message is a sticker, information about the sticker */
sticker?: Sticker;
/** Message is a forwarded story */
story?: Story;
/** Message is a video, information about the video */
video?: Video;
/** Message is a video note, information about the video message */
video_note?: VideoNote;
/** Message is a voice message, information about the file */
voice?: Voice;
/** True, if the message media is covered by a spoiler animation */
has_media_spoiler?: true;
/** Message is a shared contact, information about the contact */
contact?: Contact;
/** Message is a dice with random value */
dice?: Dice;
/** Message is a game, information about the game. */
game?: Game;
/** Message is a scheduled giveaway, information about the giveaway */
giveaway?: Giveaway;
/** A giveaway with public winners was completed */
giveaway_winners?: GiveawayWinners;
/** Message is an invoice for a payment, information about the invoice. */
invoice?: Invoice;
/** Message is a shared location, information about the location */
location?: Location;
/** Message contains paid media; information about the paid media */
paid_media?: PaidMediaInfo;
/** Message is a native poll, information about the poll */
poll?: Poll;
/** Message is a checklist */
checklist?: Checklist;
/** Message is a venue, information about the venue */
venue?: Venue;
}
/** Describes reply parameters for the message that is being sent. */
export interface ReplyParameters {
/** Identifier of the message that will be replied to in the current chat, or in the chat chat_id if it is specified */
message_id: number;
/** If the message to be replied to is from a different chat, unique identifier for the chat or username of the bot, supergroup or channel in the format `@username`. Not supported for messages sent on behalf of a business account and messages from channel direct messages chats. */
chat_id?: number | string;
/** Identifier of the specific checklist task to be replied to */
checklist_task_id?: number;
/** Persistent identifier of the specific poll option to be replied to */
poll_option_id?: string;
/** Pass True if the message should be sent even if the specified message to be replied to is not found; can be used only for replies in the same chat and forum topic. Always True for messages sent on behalf of a business account. */
allow_sending_without_reply?: boolean;
/** Quoted part of the message to be replied to; 0-1024 characters after entities parsing. The quote must be an exact substring of the message to be replied to, including bold, italic, underline, strikethrough, spoiler, custom_emoji, and date_time entities. The message will fail to send if the quote isn't found in the original message. */
quote?: string;
/** Mode for parsing entities in the quote. See formatting options for more details. */
quote_parse_mode?: ParseMode;
/** A JSON-serialized list of special entities that appear in the quote. It can be specified instead of quote_parse_mode. */
quote_entities?: MessageEntity[];
/** Position of the quote in the original message in UTF-16 code units */
quote_position?: number;
}
/** This object describes the origin of a message. It can be one of
- MessageOriginUser
- MessageOriginHiddenUser
- MessageOriginChat
- MessageOriginChannel */
export type MessageOrigin = MessageOriginUser | MessageOriginHiddenUser | MessageOriginChat | MessageOriginChannel;
/** The message was originally sent by a known user. */
export interface MessageOriginUser {
/** Type of the message origin, always “user” */
type: "user";
/** Date the message was sent originally in Unix time */
date: number;
/** User that sent the message originally */
sender_user: User;
}
/** The message was originally sent by an unknown user. */
export interface MessageOriginHiddenUser {
/** Type of the message origin, always “hidden_user” */
type: "hidden_user";
/** Date the message was sent originally in Unix time */
date: number;
/** Name of the user that sent the message originally */
sender_user_name: string;
}
/** The message was originally sent on behalf of a chat to a group chat. */
export interface MessageOriginChat {
/** Type of the message origin, always “chat” */
type: "chat";
/** Date the message was sent originally in Unix time */
date: number;
/** Chat that sent the message originally */
sender_chat: Chat;
/** For messages originally sent by an anonymous chat administrator, original message author signature */
author_signature?: string;
}
/** The message was originally sent to a channel chat. */
export interface MessageOriginChannel {
/** Type of the message origin, always “channel” */
type: "channel";
/** Date the message was sent originally in Unix time */
date: number;
/** Channel chat to which the message was originally sent */
chat: Chat.ChannelChat;
/** Unique message identifier inside the chat */
message_id: number;
/** Signature of the original post author */
author_signature?: string;
}
/** This object represents one size of a photo or a file / sticker thumbnail. */
export interface PhotoSize {
/** Identifier for this file, which can be used to download or reuse the file */
file_id: string;
/** Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file. */
file_unique_id: string;
/** Photo width */
width: number;
/** Photo height */
height: number;
/** File size in bytes */
file_size?: number;
}
/** This object represents a live photo. */
export interface LivePhoto {
/** Available sizes of the corresponding static photo */
photo?: PhotoSize[];
/** Identifier for the video file which can be used to download or reuse the file */
file_id: string;
/** Unique identifier for the video file which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file. */
file_unique_id: string;
/** Video width as defined by the sender */
width: number;
/** Video height as defined by the sender */
height: number;
/** Duration of the video in seconds as defined by the sender */
duration: number;
/** MIME type of the file as defined by the sender */
mime_type?: string;
/** File size in bytes */
file_size?: number;
}
/** Rich formatted message. */
export interface RichMessage {
/** Content of the message */
blocks: RichBlock[];
/** True, if the rich message must be shown right-to-left */
is_rtl?: boolean;
}
/** This object represents an animation file (GIF or H.264/MPEG-4 AVC video without sound). */
export interface Animation {
/** Identifier for this file, which can be used to download or reuse the file */
file_id: string;
/** Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file. */
file_unique_id: string;
/** Video width as defined by sender */
width: number;
/** Video height as defined by sender */
height: number;
/** Duration of the video in seconds as defined by sender */
duration: number;
/** Animation thumbnail as defined by sender */
thumbnail?: PhotoSize;
/** Original animation filename as defined by sender */
file_name?: string;
/** MIME type of the file as defined by sender */
mime_type?: string;
/** File size in bytes */
file_size?: number;
}
/** This object represents an audio file to be treated as music by the Telegram clients. */
export interface Audio {
/** Identifier for this file, which can be used to download or reuse the file */
file_id: string;
/** Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file. */
file_unique_id: string;
/** Duration of the audio in seconds as defined by sender */
duration: number;
/** Performer of the audio as defined by sender or by audio tags */
performer?: string;
/** Title of the audio as defined by sender or by audio tags */
title?: string;
/** Original filename as defined by sender */
file_name?: string;
/** MIME type of the file as defined by sender */
mime_type?: string;
/** File size in bytes */
file_size?: number;
/** Thumbnail of the album cover to which the music file belongs */
thumbnail?: PhotoSize;
}
/** This object represents a general file (as opposed to photos, voice messages and audio files). */
export interface Document {
/** Identifier for this file, which can be used to download or reuse the file */
file_id: string;
/** Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file. */
file_unique_id: string;
/** Document thumbnail as defined by sender */
thumbnail?: PhotoSize;
/** Original filename as defined by sender */
file_name?: string;
/** MIME type of the file as defined by sender */
mime_type?: string;
/** File size in bytes */
file_size?: number;
}
/** This object represents a story. */
export interface Story {
/** Chat that posted the story */
chat: Chat;
/** Unique identifier for the story in the chat */
id: number;
}
/** This object represents a video file. */
export interface Video {
/** Identifier for this file, which can be used to download or reuse the file */
file_id: string;
/** Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file. */
file_unique_id: string;
/** Video width as defined by sender */
width: number;
/** Video height as defined by sender */
height: number;
/** Duration of the video in seconds as defined by sender */
duration: number;
/** Video thumbnail */
thumbnail?: PhotoSize;
/** Available sizes of the cover of the video in the message */
cover?: PhotoSize[];
/** Timestamp in seconds from which the video will play in the message */
start_timestamp?: number;
/** Original filename as defined by sender */
file_name?: string;
/** MIME type of the file as defined by sender */
mime_type?: string;
/** File size in bytes */
file_size?: number;
/** List of available qualities of the video. */
qualities?: VideoQuality[];
}
/** This object represents a video file of a specific quality. */
export interface VideoQuality {
/** Identifier for this file, which can be used to download or reuse the file */
file_id: string;
/** Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file. */
file_unique_id: string;
/** Video width */
width: number;
/** Video height */
height: number;
/** Codec that was used to encode the video, for example, “h264”, “h265”, or “av01” */
codec: string;
/** File size in byte