UNPKG

telegram-bot-api-lightweight-client

Version:

Lightweight Telegram Bot API client. Exports only minimal Fetch call. Fully compatible with AWS LLRT.

1,780 lines (1,779 loc) 120 kB
/** * Represents the default response object. */ export type Response = { ok: boolean; }; /** * Request was successful, the result is returned. */ export type Success = Response & { result: { [key: string]: unknown; }; }; /** * Request was unsuccessful, so an error occurred. */ export type Error = Response & { error_code: number; description: string; parameters?: ResponseParameters; }; /** * This object represents an incoming update.At most one of the optional parameters can be present in any given update. */ export type Update = { update_id: number; message?: Message; edited_message?: Message; channel_post?: Message; edited_channel_post?: Message; business_connection?: BusinessConnection; business_message?: Message; edited_business_message?: Message; deleted_business_messages?: BusinessMessagesDeleted; message_reaction?: MessageReactionUpdated; message_reaction_count?: MessageReactionCountUpdated; inline_query?: InlineQuery; chosen_inline_result?: ChosenInlineResult; callback_query?: CallbackQuery; shipping_query?: ShippingQuery; pre_checkout_query?: PreCheckoutQuery; purchased_paid_media?: PaidMediaPurchased; poll?: Poll; poll_answer?: PollAnswer; my_chat_member?: ChatMemberUpdated; chat_member?: ChatMemberUpdated; chat_join_request?: ChatJoinRequest; chat_boost?: ChatBoostUpdated; removed_chat_boost?: ChatBoostRemoved; }; /** * Describes the current status of a webhook. */ export type WebhookInfo = { url: string; has_custom_certificate: boolean; pending_update_count: number; ip_address?: string; last_error_date?: number; last_error_message?: string; last_synchronization_error_date?: number; max_connections?: number; allowed_updates?: Array<string>; }; /** * This object represents a Telegram user or bot. */ export type User = { id: number; is_bot: boolean; first_name: string; last_name?: string; username?: string; language_code?: string; is_premium?: boolean; added_to_attachment_menu?: boolean; can_join_groups?: boolean; can_read_all_group_messages?: boolean; supports_inline_queries?: boolean; can_connect_to_business?: boolean; has_main_web_app?: boolean; }; /** * This object represents a chat. */ export type Chat = { id: number; type: string; title?: string; username?: string; first_name?: string; last_name?: string; is_forum?: boolean; }; /** * This object contains full information about a chat. */ export type ChatFullInfo = { id: number; type: string; title?: string; username?: string; first_name?: string; last_name?: string; is_forum?: boolean; accent_color_id: number; max_reaction_count: number; photo?: ChatPhoto; active_usernames?: Array<string>; birthdate?: Birthdate; business_intro?: BusinessIntro; business_location?: BusinessLocation; business_opening_hours?: BusinessOpeningHours; personal_chat?: Chat; available_reactions?: Array<ReactionType>; background_custom_emoji_id?: string; profile_accent_color_id?: number; profile_background_custom_emoji_id?: string; emoji_status_custom_emoji_id?: string; emoji_status_expiration_date?: number; bio?: string; has_private_forwards?: boolean; has_restricted_voice_and_video_messages?: boolean; join_to_send_messages?: boolean; join_by_request?: boolean; description?: string; invite_link?: string; pinned_message?: Message; permissions?: ChatPermissions; accepted_gift_types: AcceptedGiftTypes; can_send_paid_media?: boolean; slow_mode_delay?: number; unrestrict_boost_count?: number; message_auto_delete_time?: number; has_aggressive_anti_spam_enabled?: boolean; has_hidden_members?: boolean; has_protected_content?: boolean; has_visible_history?: boolean; sticker_set_name?: string; can_set_sticker_set?: boolean; custom_emoji_sticker_set_name?: string; linked_chat_id?: number; location?: ChatLocation; }; /** * This object represents a message. */ export type Message = { message_id: number; message_thread_id?: number; from?: User; sender_chat?: Chat; sender_boost_count?: number; sender_business_bot?: User; date: number; business_connection_id?: string; chat: Chat; forward_origin?: MessageOrigin; is_topic_message?: boolean; is_automatic_forward?: boolean; reply_to_message?: Message; external_reply?: ExternalReplyInfo; quote?: TextQuote; reply_to_story?: Story; via_bot?: User; edit_date?: number; has_protected_content?: boolean; is_from_offline?: boolean; media_group_id?: string; author_signature?: string; paid_star_count?: number; text?: string; entities?: Array<MessageEntity>; link_preview_options?: LinkPreviewOptions; effect_id?: string; animation?: Animation; audio?: Audio; document?: Document; paid_media?: PaidMediaInfo; photo?: Array<PhotoSize>; sticker?: Sticker; story?: Story; video?: Video; video_note?: VideoNote; voice?: Voice; caption?: string; caption_entities?: Array<MessageEntity>; show_caption_above_media?: boolean; has_media_spoiler?: boolean; contact?: Contact; dice?: Dice; game?: Game; poll?: Poll; venue?: Venue; location?: Location; new_chat_members?: Array<User>; left_chat_member?: User; new_chat_title?: string; new_chat_photo?: Array<PhotoSize>; delete_chat_photo?: boolean; group_chat_created?: boolean; supergroup_chat_created?: boolean; channel_chat_created?: boolean; message_auto_delete_timer_changed?: MessageAutoDeleteTimerChanged; migrate_to_chat_id?: number; migrate_from_chat_id?: number; pinned_message?: MaybeInaccessibleMessage; invoice?: Invoice; successful_payment?: SuccessfulPayment; refunded_payment?: RefundedPayment; users_shared?: UsersShared; chat_shared?: ChatShared; gift?: GiftInfo; unique_gift?: UniqueGiftInfo; connected_website?: string; write_access_allowed?: WriteAccessAllowed; passport_data?: PassportData; proximity_alert_triggered?: ProximityAlertTriggered; boost_added?: ChatBoostAdded; chat_background_set?: ChatBackground; forum_topic_created?: ForumTopicCreated; forum_topic_edited?: ForumTopicEdited; forum_topic_closed?: ForumTopicClosed; forum_topic_reopened?: ForumTopicReopened; general_forum_topic_hidden?: GeneralForumTopicHidden; general_forum_topic_unhidden?: GeneralForumTopicUnhidden; giveaway_created?: GiveawayCreated; giveaway?: Giveaway; giveaway_winners?: GiveawayWinners; giveaway_completed?: GiveawayCompleted; paid_message_price_changed?: PaidMessagePriceChanged; video_chat_scheduled?: VideoChatScheduled; video_chat_started?: VideoChatStarted; video_chat_ended?: VideoChatEnded; video_chat_participants_invited?: VideoChatParticipantsInvited; web_app_data?: WebAppData; reply_markup?: InlineKeyboardMarkup; }; /** * This object represents a unique message identifier. */ export type MessageId = { message_id: number; }; /** * This object describes a message that was deleted or is otherwise inaccessible to the bot. */ export type InaccessibleMessage = { chat: Chat; message_id: number; date: number; }; /** * This object describes a message that can be inaccessible to the bot. It can be one of */ export type MaybeInaccessibleMessage = Message | InaccessibleMessage; /** * This object represents one special entity in a text message. For example, hashtags, usernames, URLs, etc. */ export type MessageEntity = { type: string; offset: number; length: number; url?: string; user?: User; language?: string; custom_emoji_id?: string; }; /** * This object contains information about the quoted part of a message that is replied to by the given message. */ export type TextQuote = { text: string; entities?: Array<MessageEntity>; position: number; is_manual?: boolean; }; /** * This object contains information about a message that is being replied to, which may come from another chat or forum topic. */ export type ExternalReplyInfo = { origin: MessageOrigin; chat?: Chat; message_id?: number; link_preview_options?: LinkPreviewOptions; animation?: Animation; audio?: Audio; document?: Document; paid_media?: PaidMediaInfo; photo?: Array<PhotoSize>; sticker?: Sticker; story?: Story; video?: Video; video_note?: VideoNote; voice?: Voice; has_media_spoiler?: boolean; contact?: Contact; dice?: Dice; game?: Game; giveaway?: Giveaway; giveaway_winners?: GiveawayWinners; invoice?: Invoice; location?: Location; poll?: Poll; venue?: Venue; }; /** * Describes reply parameters for the message that is being sent. */ export type ReplyParameters = { message_id: number; chat_id?: number | string; allow_sending_without_reply?: boolean; quote?: string; quote_parse_mode?: string; quote_entities?: Array<MessageEntity>; quote_position?: number; }; /** * This object describes the origin of a message. It can be one of */ export type MessageOrigin = MessageOriginUser | MessageOriginHiddenUser | MessageOriginChat | MessageOriginChannel; /** * The message was originally sent by a known user. */ export type MessageOriginUser = { type: string; date: number; sender_user: User; }; /** * The message was originally sent by an unknown user. */ export type MessageOriginHiddenUser = { type: string; date: number; sender_user_name: string; }; /** * The message was originally sent on behalf of a chat to a group chat. */ export type MessageOriginChat = { type: string; date: number; sender_chat: Chat; author_signature?: string; }; /** * The message was originally sent to a channel chat. */ export type MessageOriginChannel = { type: string; date: number; chat: Chat; message_id: number; author_signature?: string; }; /** * This object represents one size of a photo or a file / sticker thumbnail. */ export type PhotoSize = { file_id: string; file_unique_id: string; width: number; height: number; file_size?: number; }; /** * This object represents an animation file (GIF or H.264/MPEG-4 AVC video without sound). */ export type Animation = { file_id: string; file_unique_id: string; width: number; height: number; duration: number; thumbnail?: PhotoSize; file_name?: string; mime_type?: string; file_size?: number; }; /** * This object represents an audio file to be treated as music by the Telegram clients. */ export type Audio = { file_id: string; file_unique_id: string; duration: number; performer?: string; title?: string; file_name?: string; mime_type?: string; file_size?: number; thumbnail?: PhotoSize; }; /** * This object represents a general file (as opposed to photos, voice messages and audio files). */ export type Document = { file_id: string; file_unique_id: string; thumbnail?: PhotoSize; file_name?: string; mime_type?: string; file_size?: number; }; /** * This object represents a story. */ export type Story = { chat: Chat; id: number; }; /** * This object represents a video file. */ export type Video = { file_id: string; file_unique_id: string; width: number; height: number; duration: number; thumbnail?: PhotoSize; cover?: Array<PhotoSize>; start_timestamp?: number; file_name?: string; mime_type?: string; file_size?: number; }; /** * This object represents a video message (available in Telegram apps as of v.4.0). */ export type VideoNote = { file_id: string; file_unique_id: string; length: number; duration: number; thumbnail?: PhotoSize; file_size?: number; }; /** * This object represents a voice note. */ export type Voice = { file_id: string; file_unique_id: string; duration: number; mime_type?: string; file_size?: number; }; /** * Describes the paid media added to a message. */ export type PaidMediaInfo = { star_count: number; paid_media: Array<PaidMedia>; }; /** * This object describes paid media. Currently, it can be one of */ export type PaidMedia = PaidMediaPreview | PaidMediaPhoto | PaidMediaVideo; /** * The paid media isn't available before the payment. */ export type PaidMediaPreview = { type: string; width?: number; height?: number; duration?: number; }; /** * The paid media is a photo. */ export type PaidMediaPhoto = { type: string; photo: Array<PhotoSize>; }; /** * The paid media is a video. */ export type PaidMediaVideo = { type: string; video: Video; }; /** * This object represents a phone contact. */ export type Contact = { phone_number: string; first_name: string; last_name?: string; user_id?: number; vcard?: string; }; /** * This object represents an animated emoji that displays a random value. */ export type Dice = { emoji: string; value: number; }; /** * This object contains information about one answer option in a poll. */ export type PollOption = { text: string; text_entities?: Array<MessageEntity>; voter_count: number; }; /** * This object contains information about one answer option in a poll to be sent. */ export type InputPollOption = { text: string; text_parse_mode?: string; text_entities?: Array<MessageEntity>; }; /** * This object represents an answer of a user in a non-anonymous poll. */ export type PollAnswer = { poll_id: string; voter_chat?: Chat; user?: User; option_ids: Array<number>; }; /** * This object contains information about a poll. */ export type Poll = { id: string; question: string; question_entities?: Array<MessageEntity>; options: Array<PollOption>; total_voter_count: number; is_closed: boolean; is_anonymous: boolean; type: string; allows_multiple_answers: boolean; correct_option_id?: number; explanation?: string; explanation_entities?: Array<MessageEntity>; open_period?: number; close_date?: number; }; /** * This object represents a point on the map. */ export type Location = { latitude: number; longitude: number; horizontal_accuracy?: number; live_period?: number; heading?: number; proximity_alert_radius?: number; }; /** * This object represents a venue. */ export type Venue = { location: Location; title: string; address: string; foursquare_id?: string; foursquare_type?: string; google_place_id?: string; google_place_type?: string; }; /** * Describes data sent from a Web App to the bot. */ export type WebAppData = { data: string; button_text: string; }; /** * This object represents the content of a service message, sent whenever a user in the chat triggers a proximity alert set by another user. */ export type ProximityAlertTriggered = { traveler: User; watcher: User; distance: number; }; /** * This object represents a service message about a change in auto-delete timer settings. */ export type MessageAutoDeleteTimerChanged = { message_auto_delete_time: number; }; /** * This object represents a service message about a user boosting a chat. */ export type ChatBoostAdded = { boost_count: number; }; /** * This object describes the way a background is filled based on the selected colors. Currently, it can be one of */ export type BackgroundFill = BackgroundFillSolid | BackgroundFillGradient | BackgroundFillFreeformGradient; /** * The background is filled using the selected color. */ export type BackgroundFillSolid = { type: string; color: number; }; /** * The background is a gradient fill. */ export type BackgroundFillGradient = { type: string; top_color: number; bottom_color: number; rotation_angle: number; }; /** * The background is a freeform gradient that rotates after every message in the chat. */ export type BackgroundFillFreeformGradient = { type: string; colors: Array<number>; }; /** * This object describes the type of a background. Currently, it can be one of */ export type BackgroundType = BackgroundTypeFill | BackgroundTypeWallpaper | BackgroundTypePattern | BackgroundTypeChatTheme; /** * The background is automatically filled based on the selected colors. */ export type BackgroundTypeFill = { type: string; fill: BackgroundFill; dark_theme_dimming: number; }; /** * The background is a wallpaper in the JPEG format. */ export type BackgroundTypeWallpaper = { type: string; document: Document; dark_theme_dimming: number; is_blurred?: boolean; is_moving?: boolean; }; /** * The background is a .PNG or .TGV (gzipped subset of SVG with MIME type “application/x-tgwallpattern”) pattern to be combined with the background fill chosen by the user. */ export type BackgroundTypePattern = { type: string; document: Document; fill: BackgroundFill; intensity: number; is_inverted?: boolean; is_moving?: boolean; }; /** * The background is taken directly from a built-in chat theme. */ export type BackgroundTypeChatTheme = { type: string; theme_name: string; }; /** * This object represents a chat background. */ export type ChatBackground = { type: BackgroundType; }; /** * This object represents a service message about a new forum topic created in the chat. */ export type ForumTopicCreated = { name: string; icon_color: number; icon_custom_emoji_id?: string; }; /** * This object represents a service message about a forum topic closed in the chat. Currently holds no information. */ export type ForumTopicClosed = { [key: string]: unknown; }; /** * This object represents a service message about an edited forum topic. */ export type ForumTopicEdited = { name?: string; icon_custom_emoji_id?: string; }; /** * This object represents a service message about a forum topic reopened in the chat. Currently holds no information. */ export type ForumTopicReopened = { [key: string]: unknown; }; /** * This object represents a service message about General forum topic hidden in the chat. Currently holds no information. */ export type GeneralForumTopicHidden = { [key: string]: unknown; }; /** * This object represents a service message about General forum topic unhidden in the chat. Currently holds no information. */ export type GeneralForumTopicUnhidden = { [key: string]: unknown; }; /** * This object contains information about a user that was shared with the bot using a KeyboardButtonRequestUsers button. */ export type SharedUser = { user_id: number; first_name?: string; last_name?: string; username?: string; photo?: Array<PhotoSize>; }; /** * This object contains information about the users whose identifiers were shared with the bot using a KeyboardButtonRequestUsers button. */ export type UsersShared = { request_id: number; users: Array<SharedUser>; }; /** * This object contains information about a chat that was shared with the bot using a KeyboardButtonRequestChat button. */ export type ChatShared = { request_id: number; chat_id: number; title?: string; username?: string; photo?: Array<PhotoSize>; }; /** * This object represents a service message about a user allowing a bot to write messages after adding it to the attachment menu, launching a Web App from a link, or accepting an explicit request from a Web App sent by the method requestWriteAccess. */ export type WriteAccessAllowed = { from_request?: boolean; web_app_name?: string; from_attachment_menu?: boolean; }; /** * This object represents a service message about a video chat scheduled in the chat. */ export type VideoChatScheduled = { start_date: number; }; /** * This object represents a service message about a video chat started in the chat. Currently holds no information. */ export type VideoChatStarted = { [key: string]: unknown; }; /** * This object represents a service message about a video chat ended in the chat. */ export type VideoChatEnded = { duration: number; }; /** * This object represents a service message about new members invited to a video chat. */ export type VideoChatParticipantsInvited = { users: Array<User>; }; /** * Describes a service message about a change in the price of paid messages within a chat. */ export type PaidMessagePriceChanged = { paid_message_star_count: number; }; /** * This object represents a service message about the creation of a scheduled giveaway. */ export type GiveawayCreated = { prize_star_count?: number; }; /** * This object represents a message about a scheduled giveaway. */ export type Giveaway = { chats: Array<Chat>; winners_selection_date: number; winner_count: number; only_new_members?: boolean; has_public_winners?: boolean; prize_description?: string; country_codes?: Array<string>; prize_star_count?: number; premium_subscription_month_count?: number; }; /** * This object represents a message about the completion of a giveaway with public winners. */ export type GiveawayWinners = { chat: Chat; giveaway_message_id: number; winners_selection_date: number; winner_count: number; winners: Array<User>; additional_chat_count?: number; prize_star_count?: number; premium_subscription_month_count?: number; unclaimed_prize_count?: number; only_new_members?: boolean; was_refunded?: boolean; prize_description?: string; }; /** * This object represents a service message about the completion of a giveaway without public winners. */ export type GiveawayCompleted = { winner_count: number; unclaimed_prize_count?: number; giveaway_message?: Message; is_star_giveaway?: boolean; }; /** * Describes the options used for link preview generation. */ export type LinkPreviewOptions = { is_disabled?: boolean; url?: string; prefer_small_media?: boolean; prefer_large_media?: boolean; show_above_text?: boolean; }; /** * This object represent a user's profile pictures. */ export type UserProfilePhotos = { total_count: number; photos: Array<Array<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. */ export type File = { file_id: string; file_unique_id: string; file_size?: number; file_path?: string; }; /** * Describes a Web App. */ export type WebAppInfo = { url: string; }; /** * This object represents a custom keyboard with reply options (see Introduction to bots for details and examples). Not supported in channels and for messages sent on behalf of a Telegram Business account. */ export type ReplyKeyboardMarkup = { keyboard: Array<Array<KeyboardButton>>; is_persistent?: boolean; resize_keyboard?: boolean; one_time_keyboard?: boolean; input_field_placeholder?: string; selective?: boolean; }; /** * This object represents one button of the reply keyboard. At most one of the optional fields must be used to specify type of the button. For simple text buttons, String can be used instead of this object to specify the button text. */ export type KeyboardButton = { text: string; request_users?: KeyboardButtonRequestUsers; request_chat?: KeyboardButtonRequestChat; request_contact?: boolean; request_location?: boolean; request_poll?: KeyboardButtonPollType; web_app?: WebAppInfo; }; /** * This object defines the criteria used to request suitable users. Information about the selected users will be shared with the bot when the corresponding button is pressed. More about requesting users » */ export type KeyboardButtonRequestUsers = { request_id: number; user_is_bot?: boolean; user_is_premium?: boolean; max_quantity?: number; request_name?: boolean; request_username?: boolean; request_photo?: boolean; }; /** * This object defines the criteria used to request a suitable chat. Information about the selected chat will be shared with the bot when the corresponding button is pressed. The bot will be granted requested rights in the chat if appropriate. More about requesting chats ». */ export type KeyboardButtonRequestChat = { request_id: number; chat_is_channel: boolean; chat_is_forum?: boolean; chat_has_username?: boolean; chat_is_created?: boolean; user_administrator_rights?: ChatAdministratorRights; bot_administrator_rights?: ChatAdministratorRights; bot_is_member?: boolean; request_title?: boolean; request_username?: boolean; request_photo?: boolean; }; /** * This object represents type of a poll, which is allowed to be created and sent when the corresponding button is pressed. */ export type KeyboardButtonPollType = { type?: string; }; /** * 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). Not supported in channels and for messages sent on behalf of a Telegram Business account. */ export type ReplyKeyboardRemove = { remove_keyboard: boolean; selective?: boolean; }; /** * This object represents an inline keyboard that appears right next to the message it belongs to. */ export type InlineKeyboardMarkup = { inline_keyboard: Array<Array<InlineKeyboardButton>>; }; /** * This object represents one button of an inline keyboard. Exactly one of the optional fields must be used to specify type of the button. */ export type InlineKeyboardButton = { text: string; url?: string; callback_data?: string; web_app?: WebAppInfo; login_url?: LoginUrl; switch_inline_query?: string; switch_inline_query_current_chat?: string; switch_inline_query_chosen_chat?: SwitchInlineQueryChosenChat; copy_text?: CopyTextButton; callback_game?: CallbackGame; pay?: boolean; }; /** * This object represents a parameter of the inline keyboard button used to automatically authorize a user. Serves as a great replacement for the Telegram Login Widget when the user is coming from Telegram. All the user needs to do is tap/click a button and confirm that they want to log in: * Telegram apps support these buttons as of version 5.7. */ export type LoginUrl = { url: string; forward_text?: string; bot_username?: string; request_write_access?: boolean; }; /** * This object represents an inline button that switches the current user to inline mode in a chosen chat, with an optional default inline query. */ export type SwitchInlineQueryChosenChat = { query?: string; allow_user_chats?: boolean; allow_bot_chats?: boolean; allow_group_chats?: boolean; allow_channel_chats?: boolean; }; /** * This object represents an inline keyboard button that copies specified text to the clipboard. */ export type CopyTextButton = { text: string; }; /** * 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. */ export type CallbackQuery = { id: string; from: User; message?: MaybeInaccessibleMessage; inline_message_id?: string; chat_instance: string; data?: string; game_short_name?: string; }; /** * Upon receiving a message with this object, Telegram clients will display a reply interface to the user (act as if the user has selected the bot's message and tapped 'Reply'). This can be extremely useful if you want to create user-friendly step-by-step interfaces without having to sacrifice privacy mode. Not supported in channels and for messages sent on behalf of a Telegram Business account. */ export type ForceReply = { force_reply: boolean; input_field_placeholder?: string; selective?: boolean; }; /** * This object represents a chat photo. */ export type ChatPhoto = { small_file_id: string; small_file_unique_id: string; big_file_id: string; big_file_unique_id: string; }; /** * Represents an invite link for a chat. */ export type ChatInviteLink = { invite_link: string; creator: User; creates_join_request: boolean; is_primary: boolean; is_revoked: boolean; name?: string; expire_date?: number; member_limit?: number; pending_join_request_count?: number; subscription_period?: number; subscription_price?: number; }; /** * Represents the rights of an administrator in a chat. */ export type ChatAdministratorRights = { is_anonymous: boolean; can_manage_chat: boolean; can_delete_messages: boolean; can_manage_video_chats: boolean; can_restrict_members: boolean; can_promote_members: boolean; can_change_info: boolean; can_invite_users: boolean; can_post_stories: boolean; can_edit_stories: boolean; can_delete_stories: boolean; can_post_messages?: boolean; can_edit_messages?: boolean; can_pin_messages?: boolean; can_manage_topics?: boolean; }; /** * This object represents changes in the status of a chat member. */ export type ChatMemberUpdated = { chat: Chat; from: User; date: number; old_chat_member: ChatMember; new_chat_member: ChatMember; invite_link?: ChatInviteLink; via_join_request?: boolean; via_chat_folder_invite_link?: boolean; }; /** * This object contains information about one member of a chat. Currently, the following 6 types of chat members are supported: */ export type ChatMember = ChatMemberOwner | ChatMemberAdministrator | ChatMemberMember | ChatMemberRestricted | ChatMemberLeft | ChatMemberBanned; /** * Represents a chat member that owns the chat and has all administrator privileges. */ export type ChatMemberOwner = { status: string; user: User; is_anonymous: boolean; custom_title?: string; }; /** * Represents a chat member that has some additional privileges. */ export type ChatMemberAdministrator = { status: string; user: User; can_be_edited: boolean; is_anonymous: boolean; can_manage_chat: boolean; can_delete_messages: boolean; can_manage_video_chats: boolean; can_restrict_members: boolean; can_promote_members: boolean; can_change_info: boolean; can_invite_users: boolean; can_post_stories: boolean; can_edit_stories: boolean; can_delete_stories: boolean; can_post_messages?: boolean; can_edit_messages?: boolean; can_pin_messages?: boolean; can_manage_topics?: boolean; custom_title?: string; }; /** * Represents a chat member that has no additional privileges or restrictions. */ export type ChatMemberMember = { status: string; user: User; until_date?: number; }; /** * Represents a chat member that is under certain restrictions in the chat. Supergroups only. */ export type ChatMemberRestricted = { status: string; user: User; is_member: boolean; can_send_messages: boolean; can_send_audios: boolean; can_send_documents: boolean; can_send_photos: boolean; can_send_videos: boolean; can_send_video_notes: boolean; can_send_voice_notes: boolean; can_send_polls: boolean; can_send_other_messages: boolean; can_add_web_page_previews: boolean; can_change_info: boolean; can_invite_users: boolean; can_pin_messages: boolean; can_manage_topics: boolean; until_date: number; }; /** * Represents a chat member that isn't currently a member of the chat, but may join it themselves. */ export type ChatMemberLeft = { status: string; user: User; }; /** * Represents a chat member that was banned in the chat and can't return to the chat or view chat messages. */ export type ChatMemberBanned = { status: string; user: User; until_date: number; }; /** * Represents a join request sent to a chat. */ export type ChatJoinRequest = { chat: Chat; from: User; user_chat_id: number; date: number; bio?: string; invite_link?: ChatInviteLink; }; /** * Describes actions that a non-administrator user is allowed to take in a chat. */ export type ChatPermissions = { can_send_messages?: boolean; can_send_audios?: boolean; can_send_documents?: boolean; can_send_photos?: boolean; can_send_videos?: boolean; can_send_video_notes?: boolean; can_send_voice_notes?: boolean; can_send_polls?: boolean; can_send_other_messages?: boolean; can_add_web_page_previews?: boolean; can_change_info?: boolean; can_invite_users?: boolean; can_pin_messages?: boolean; can_manage_topics?: boolean; }; /** * Describes the birthdate of a user. */ export type Birthdate = { day: number; month: number; year?: number; }; /** * Contains information about the start page settings of a Telegram Business account. */ export type BusinessIntro = { title?: string; message?: string; sticker?: Sticker; }; /** * Contains information about the location of a Telegram Business account. */ export type BusinessLocation = { address: string; location?: Location; }; /** * Describes an interval of time during which a business is open. */ export type BusinessOpeningHoursInterval = { opening_minute: number; closing_minute: number; }; /** * Describes the opening hours of a business. */ export type BusinessOpeningHours = { time_zone_name: string; opening_hours: Array<BusinessOpeningHoursInterval>; }; /** * Describes the position of a clickable area within a story. */ export type StoryAreaPosition = { x_percentage: number; y_percentage: number; width_percentage: number; height_percentage: number; rotation_angle: number; corner_radius_percentage: number; }; /** * Describes the physical address of a location. */ export type LocationAddress = { country_code: string; state?: string; city?: string; street?: string; }; /** * Describes the type of a clickable area on a story. Currently, it can be one of */ export type StoryAreaType = StoryAreaTypeLocation | StoryAreaTypeSuggestedReaction | StoryAreaTypeLink | StoryAreaTypeWeather | StoryAreaTypeUniqueGift; /** * Describes a story area pointing to a location. Currently, a story can have up to 10 location areas. */ export type StoryAreaTypeLocation = { type: string; latitude: number; longitude: number; address?: LocationAddress; }; /** * Describes a story area pointing to a suggested reaction. Currently, a story can have up to 5 suggested reaction areas. */ export type StoryAreaTypeSuggestedReaction = { type: string; reaction_type: ReactionType; is_dark?: boolean; is_flipped?: boolean; }; /** * Describes a story area pointing to an HTTP or tg:// link. Currently, a story can have up to 3 link areas. */ export type StoryAreaTypeLink = { type: string; url: string; }; /** * Describes a story area containing weather information. Currently, a story can have up to 3 weather areas. */ export type StoryAreaTypeWeather = { type: string; temperature: number; emoji: string; background_color: number; }; /** * Describes a story area pointing to a unique gift. Currently, a story can have at most 1 unique gift area. */ export type StoryAreaTypeUniqueGift = { type: string; name: string; }; /** * Describes a clickable area on a story media. */ export type StoryArea = { position: StoryAreaPosition; type: StoryAreaType; }; /** * Represents a location to which a chat is connected. */ export type ChatLocation = { location: Location; address: string; }; /** * This object describes the type of a reaction. Currently, it can be one of */ export type ReactionType = ReactionTypeEmoji | ReactionTypeCustomEmoji | ReactionTypePaid; /** * The reaction is based on an emoji. */ export type ReactionTypeEmoji = { type: string; emoji: string; }; /** * The reaction is based on a custom emoji. */ export type ReactionTypeCustomEmoji = { type: string; custom_emoji_id: string; }; /** * The reaction is paid. */ export type ReactionTypePaid = { type: string; }; /** * Represents a reaction added to a message along with the number of times it was added. */ export type ReactionCount = { type: ReactionType; total_count: number; }; /** * This object represents a change of a reaction on a message performed by a user. */ export type MessageReactionUpdated = { chat: Chat; message_id: number; user?: User; actor_chat?: Chat; date: number; old_reaction: Array<ReactionType>; new_reaction: Array<ReactionType>; }; /** * This object represents reaction changes on a message with anonymous reactions. */ export type MessageReactionCountUpdated = { chat: Chat; message_id: number; date: number; reactions: Array<ReactionCount>; }; /** * This object represents a forum topic. */ export type ForumTopic = { message_thread_id: number; name: string; icon_color: number; icon_custom_emoji_id?: string; }; /** * This object represents a gift that can be sent by the bot. */ export type Gift = { id: string; sticker: Sticker; star_count: number; upgrade_star_count?: number; total_count?: number; remaining_count?: number; }; /** * This object represent a list of gifts. */ export type Gifts = { gifts: Array<Gift>; }; /** * This object describes the model of a unique gift. */ export type UniqueGiftModel = { name: string; sticker: Sticker; rarity_per_mille: number; }; /** * This object describes the symbol shown on the pattern of a unique gift. */ export type UniqueGiftSymbol = { name: string; sticker: Sticker; rarity_per_mille: number; }; /** * This object describes the colors of the backdrop of a unique gift. */ export type UniqueGiftBackdropColors = { center_color: number; edge_color: number; symbol_color: number; text_color: number; }; /** * This object describes the backdrop of a unique gift. */ export type UniqueGiftBackdrop = { name: string; colors: UniqueGiftBackdropColors; rarity_per_mille: number; }; /** * This object describes a unique gift that was upgraded from a regular gift. */ export type UniqueGift = { base_name: string; name: string; number: number; model: UniqueGiftModel; symbol: UniqueGiftSymbol; backdrop: UniqueGiftBackdrop; }; /** * Describes a service message about a regular gift that was sent or received. */ export type GiftInfo = { gift: Gift; owned_gift_id?: string; convert_star_count?: number; prepaid_upgrade_star_count?: number; can_be_upgraded?: boolean; text?: string; entities?: Array<MessageEntity>; is_private?: boolean; }; /** * Describes a service message about a unique gift that was sent or received. */ export type UniqueGiftInfo = { gift: UniqueGift; origin: string; owned_gift_id?: string; transfer_star_count?: number; }; /** * This object describes a gift received and owned by a user or a chat. Currently, it can be one of */ export type OwnedGift = OwnedGiftRegular | OwnedGiftUnique; /** * Describes a regular gift owned by a user or a chat. */ export type OwnedGiftRegular = { type: string; gift: Gift; owned_gift_id?: string; sender_user?: User; send_date: number; text?: string; entities?: Array<MessageEntity>; is_private?: boolean; is_saved?: boolean; can_be_upgraded?: boolean; was_refunded?: boolean; convert_star_count?: number; prepaid_upgrade_star_count?: number; }; /** * Describes a unique gift received and owned by a user or a chat. */ export type OwnedGiftUnique = { type: string; gift: UniqueGift; owned_gift_id?: string; sender_user?: User; send_date: number; is_saved?: boolean; can_be_transferred?: boolean; transfer_star_count?: number; }; /** * Contains the list of gifts received and owned by a user or a chat. */ export type OwnedGifts = { total_count: number; gifts: Array<OwnedGift>; next_offset?: string; }; /** * This object describes the types of gifts that can be gifted to a user or a chat. */ export type AcceptedGiftTypes = { unlimited_gifts: boolean; limited_gifts: boolean; unique_gifts: boolean; premium_subscription: boolean; }; /** * Describes an amount of Telegram Stars. */ export type StarAmount = { amount: number; nanostar_amount?: number; }; /** * This object represents a bot command. */ export type BotCommand = { command: string; description: string; }; /** * This object represents the scope to which bot commands are applied. Currently, the following 7 scopes are supported: */ export type BotCommandScope = BotCommandScopeDefault | BotCommandScopeAllPrivateChats | BotCommandScopeAllGroupChats | BotCommandScopeAllChatAdministrators | BotCommandScopeChat | BotCommandScopeChatAdministrators | BotCommandScopeChatMember; /** * Represents the default scope of bot commands. Default commands are used if no commands with a narrower scope are specified for the user. */ export type BotCommandScopeDefault = { type: string; }; /** * Represents the scope of bot commands, covering all private chats. */ export type BotCommandScopeAllPrivateChats = { type: string; }; /** * Represents the scope of bot commands, covering all group and supergroup chats. */ export type BotCommandScopeAllGroupChats = { type: string; }; /** * Represents the scope of bot commands, covering all group and supergroup chat administrators. */ export type BotCommandScopeAllChatAdministrators = { type: string; }; /** * Represents the scope of bot commands, covering a specific chat. */ export type BotCommandScopeChat = { type: string; chat_id: number | string; }; /** * Represents the scope of bot commands, covering all administrators of a specific group or supergroup chat. */ export type BotCommandScopeChatAdministrators = { type: string; chat_id: number | string; }; /** * Represents the scope of bot commands, covering a specific member of a group or supergroup chat. */ export type BotCommandScopeChatMember = { type: string; chat_id: number | string; user_id: number; }; /** * This object represents the bot's name. */ export type BotName = { name: string; }; /** * This object represents the bot's description. */ export type BotDescription = { description: string; }; /** * This object represents the bot's short description. */ export type BotShortDescription = { short_description: string; }; /** * This object describes the bot's menu button in a private chat. It should be one of */ export type MenuButton = MenuButtonCommands | MenuButtonWebApp | MenuButtonDefault; /** * Represents a menu button, which opens the bot's list of commands. */ export type MenuButtonCommands = { type: string; }; /** * Represents a menu button, which launches a Web App. */ export type MenuButtonWebApp = { type: string; text: string; web_app: WebAppInfo; }; /** * Describes that no specific value for the menu button was set. */ export type MenuButtonDefault = { type: string; }; /** * This object describes the source of a chat boost. It can be one of */ export type ChatBoostSource = ChatBoostSourcePremium | ChatBoostSourceGiftCode | ChatBoostSourceGiveaway; /** * The boost was obtained by subscribing to Telegram Premium or by gifting a Telegram Premium subscription to another user. */ export type ChatBoostSourcePremium = { source: string; user: User; }; /** * The boost was obtained by the creation of Telegram Premium gift codes to boost a chat. Each such code boosts the chat 4 times for the duration of the corresponding Telegram Premium subscription. */ export type ChatBoostSourceGiftCode = { source: string; user: User; }; /** * The boost was obtained by the creation of a Telegram Premium or a Telegram Star giveaway. This boosts the chat 4 times for the duration of the corresponding Telegram Premium subscription for Telegram Premium giveaways and prize_star_count / 500 times for one year for Telegram Star giveaways. */ export type ChatBoostSourceGiveaway = { source: string; giveaway_message_id: number; user?: User; prize_star_count?: number; is_unclaimed?: boolean; }; /** * This object contains information about a chat boost. */ export type ChatBoost = { boost_id: string; add_date: number; expiration_date: number; source: ChatBoostSource; }; /** * This object represents a boost added to a chat or changed. */ export type ChatBoostUpdated = { chat: Chat; boost: ChatBoost; }; /** * This object represents a boost removed from a chat. */ export type ChatBoostRemoved = { chat: Chat; boost_id: string; remove_date: number; source: ChatBoostSource; }; /** * This object represents a list of boosts added to a chat by a user. */ export type UserChatBoosts = { boosts: Array<ChatBoost>; }; /** * Represents the rights of a business bot. */ export type BusinessBotRights = { can_reply?: boolean; can_read_messages?: boolean; can_delete_outgoing_messages?: boolean; can_delete_all_messages?: boolean; can_edit_name?: boolean; can_edit_bio?: boolean; can_edit_profile_photo?: boolean; can_edit_username?: boolean; can_change_gift_settings?: boolean; can_view_gifts_and_stars?: boolean; can_convert_gifts_to_stars?: boolean; can_transfer_and_upgrade_gifts?: boolean; can_transfer_stars?: boolean; can_manage_stories?: boolean; }; /** * Describes the connection of the bot with a business account. */ export type BusinessConnection = { id: string; user: User; user_chat_id: number; date: number; rights?: BusinessBotRights; is_enabled: boolean; }; /** * This object is received when messages are deleted from a connected business account. */ export type BusinessMessagesDeleted = { business_connection_id: string; chat: Chat; message_ids: Array<number>; }; /** * Describes why a request was unsuccessful. */ export type ResponseParameters = { migrate_to_chat_id?: number; retry_after?: number; }; /** * This object represents the content of a media message to be sent. It should be one of */ export type InputMedia = InputMediaAnimation | InputMediaDocument | InputMediaAudio | InputMediaPhoto | InputMediaVideo; /** * Represents a photo to be sent. */ export type InputMediaPhoto = { type: string; media: string; caption?: string; parse_mode?: string; caption_entities?: Array<MessageEntity>; show_caption_above_media?: boolean; has_spoiler?: boolean; }; /** * Represents a video to be sent. */ export type InputMediaVideo = { type: string; media: string; thumbnail?: string; cover?: string; start_timestamp?: number; caption?: string; parse_mode?: string; caption_entities?: Array<MessageEntity>; show_caption_above_media?: boolean; width?: number; height?: number; duration?: number; supports_streaming?: boolean; has_spoiler?: boolean; }; /** * Represents an animation file (GIF or H.264/MPEG-4 AVC video without sound) to be sent. */ export type InputMediaAnimation = { type: string; media: string; thumbnail?: string; caption?: string; parse_mode?: string; caption_entities?: Array<MessageEntity>; show_caption_above_media?: boolean; width?: number; height?: number; duration?: number; has_spoiler?: boolean; }; /** * Represents an audio file to be treated as music to be sent. */ export type InputMediaAudio = { type: string; media: string; thumbnail?: string; caption?: string; parse_mode?: string; caption_entities?: Array<MessageEntity>; duration?: number; performer?: string; title?: string; }; /** * Represents a general file to be sent. */ export type InputMediaDocument = { type: string; media: string; thumbnail?: string; caption?: string; parse_mode?: string; caption_entities?: Array<MessageEntity>; disable_content_type_detection?: boolean; }; /** * 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 = { [key: string]: unknown; }; /** * This object describes the paid media to be sent. Currently, it can be one of */ export type InputPaidMedia = InputPaidMediaPhoto | InputPaidMediaVideo; /** * The paid media to send is a photo. */ export type InputPaidMediaPhoto = { type: string; media: string; }; /** * The paid media to send is a video. */ export type InputPaidMediaVideo = { type: string; media: string; thumbnail?: string; cover?: string; start_timestamp?: number;