telegraf-ts
Version:
Well-Typed fork of telegraf
1,983 lines (1,655 loc) • 105 kB
TypeScript
/* eslint-disable max-lines */
/// <reference types="node" />
export type ParseMode = 'Markdown' | 'MarkdownV2' | 'HTML';
export type MemberStatus =
| 'creator'
| 'administrator'
| 'member'
| 'restricted'
| 'left'
| 'kicked';
export type AdminPermissions = keyof ChatPermissions | keyof ExtraPromoteChatMember;
export type UserPermissions = keyof UserPermissionsOption;
export interface UserPermissionsOption {
can_send_messages?: boolean;
can_send_media_messages?: boolean;
can_send_other_messages?: boolean;
can_add_web_page_previews?: boolean;
}
/**
* This object contains information about one member of a chat.
*/
export interface ChatMember extends ChatPermissions, ExtraPromoteChatMember {
/**
* Information about the user
*/
user: User;
/**
* The member's status in the chat. Can be “creator”, “administrator”,
* “member”, “restricted”, “left” or “kicked”
*/
status: MemberStatus;
/**
* Restricted and kicked only. Date when restrictions will be lifted for
* this user, unix time
*/
until_date?: number;
}
export type ChatAction =
| 'typing'
| 'upload_photo'
| 'record_video'
| 'upload_video'
| 'record_audio'
| 'upload_audio'
| 'upload_document'
| 'find_location'
| 'record_video_note'
| 'upload_video_note';
export type UpdateType =
| 'callback_query'
| 'channel_post'
| 'chosen_inline_result'
| 'edited_channel_post'
| 'edited_message'
| 'inline_query'
| 'message'
| 'pre_checkout_query'
| 'shipping_query'
| 'poll'
| 'poll_answer';
export type ChatType = 'private' | 'group' | 'supergroup' | 'channel';
export type MessageSubTypes =
| 'voice'
| 'video_note'
| 'video'
| 'venue'
| 'text'
| 'supergroup_chat_created'
| 'successful_payment'
| 'sticker'
| 'pinned_message'
| 'photo'
| 'new_chat_title'
| 'new_chat_photo'
| 'new_chat_members'
| 'migrate_to_chat_id'
| 'migrate_from_chat_id'
| 'location'
| 'left_chat_member'
| 'invoice'
| 'group_chat_created'
| 'game'
| 'document'
| 'delete_chat_photo'
| 'contact'
| 'channel_chat_created'
| 'audio'
| 'passport_data'
| 'connected_website'
| 'animation';
/**
* This object represents one result of an inline query
*/
export type InlineQueryResult =
| InlineQueryResultCachedAudio
| InlineQueryResultCachedDocument
| InlineQueryResultCachedGif
| InlineQueryResultCachedMpeg4Gif
| InlineQueryResultCachedPhoto
| InlineQueryResultCachedSticker
| InlineQueryResultCachedVideo
| InlineQueryResultCachedVoice
| InlineQueryResultArticle
| InlineQueryResultAudio
| InlineQueryResultContact
| InlineQueryResultGame
| InlineQueryResultDocument
| InlineQueryResultGif
| InlineQueryResultLocation
| InlineQueryResultMpeg4Gif
| InlineQueryResultPhoto
| InlineQueryResultVenue
| InlineQueryResultVideo
| InlineQueryResultVoice;
export type MessageMedia =
| InputMediaPhoto
| InputMediaVideo
| InputMediaAnimation
| InputMediaAudio
| InputMediaDocument;
/**
* This object represents a chat.
*/
export interface Chat {
/**
* Unique identifier for this chat. This number may be greater than 32 bits
* and some programming languages may have difficulty/silent defects in
* interpreting it. But it is smaller than 52 bits, so a signed 64 bit
* integer or double-precision float type are safe for storing this identifier.
*/
id: number;
/**
* Type of chat, can be either “private”, “group”, “supergroup” or “channel”
*/
type: ChatType;
/**
* Title, for supergroups, channels and group chats
*/
title?: string;
/**
* Username, for private chats, supergroups and channels if available
*/
username?: string;
/**
* First name of the other party in a private chat
*/
first_name?: string;
/**
* Last name of the other party in a private chat
*/
last_name?: string;
/**
* True if a group has ‘All Members Are Admins’ enabled.
*/
all_members_are_administrators?: boolean;
/**
* Chat photo. Returned only in getChat.
* @see https://core.telegram.org/bots/api#getchat
*/
photo?: ChatPhoto;
/**
* Description, for supergroups and channel chats. Returned only in getChat.
* @see https://core.telegram.org/bots/api#getchat
*/
description?: string;
/**
* Chat invite link, for supergroups and channel chats. Returned only in getChat.
* @see https://core.telegram.org/bots/api#getchat
*/
invite_link?: string;
/**
* Pinned message, for supergroups and channel chats. Returned only in getChat.
* @see https://core.telegram.org/bots/api#getchat
*/
pinned_message?: Message;
/**
* For supergroups, name of group sticker set. Returned only in getChat.
* @see https://core.telegram.org/bots/api#getchat
*/
sticker_set_name?: string;
/**
* True, if the bot can change the group sticker set. Returned only in getChat.
* @see https://core.telegram.org/bots/api#getchat
*/
can_set_sticker_set?: boolean;
}
export interface StickerData {
png_sticker: string | Buffer;
emojis: string;
mask_position: MaskPosition;
}
type FileId = string;
export interface InputFileByPath {
source: string;
}
export interface InputFileByReadableStream {
source: NodeJS.ReadableStream;
}
export interface InputFileByBuffer {
source: Buffer;
}
export interface InputFileByURL {
url: string;
filename: string;
}
interface InputFileByPath {
source: string;
}
interface InputFileByReadableStream {
source: NodeJS.ReadableStream;
}
interface InputFileByBuffer {
source: Buffer;
}
interface InputFileByURL {
url: string;
filename: string;
}
/**
* This object represents the contents of a file to be uploaded. Must be
* posted using multipart/form-data in the usual way that files are
* uploaded via the browser.
*/
export type InputFile =
| FileId
| InputFileByPath
| InputFileByReadableStream
| InputFileByBuffer
| InputFileByURL;
/**
* Sending video notes by a URL is currently unsupported
*/
export type InputFileVideoNote = Exclude<InputFile, InputFileByURL>;
export interface ChatPermissions {
/** True, if the user is allowed to send text messages, contacts, locations and venues */
can_send_messages?: boolean;
/** True, if the user is allowed to send audios, documents, photos, videos, video notes and voice notes, implies can_send_messages */
can_send_media_messages?: boolean;
/** True, if the user is allowed to send polls, implies can_send_messages */
can_send_polls?: boolean;
/** True, if the user is allowed to send animations, games, stickers and use inline bots, implies can_send_media_messages */
can_send_other_messages?: boolean;
/** True, if the user is allowed to add web page previews to their messages, implies can_send_media_messages */
can_add_web_page_previews?: boolean;
/** True, if the user is allowed to change the chat title, photo and other settings. Ignored in public supergroups */
can_change_info?: boolean;
/** True, if the user is allowed to invite new users to the chat */
can_invite_users?: boolean;
/** True, if the user is allowed to pin messages. Ignored in public supergroups */
can_pin_messages?: boolean;
}
export interface ExtraRestrictChatMember {
/** New user permissions */
permissions: ChatPermissions;
/** Date when restrictions will be lifted for the user, unix time. If user is restricted for more than 366 days or less than 30 seconds from the current time, they are considered to be restricted forever */
until_date?: number;
}
export interface ExtraPromoteChatMember {
/** Pass True, if the administrator can change chat title, photo and other settings */
can_change_info?: boolean;
/** Pass True, if the administrator can create channel posts, channels only */
can_post_messages?: boolean;
/** Pass True, if the administrator can edit messages of other users and can pin messages, channels only */
can_edit_messages?: boolean;
/** Pass True, if the administrator can delete messages of other users */
can_delete_messages?: boolean;
/** Pass True, if the administrator can invite new users to the chat */
can_invite_users?: boolean;
/** Pass True, if the administrator can restrict, ban or unban chat members */
can_restrict_members?: boolean;
/** Pass True, if the administrator can pin messages, supergroups only */
can_pin_messages?: boolean;
/** Pass True, if the administrator can add new administrators with a subset of his own privileges or demote administrators that he has promoted, directly or indirectly (promoted by administrators that were appointed by him) */
can_promote_members?: boolean;
}
/*
* This object represents a message.
*/
export interface Message {
/**
* Unique message identifier inside this chat
*/
message_id: number;
/**
* Sender, empty for messages sent to channels
*/
from?: User;
/**
* Date the message was sent in Unix time
*/
date: number;
/**
* Conversation the message belongs to
*/
chat: Chat;
/**
* For forwarded messages, sender of the original message
*/
forward_from?: User;
/**
* For messages forwarded from channels, information about the original channel
*/
forward_from_chat?: Chat;
/**
* For messages forwarded from channels, identifier of the original message
* in the channel
*/
forward_from_message_id?: number;
/**
* For messages forwarded from channels, signature of the post author if present
*/
forward_signature?: string;
/**
* For forwarded messages, date the original message was sent in Unix time
*/
forward_date?: number;
/**
* For replies, 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?: Message;
/**
* Date the message was last edited in Unix time
*/
edit_date?: number;
/**
* The unique identifier of a media message group this message belongs to
*/
media_group_id?: string;
/**
* Signature of the post author for messages in channels
*/
author_signature?: string;
/**
* For text messages, the actual UTF-8 text of the message, 0-4096 characters.
*/
text?: string;
/**
* For text messages, special entities like usernames, URLs, bot commands,
* etc. that appear in the text
*/
entities?: MessageEntity[];
/**
* For messages with a caption, special entities like usernames, URLs, bot
* commands, etc. that appear in the caption
*/
caption_entities?: MessageEntity[];
/**
* Message is an audio file, information about the file
*/
audio?: Audio;
/**
* Message is a general file, information about the file
*/
document?: Document;
/**
* 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 a game, information about the game. More about games »
* @see https://core.telegram.org/bots/api#games
*/
game?: Game;
/**
* Message is a photo, available sizes of the photo
*/
photo?: PhotoSize[];
/**
* Message is a sticker, information about the sticker
*/
sticker?: Sticker;
/**
* Message is a video, information about the video
*/
video?: Video;
/**
* Message is a voice message, information about the file
*/
voice?: Voice;
/**
* Message is a video note, information about the video message
* @see https://telegram.org/blog/video-messages-and-telescope
*/
video_note?: VideoNote;
/**
* Caption for the audio, document, photo, video or voice, 0-200 characters
*/
caption?: string;
/**
* Message is a shared contact, information about the contact
*/
contact?: Contact;
/**
* Message is a shared location, information about the location
*/
location?: Location;
/**
* Message is a venue, information about the venue
*/
venue?: Venue;
/**
* 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;
/**
* The group has been migrated to a supergroup with the specified
* identifier. This number may be greater than 32 bits and some programming
* languages may have difficulty/silent defects in interpreting it. But it
* is smaller than 52 bits, so a signed 64 bit integer or double-precision
* float type are safe for storing this identifier.
*/
migrate_to_chat_id?: number;
/**
* The supergroup has been migrated from a group with the specified
* identifier. This number may be greater than 32 bits and some programming
* languages may have difficulty/silent defects in interpreting it. But it
* is smaller than 52 bits, so a signed 64 bit integer or double-precision
* float type are safe for storing this 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 is itself a reply.
*/
pinned_message?: Message;
/**
* Message is an invoice for a payment, information about the invoice. More
* about payments »
* @see https://core.telegram.org/bots/api#payments
*/
invoice?: Invoice;
/**
* Message is a service message about a successful payment, information
* about the payment. More about payments »
* @see https://core.telegram.org/bots/api#payments
*/
successful_payment?: SuccessfulPayment;
/**
* The domain name of the website on which the user has logged in. More
* about Telegram Login »
* @see https://core.telegram.org/bots/api/widgets/login
*/
connected_website?: string;
/**
* Telegram Passport data
*/
passport_data?: PassportData;
}
export interface ExtraReplyMessage {
/**
* Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message.
*/
parse_mode?: ParseMode;
/**
* Disables link previews for links in this message
*/
disable_web_page_preview?: boolean;
/**
* Sends the message silently. Users will receive a notification with no sound.
*/
disable_notification?: boolean;
/**
* If the message is a reply, ID of the original message
*/
reply_to_message_id?: number;
/**
* Additional interface options. An object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
*/
reply_markup?:
| InlineKeyboardMarkup
| ReplyKeyboardMarkup
| ReplyKeyboardRemove
| ForceReply;
}
export interface ExtraEditMessage extends ExtraReplyMessage {
// no specified properties
}
export interface ExtraAudio extends ExtraReplyMessage {
/**
* Audio caption, 0-1024 characters
*/
caption?: string;
/**
* Duration of the audio in seconds
*/
duration?: number;
/**
* Performer
*/
performer?: string;
/**
* Track name
*/
title?: string;
/**
* Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side.
* The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 320.
* Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file,
* so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>.
*/
thumb?: InputFile;
/**
* Does not exist, see https://core.telegram.org/bots/api#sendaudio
*/
disable_web_page_preview?: never;
}
export interface ExtraDocument extends ExtraReplyMessage {
/**
* Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side.
* The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 320.
* Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file,
* so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>.
*/
thumb?: InputFile;
/**
* Document caption (may also be used when resending documents by file_id), 0-1024 characters
*/
caption?: string;
/**
* Does not exist, see https://core.telegram.org/bots/api#senddocument
*/
disable_web_page_preview?: never;
}
export interface ExtraGame extends ExtraReplyMessage {
/**
* Inline keyboard. If empty, one ‘Play game_title’ button will be shown. If not empty, the first button must launch the game.
*/
reply_markup?: InlineKeyboardMarkup;
/**
* Does not exist, see https://core.telegram.org/bots/api#sendgame
*/
disable_web_page_preview?: never;
/**
* Does not exist, see https://core.telegram.org/bots/api#sendgame
*/
parse_mode?: never;
}
export interface ExtraInvoice extends ExtraReplyMessage {
/**
* Inline keyboard. If empty, one 'Pay total price' button will be shown. If not empty, the first button must be a Pay button.
*/
reply_markup?: InlineKeyboardMarkup;
/**
* Does not exist, see https://core.telegram.org/bots/api#sendinvoice
*/
disable_web_page_preview?: never;
/**
* Does not exist, see https://core.telegram.org/bots/api#sendinvoice
*/
parse_mode?: never;
}
export interface ExtraLocation extends ExtraReplyMessage {
/**
* Period in seconds for which the location will be updated (should be between 60 and 86400)
*/
live_period?: number;
/**
* Does not exist, see https://core.telegram.org/bots/api#sendlocation
*/
disable_web_page_preview?: never;
/**
* Does not exist, see https://core.telegram.org/bots/api#sendlocation
*/
parse_mode?: never;
}
export interface ExtraPhoto extends ExtraReplyMessage {
/**
* Photo caption (may also be used when resending photos by file_id), 0-1024 characters
*/
caption?: string;
/**
* Does not exist, see https://core.telegram.org/bots/api#sendphoto
*/
disable_web_page_preview?: never;
}
export interface ExtraMediaGroup extends ExtraReplyMessage {
/**
* Does not exist, see https://core.telegram.org/bots/api#sendmediagroup
*/
disable_web_page_preview?: never;
/**
* Does not exist, see https://core.telegram.org/bots/api#sendmediagroup
*/
parse_mode?: never;
/**
* Does not exist, see https://core.telegram.org/bots/api#sendmediagroup
*/
reply_markup?: never;
}
export interface ExtraAnimation extends ExtraReplyMessage {
/**
* Animation caption (may also be used when resending animation by file_id), 0-200 characters
*/
caption?: string;
}
export interface ExtraSticker extends ExtraReplyMessage {
/**
* Does not exist, see https://core.telegram.org/bots/api#sendsticker
*/
disable_web_page_preview?: never;
/**
* Does not exist, see https://core.telegram.org/bots/api#sendsticker
*/
parse_mode?: never;
}
export interface ExtraVideo extends ExtraReplyMessage {
/**
* Duration of sent video in seconds
*/
duration?: number;
/**
* Video width
*/
width?: number;
/**
* Video height
*/
height?: number;
/**
* Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side.
* The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 320.
* Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file,
* so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>.
*/
thumb?: InputFile;
/**
* Video caption (may also be used when resending videos by file_id), 0-1024 characters
*/
caption?: string;
/**
* Pass True, if the uploaded video is suitable for streaming
*/
supports_streaming?: boolean;
/**
* Does not exist, see https://core.telegram.org/bots/api#sendvideo
*/
disable_web_page_preview?: never;
}
export interface ExtraVideoNote extends ExtraReplyMessage {
/**
* Duration of sent video in seconds
*/
duration?: number;
/**
* Video width and height, i.e. diameter of the video message
*/
length?: number;
/**
* Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side.
* The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 320.
* Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file,
* so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>.
*/
thumb?: InputFile;
}
export interface ExtraVoice extends ExtraReplyMessage {
/**
* Voice message caption, 0-1024 characters
*/
caption?: string;
/**
* Duration of the voice message in seconds
*/
duration?: number;
/**
* Does not exist, see https://core.telegram.org/bots/api#sendvoice
*/
disable_web_page_preview?: never;
}
export interface ExtraDice extends ExtraReplyMessage {
/**
* Does not exist, see https://core.telegram.org/bots/api#senddice
*/
parse_mode?: never;
/**
* Does not exist, see https://core.telegram.org/bots/api#senddice
*/
disable_web_page_preview?: never;
}
export interface ExtraPoll {
/** True, if the poll needs to be anonymous, defaults to True */
is_anonymous?: boolean;
/** True, if the poll allows multiple answers, ignored for polls in quiz mode, defaults to False */
allows_multiple_answers?: boolean;
/** 0-based identifier of the correct answer option, required for polls in quiz mode */
correct_option_id?: number;
/** Pass True, if the poll needs to be immediately closed. This can be useful for poll preview. */
is_closed?: boolean;
/** Sends the message silently. Users will receive a notification with no sound. */
disable_notification?: boolean;
/** If the message is a reply, ID of the original message */
reply_to_message_id?: number;
/** Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user. */
reply_markup?:
| InlineKeyboardMarkup
| ReplyKeyboardMarkup
| ReplyKeyboardRemove
| ForceReply;
}
export interface ExtraStopPoll {
/** A JSON-serialized object for a new message inline keyboard. */
reply_markup?: InlineKeyboardMarkup;
}
export interface IncomingMessage extends Message {
audio?: Audio;
entities?: MessageEntity[];
dice?: Dice;
caption?: string;
document?: Document;
game?: Game;
photo?: PhotoSize[];
animation?: Animation;
sticker?: Sticker;
video?: Video;
video_note?: VideoNote;
contact?: Contact;
location?: Location;
venue?: Venue;
pinned_message?: Message;
invoice?: Invoice;
successful_payment?: SuccessfulPayment;
}
export interface MessageAudio extends Message {
audio: Audio;
}
export interface MessageDocument extends Message {
document: Document;
}
export interface MessageGame extends Message {
game: Game;
}
export interface MessageInvoice extends Message {
invoice: Invoice;
}
export interface MessageLocation extends Message {
location: Location;
}
export interface MessagePhoto extends Message {
photo: PhotoSize[];
}
export interface MessageAnimation extends Message {
animation: Animation;
}
export interface MessageSticker extends Message {
sticker: Sticker;
}
export interface MessageVideo extends Message {
video: Video;
}
export interface MessageVideoNote extends Message {
video_note: VideoNote;
}
export interface MessageVoice extends Message {
voice: Voice;
}
export interface MessageDice extends Message {
dice: Dice;
}
export interface MessagePoll extends Message {
poll: Poll;
}
export interface NewInvoiceParameters {
/**
* Product name, 1-32 characters
*/
title: string;
/**
* Product description, 1-255 characters
*/
description: string;
/**
* Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes.
*/
payload: string;
/**
* Payments provider token, obtained via Botfather
*/
provider_token: string;
/**
* Unique deep-linking parameter that can be used to generate this invoice when used as a start parameter
*/
start_parameter: string;
/**
* Three-letter ISO 4217 currency code, see more on currencies
*/
currency: string;
/**
* Price breakdown, a list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.)
*/
prices: LabeledPrice[];
/**
* URL of the product photo for the invoice. Can be a photo of the goods or a marketing image for a service. People like it better when they see what they are paying for.
*/
photo_url?: string;
/**
* Photo size
*/
photo_size?: number;
/**
* Photo width
*/
photo_width?: number;
/**
* Photo height
*/
photo_height?: number;
/**
* Pass True, if you require the user's full name to complete the order
*/
need_name?: true;
/**
* Pass True, if you require the user's phone number to complete the order
*/
need_phone_number?: true;
/**
* Pass True, if you require the user's email to complete the order
*/
need_email?: true;
/**
* Pass True, if you require the user's shipping address to complete the order
*/
need_shipping_address?: true;
/**
* Pass True, if the final price depends on the shipping method
*/
is_flexible?: true;
}
export interface ExtraAnswerInlineQuery {
/**
* The maximum amount of time in seconds that the result of the inline query may be cached on the server. Defaults to 300.
*/
cache_time?: number;
/**
* Pass True, if results may be cached on the server side only for the user that sent the query. By default, results may be returned to any user who sends the same query
*/
is_personal?: boolean;
/**
* Pass the offset that a client should send in the next query with the same text to receive more results. Pass an empty string if there are no more results or if you don‘t support pagination. Offset length can’t exceed 64 bytes.
*/
next_offset?: string;
/**
* If passed, clients will display a button with specified text that switches the user to a private chat with the bot and sends the bot a start message with the parameter switch_pm_parameter
*/
switch_pm_text?: string;
/**
* Deep-linking parameter for the /start message sent to the bot when user presses the switch button. 1-64 characters, only A-Z, a-z, 0-9, _ and - are allowed.
*/
switch_pm_parameter?: string;
}
/**
* This object represents a bot command
*/
export interface BotCommand {
/**
* Text of the command, 1-32 characters. Can contain only lowercase English letters, digits and underscores.
*/
command: string;
/**
* Description of the command, 3-256 characters.
*/
description: string;
}
/**
* This object represents a dice with random value from 1 to 6. (Yes, we're aware of the “proper” singular of die. But it's awkward, and we decided to help it change. One dice at a time!)
*/
export interface Dice {
/**
* Value of the dice, 1-6
*/
value: number;
}
export interface PollOption {
/** Option text, 1-100 characters */
text: string;
/** Number of users that voted for this option */
voter_count: number;
}
export interface PollAnswer {
/** Unique poll identifier */
poll_id: string;
/** The user, who changed the answer to the poll */
user: User;
/** 0-based identifiers of answer options, chosen by the user. May be empty if the user retracted their vote. */
option_ids: number[];
}
export interface Poll {
/** Unique poll identifier */
id: string;
/** Poll question, 1-255 characters */
question: string;
/** List of poll options */
options: PollOption[];
/** Total number of users that voted in the poll */
total_voter_count: number;
/** True, if the poll is closed */
is_closed: boolean;
/** True, if the poll is anonymous */
is_anonymous: boolean;
/** Poll type, currently can be “regular” or “quiz” */
type: 'regular' | 'quiz';
/** True, if the poll allows multiple answers */
allows_multiple_answers: boolean;
/** 0-based identifier of the correct answer option. Available only for polls in the quiz mode, which are closed, or was sent (not forwarded) by the bot or to the private chat with the bot. */
correct_option_id?: number;
}
export type EntityType =
| 'mention'
| 'hashtag'
| 'cashtag'
| 'bot_command'
| 'url'
| 'email'
| 'phone_number'
| 'bold'
| 'italic'
| 'underline'
| 'code'
| 'pre'
| 'text_link'
| 'text_mention';
/**
* This object represents one special entity in a text message. For
* example, hashtags, usernames, URLs, etc.
*/
export interface MessageEntity {
/**
* Type of the entity. Can be mention (@username), hashtag, cashtag,
* bot_command, url, email, phone_number, bold (bold text), italic (italic
* text), code (monowidth string), pre (monowidth block), text_link (for
* clickable text URLs), text_mention (for users without usernames)
* @see https://telegram.org/blog/edit#new-mentions
*/
type: EntityType;
/**
* 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;
/**
* For “text_link” only, url that will be opened after user taps on the text
*/
url?: string;
/**
* For “text_mention” only, the mentioned user
*/
user?: User;
}
/**
* A placeholder, currently holds no information. Use BotFather to set up
* your game.
*/
export interface CallbackGame {}
/**
* Contains information about Telegram Passport data shared with the bot by
* the user.
*/
export interface PassportData {
/**
*/
data: EncryptedPassportElement[];
/**
*/
credentials: EncryptedCredentials;
}
/**
*/
export interface EncryptedPassportElement {}
/**
* Contains data required for decrypting and authenticating
* EncryptedPassportElement. See the Telegram Passport Documentation for a
* complete description of the data decryption and authentication processes.
*/
export interface EncryptedCredentials {}
/**
* This object represents the content of a message to be sent as a result
* of an inline query.
*/
export type InputMessageContent =
| InputTextMessageContent
| InputLocationMessageContent
| InputVenueMessageContent
| InputContactMessageContent;
/**
* This object represents the content of a media message to be sent.
*/
export type InputMedia = InputMediaPhoto | InputMediaVideo;
/**
* This object represents an incoming update.At most one of the optional
* parameters can be present in any given update.
* @see https://core.telegram.org/bots/api#available-types
*/
export interface Update {
/**
* The update‘s unique identifier. Update identifiers start from a certain
* positive number and increase sequentially. This ID becomes especially
* handy if you’re using Webhooks, since it allows you to ignore repeated
* updates or to restore the correct update sequence, should they get out
* of order. If there are no new updates for at least a week, then
* identifier of the next update will be chosen randomly instead of sequentially.
* @see https://core.telegram.org/bots/api#setwebhook
*/
update_id: number;
/**
* New incoming message of any kind — text, photo, sticker, etc.
*/
message?: Message;
/**
* New version of a message that is known to the bot and was edited
*/
edited_message?: Message;
/**
* New incoming channel post of any kind — text, photo, sticker, etc.
*/
channel_post?: Message;
/**
* New version of a channel post that is known to the bot and was edited
*/
edited_channel_post?: Message;
/**
* New incoming inline query
* @see https://core.telegram.org/bots/api#inline-mode
*/
inline_query?: InlineQuery;
/**
* The result of an inline query that was chosen by a user and sent to
* their chat partner. Please see our documentation on the feedback
* collecting for details on how to enable these updates for your bot.
* @see https://core.telegram.org/bots/api#inline-mode
* @see https://core.telegram.org/bots/api/bots/inline#collecting-feedback
*/
chosen_inline_result?: ChosenInlineResult;
/**
* New incoming callback query
*/
callback_query?: CallbackQuery;
/**
* New incoming shipping query. Only for invoices with flexible price
*/
shipping_query?: ShippingQuery;
/**
* New incoming pre-checkout query. Contains full information about checkout
*/
pre_checkout_query?: PreCheckoutQuery;
}
/**
* Contains information about the current status of a webhook.
*/
export interface WebhookInfo {
/**
* Webhook URL, may be empty if webhook is not set up
*/
url: string;
/**
* True, if a custom certificate was provided for webhook certificate checks
*/
has_custom_certificate: boolean;
/**
* Number of updates awaiting delivery
*/
pending_update_count: number;
/**
* Unix time for the most recent error that happened when trying to deliver
* an update via webhook
*/
last_error_date?: number;
/**
* Error message in human-readable format for the most recent error that
* happened when trying to deliver an update via webhook
*/
last_error_message?: string;
/**
* Maximum allowed number of simultaneous HTTPS connections to the webhook
* for update delivery
*/
max_connections?: number;
/**
* A list of update types the bot is subscribed to. Defaults to all update types
*/
allowed_updates?: string[];
}
/**
* This object represents a Telegram user or bot.
*/
export interface User {
/**
* Unique identifier for this user or bot
*/
id: number;
/**
* True, if this user is a bot
*/
is_bot: boolean;
/**
* User‘s or bot’s first name
*/
first_name: string;
/**
* User‘s or bot’s last name
*/
last_name?: string;
/**
* User‘s or bot’s username
*/
username?: string;
/**
* IETF language tag of the user's language
* @see https://en.wikipedia.org/wiki/IETF_language_tag
*/
language_code?: string;
}
/**
* This object represents one size of a photo or a file / sticker thumbnail.
* @see https://core.telegram.org/bots/api#document
* @see https://core.telegram.org/bots/api#sticker
*/
export interface PhotoSize {
/**
* Unique identifier for this file
*/
file_id: string;
/**
* Photo width
*/
width: number;
/**
* Photo height
*/
height: number;
/**
* File size
*/
file_size?: number;
}
/**
* This object represents an audio file to be treated as music by the
* Telegram clients.
*/
export interface Audio {
/**
* Unique identifier for this file
*/
file_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;
/**
* MIME type of the file as defined by sender
*/
mime_type?: string;
/**
* File size
*/
file_size?: number;
/**
* Thumbnail of the album cover to which the music file belongs
*/
thumb?: PhotoSize;
}
/**
* This object represents a general file (as opposed to photos, voice
* messages and audio files).
* @see https://core.telegram.org/bots/api#photosize
* @see https://core.telegram.org/bots/api#voice
* @see https://core.telegram.org/bots/api#audio
*/
export interface Document {
/**
* Unique file identifier
*/
file_id: string;
/**
* Document thumbnail as defined by sender
*/
thumb?: PhotoSize;
/**
* Original filename as defined by sender
*/
file_name?: string;
/**
* MIME type of the file as defined by sender
*/
mime_type?: string;
/**
* File size
*/
file_size?: number;
}
/**
* This object represents a video file.
*/
export interface Video {
/**
* Unique identifier for this file
*/
file_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
*/
thumb?: PhotoSize;
/**
* Mime type of a file as defined by sender
*/
mime_type?: string;
/**
* File size
*/
file_size?: number;
}
/**
* This object represents an animation file (GIF or H.264/MPEG-4 AVC video
* without sound).
*/
export interface Animation {
/**
* Unique file identifier
*/
file_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
*/
thumb?: 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
*/
file_size?: number;
}
/**
* This object represents a voice note.
*/
export interface Voice {
/**
* Unique identifier for this file
*/
file_id: string;
/**
* Duration of the audio in seconds as defined by sender
*/
duration: number;
/**
* MIME type of the file as defined by sender
*/
mime_type?: string;
/**
* File size
*/
file_size?: number;
}
/**
* This object represents a video message (available in Telegram apps as of v.4.0).
* @see https://telegram.org/blog/video-messages-and-telescope
*/
export interface VideoNote {
/**
* Unique identifier for this file
*/
file_id: string;
/**
* Video width and height as defined by sender
*/
length: number;
/**
* Duration of the video in seconds as defined by sender
*/
duration: number;
/**
* Video thumbnail
*/
thumb?: PhotoSize;
/**
* File size
*/
file_size?: number;
}
/**
* This object represents a phone contact.
*/
export interface Contact {
/**
* Contact's phone number
*/
phone_number: string;
/**
* Contact's first name
*/
first_name: string;
/**
* Contact's last name
*/
last_name?: string;
/**
* Contact's user identifier in Telegram
*/
user_id?: number;
/**
* Additional data about the contact in the form of a vCard
* @see https://en.wikipedia.org/wiki/VCard
*/
vcard?: string;
}
/**
* This object represents a point on the map.
*/
export interface Location {
/**
* Longitude as defined by sender
*/
longitude: number;
/**
* Latitude as defined by sender
*/
latitude: number;
}
/**
* This object represents a venue.
*/
export interface Venue {
/**
* Venue location
*/
location: Location;
/**
* Name of the venue
*/
title: string;
/**
* Address of the venue
*/
address: string;
/**
* Foursquare identifier of the venue
*/
foursquare_id?: string;
/**
* Foursquare type of the venue. (For example,
* “arts_entertainment/default”, “arts_entertainment/aquarium” or “food/icecream”.)
*/
foursquare_type?: string;
}
/**
* This object represent a user's profile pictures.
*/
export interface UserProfilePhotos {
/**
* Total number of profile pictures the target user has
*/
total_count: number;
/**
* Requested profile pictures (in up to 4 sizes each)
*/
photos: PhotoSize[][];
}
/**
* This object represents a file ready to be downloaded. The file can be
* downloaded via the link
* https://api.telegram.org/file/bot<token>/<file_path>. It is guaranteed
* that the link will be valid for at least 1 hour. When the link expires,
* a new one can be requested by calling getFile.
* @see https://core.telegram.org/bots/api#getfile
*/
export interface File {
/**
* Unique identifier for this file
*/
file_id: string;
/**
* File size, if known
*/
file_size?: number;
/**
* File path. Use https://api.telegram.org/file/bot<token>/<file_path> to
* get the file.
*/
file_path?: string;
}
/**
* This object represents a custom keyboard with reply options (see
* Introduction to bots for details and examples).
* @see https://core.telegram.org/bots#keyboards
*/
export interface ReplyKeyboardMarkup {
/**
* Array of button rows, each represented by an Array of KeyboardButton objects
* @see https://core.telegram.org/bots/api#keyboardbutton
*/
keyboard: KeyboardButton[][];
/**
* Requests clients to resize the keyboard vertically for optimal fit
* (e.g., make the keyboard smaller if there are just two rows of buttons).
* Defaults to false, in which case the custom keyboard is always of the
* same height as the app's standard keyboard.
*/
resize_keyboard?: boolean;
/**
* Requests clients to hide the keyboard as soon as it's been used. The
* keyboard will still be available, but clients will automatically display
* the usual letter-keyboard in the chat – the user can press a special
* button in the input field to see the custom keyboard again. Defaults to false.
*/
one_time_keyboard?: boolean;
/**
* Use this parameter if you want to show the keyboard to specific users
* only. Targets: 1) users that are @mentioned in the text of the Message
* object; 2) if the bot's message is a reply (has reply_to_message_id),
* sender of the original message.Example: A user requests to change the
* bot‘s language, bot replies to the request with a keyboard to select the
* new language. Other users in the group don’t see the keyboard.
* @see https://core.telegram.org/bots/api#message
*/
selective?: boolean;
}
/**
* This object represents one button of the reply keyboard. For simple text
* buttons String can be used instead of this object to specify text of the
* button. Optional fields are mutually exclusive.
*/
export interface KeyboardButton {
/**
* Text of the button. If none of the optional fields are used, it will be
* sent as a message when the button is pressed
*/
text: string;
/**
* If True, the user's phone number will be sent as a contact when the
* button is pressed. Available in private chats only
*/
request_contact?: boolean;
/**
* If True, the user's current location will be sent when the button is
* pressed. Available in private chats only
*/
request_location?: boolean;
}
/**
* Upon receiving a message with this object, Telegram clients will remove
* the current custom keyboard and display the default letter-keyboard. By
* default, custom keyboards are displayed until a new keyboard is sent by
* a bot. An exception is made for one-time keyboards that are hidden
* immediately after the user presses a button (see ReplyKeyboardMarkup).
* @see https://core.telegram.org/bots/api#replykeyboardmarkup
*/
export interface ReplyKeyboardRemove {
/**
* Requests clients to remove the custom keyboard (user will not be able to
* summon this keyboard; if you want to hide the keyboard from sight but
* keep it accessible, use one_time_keyboard in ReplyKeyboardMarkup)
* @see https://core.telegram.org/bots/api#replykeyboardmarkup
*/
remove_keyboard: true;
/**
* Use this parameter if you want to remove the keyboard for specific users
* only. Targets: 1) users that are @mentioned in the text of the Message
* object; 2) if the bot's message is a reply (has reply_to_message_id),
* sender of the original message.Example: A user votes in a poll, bot
* returns confirmation message in reply to the vote and removes the
* keyboard for that user, while still showing the keyboard with poll
* options to users who haven't voted yet.
* @see https://core.telegram.org/bots/api#message
*/
selective?: boolean;
}
/**
* This object represents an inline keyboard that appears right next to the
* message it belongs to.
* @see https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
*/
export interface InlineKeyboardMarkup {
/**
* Array of button rows, each represented by an Array of
* InlineKeyboardButton objects
* @see https://core.telegram.org/bots/api#inlinekeyboardbutton
*/
inline_keyboard: InlineKeyboardButton[][];
}
/**
* This object represents one button of an inline keyboard. You must use
* exactly one of the optional fields.
*/
export interface InlineKeyboardButton {
/**
* Label text on the button
*/
text: string;
/**
* HTTP or tg:// url to be opened when button is pressed
*/
url?: string;
/**
* Data to be sent in a callback query to the bot when button is pressed,
* 1-64 bytes
* @see https://core.telegram.org/bots/api#callbackquery
*/
callback_data?: string;
/**
* If set, pressing the button will prompt the user to select one of their
* chats, open that chat and insert the bot‘s username and the specified
* inline query in the input field. Can be empty, in which case just the
* bot’s username will be inserted.Note: This offers an easy way for users
* to start using your bot in inline mode when they are currently in a
* private chat with it. Especially useful when combined with switch_pm…
* actions – in this case the user will be automatically returned to the
* chat they switched from, skipping the chat selection screen.
* @see https://core.telegram.org/bots/api/bots/inline
* @see https://core.telegram.org/bots/api#answerinlinequery
*/
switch_inline_query?: string;
/**
* If set, pressing the button will insert the bot‘s username and the
* specified inline query in the current chat's input field. Can be empty,
* in which case only the bot’s username will be inserted.This offers a
* quick way for the user to open your bot in inline mode in the same chat
* – good for selecting something from multiple options.
*/
switch_inline_query_current_chat?: string;
/**
* Description of the game that will be launched when the user presses the
* button.NOTE: This type of button must always be the first button in the
* first row.
*/
callback_game?: CallbackGame;
/**
* Specify True, to send a Pay button.NOTE: This type of button must always
* be the first button in the first row.
* @see https://core.telegram.org/bots/api#payments
*/
pay?: boolean;
}
/**
* This object represents an incoming callback query from a callback button
* in an inline keyboard. If the button that originated the query was
* attached to a message sent by the bot, the field message will be
* present. If the button was attached to a message sent via the bot (in
* inline mode), the field inline_message_id will be present. Exactly one
* of the fields data or game_short_name will be present.
* @see https://core.telegram.org/bots/api/bots#inline-keyboards-and-on-the-fly-updating
* @see https://core.telegram.org/bots/api#inline-mode
*/
export interface CallbackQuery {
/**
* Unique identifier for this query
*/
id: string;
/**
* Sender
*/
from: User;
/**
* Message with the callback button that originated the query. Note that
* message content and message date will not be available if the message is
* too old
*/
message?: Message;
/**
* Identifier of the message sent via the bot in inline mode, that
* originated the query.
*/
inline_message_id?: string;
/**
* Global identifier, uniquely corresponding to the chat to which the
* message with the callback button was sent. Useful for high scores in games.
* @see https://core.telegram.org/bots/api#games
*/
chat_instance: string;
/**
* Data associated with the callback button. Be aware that a bad client can
* send arbitrary data in this field.
*/
data?: string;
/**
* Short name of a Game to be returned, serves as the unique identifier for
* the game
* @see https://core.telegram.org/bots/api#gam