├── .editorconfig ├── .gitignore ├── .vscode ├── extensions.json └── settings.json ├── LICENSE ├── README.md ├── api.ts ├── deno.jsonc ├── inline.ts ├── langs.ts ├── manage.ts ├── markup.ts ├── message.ts ├── methods.ts ├── mod.js ├── mod.ts ├── package.json ├── passport.ts ├── payment.ts ├── settings.ts ├── story.ts ├── tsconfig.json └── update.ts /.editorconfig: -------------------------------------------------------------------------------- 1 | [*] 2 | end_of_line = lf 3 | charset = utf-8 4 | indent_style = space 5 | indent_size = 2 6 | insert_final_newline = true 7 | trim_trailing_whitespace = true 8 | max_line_length = 80 9 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Build output 2 | *.d.ts 3 | -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": ["denoland.vscode-deno", "editorconfig.editorconfig"] 3 | } 4 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "editor.formatOnSave": true, 3 | "editor.codeActionsOnSave": { 4 | "source.fixAll": "explicit" 5 | }, 6 | "[typescript]": { 7 | "editor.defaultFormatter": "denoland.vscode-deno" 8 | }, 9 | "[markdown]": { 10 | "editor.defaultFormatter": "denoland.vscode-deno" 11 | }, 12 | "[json]": { 13 | "editor.defaultFormatter": "denoland.vscode-deno" 14 | }, 15 | "[jsonc]": { 16 | "editor.defaultFormatter": "denoland.vscode-deno" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021-2024 KnorpelSenf 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Telegram Bot API types for grammY 2 | 3 | [grammY](https://github.com/grammyjs/grammY) makes writing Telegram bots easy. Check it out! 4 | 5 | This package just provides type annotations for the complete Telegram Bot API, and aims at making them usable for grammY. It contains no runnable code. 6 | 7 | Originally, this package is based on `typegram`, but since the update to Telegram Bot API 5.1, `typegram` is no longer directly updated. Instead, this package is maintained and its updates are backported to `typegram`. Hence, both packages are kept up to date with the Telegram Bot API for now. 8 | 9 | ## Available Types 10 | 11 | Generally this package just exposes a huge load of `interface`s that correspond to the **types** used throughout the Telegram Bot API. 12 | 13 | Note that the API specification sometimes only has one name for multiple variants of a type, e.g. there is a number of different `Update`s you can receive, but they're all just called `Update`. 14 | If you need to access the individual variants of an `Update`, refer to `Update.MessageUpdate` and its siblings. 15 | 16 | In fact, this pattern is used for various types, namely: 17 | 18 | - `CallbackQuery` 19 | - `Chat` 20 | - `ChatFullInfo` 21 | - `InlineKeyboardButton` 22 | - `KeyboardButton` 23 | - `Message` 24 | - `MessageEntity` 25 | - `Location` 26 | - `Update` 27 | 28 | Naturally, when the API specification is actually modelling types to be unions (e.g. `InlineQueryResult`), this is reflected here as a union type, too. 29 | Those types are not closed. 30 | 31 | ## Available Methods 32 | 33 | In addition to the types, this package provides you with another type `Telegram` which contains all available **methods** of the API. 34 | There is no further structure applied to this, but if you can come up with something reasonable, please suggest it in an issue or directly open a PR. 35 | In grammY, these types are what defines the `bot.api.raw` object. 36 | 37 | Each method takes just a single argument with a structure that corresponds to the object expected by Telegram. 38 | The helper type `Opts` (where `M` is the method name) allows grammY to access that type directly. 39 | 40 | ## Handling JSON-Serialized Objects 41 | 42 | Some methods of the Telegram Bot API are expected to be called with JSON-serialized objects contained in a property of the payload, rather than an actual JSON payload. 43 | In other words, the objects are serialized twice—the first time in order to conform with the docs, and the second time when the payload is actually sent in the POST body to the API server. 44 | 45 | The most prominent example is the `reply_markup` property that appears in a number of different methods, but more than a dozen other properties like this can be found throughout the API. 46 | 47 | Strictly speaking, the `@grammyjs/types` types do not reflect this accurately. 48 | Instead of using `string` (representing a serialized object) as the type, `@grammyjs/types` uses the type of the object itself, thus ignoring the serialization step. 49 | For instance, instead of declaring `reply_markup: string`, it declares the property as `reply_markup: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply` because that is what is supposed to be serialized to `string` before calling the respective method. 50 | 51 | That makes sense for the reason that grammY uses the types in its wrapper code around the Telegram Bot API, exposed as `bot.raw.api`. 52 | This wrapper code does the necessary JSON serialization automatically for the required properties. 53 | Bots written with grammY then do not need to care about which properties to serialize and which not. 54 | Given that `@grammyjs/types` refers to the objects themselves instead of their serialized strings, the wrapper code can now simply expose the `@grammyjs/types` types to its consumers without having to transform them before. 55 | 56 | Consequently, the descriptions of all methods are adjusted in order to reflect this, i.e. the JSDoc comments do not mention JSON serialization (in contrast to their official equivalents). 57 | 58 | ## Customizing `InputFile` 59 | 60 | The Telegram Bot API lets bots send files in [three different ways](https://core.telegram.org/bots/api#sending-files). 61 | Two of those ways are by specifying a `string`—either a `file_id` or a URL. 62 | The third option, however, is by uploading files to the server using multipart/form-data. 63 | 64 | The first two means to send a file are already covered by the type annotations across the library. 65 | In all places where a `file_id` or a URL is permitted, the corresponding property allows a `string`. 66 | 67 | We will now look at the type declarations that are relevant for uploading files directly. 68 | grammY automatically translates calls to `sendDocument` and the like to multipart/form-data uploads when supplied with an `InputFile` object in the `document` property of the argument object. 69 | 70 | `@grammyjs/types` should not have to know what objects you want to support as `InputFile`s. 71 | Consequently, the type `InputFile` is not defined in this library. 72 | 73 | Instead, grammY specifies its own version of what an `InputFile` is, hence automatically adjusting `@grammyjs/types` with a custom `InputFile` type used throughout all affected methods and interfaces. 74 | This is possible by adding a type parameter to all affected types. 75 | grammY then import types parametrises these types with its version of `InputFile`, and re-exports the adjusted types. 76 | This is why you should always import Bot API as described here: . 77 | 78 | ## Differences to the Bot API 79 | 80 | Some documentation strings are intentionally different from what is written on the website. 81 | The actual type definitions themselves are never different. 82 | 83 | 1. No formatting. 84 | We do not leverage the markdown capabilities of JSDoc for the sake of easier copying and thus reduced maintenance efforts. 85 | 2. No mentions of `JSON-serialized`. 86 | As underlying libraries handle serialization, these words are removed from the explanations. 87 | 3. No mentions of integer numbers that exceed 2^31 but not 2^51. 88 | All numbers are 64-bit floats in JS, so this is irrelevant. 89 | Note that JS bit operators cast numbers to 32-bit integers and back, but we deliberately ignore this because people who use bit operators on identifiers or file sizes should know what they're doing, and they should also know that it's a bad idea. 90 | 4. No `More info on Sending Files »`. 91 | File handling is abstracted away by the underlying library. 92 | Also, without the links, it's useless anyway. 93 | The same is true for the links to more info about requesting chats and users. 94 | 5. No images. 95 | Documentation strings containing an image are adjusted to make sense without the images, too. 96 | 97 | ## Contributing 98 | 99 | This is a Deno project. 100 | All the files are TypeScript files that are published on . 101 | This project uses [deno2node](https://github.com/fromdeno/deno2node) to emit declaration files which are then published on npm. 102 | 103 | If you want to work on this, you do not need to have Node.js installed. 104 | You also should not run `npm install`. 105 | You only need [Deno](https://deno.land) and the VSCode extensions recommended in this repo. 106 | 107 | Run `deno task` to see available development scripts. 108 | -------------------------------------------------------------------------------- /api.ts: -------------------------------------------------------------------------------- 1 | export interface ApiError { 2 | ok: false; 3 | error_code: number; 4 | description: string; 5 | parameters?: ResponseParameters; 6 | } 7 | 8 | export interface ApiSuccess { 9 | ok: true; 10 | result: T; 11 | } 12 | 13 | /** The response contains an object, which always has a Boolean field 'ok' and may have an optional String field 'description' with a human-readable description of the result. If 'ok' equals true, the request was successful and the result of the query can be found in the 'result' field. In case of an unsuccessful request, 'ok' equals false and the error is explained in the 'description'. An Integer 'error_code' field is also returned, but its contents are subject to change in the future. Some errors may also have an optional field 'parameters' of the type ResponseParameters, which can help to automatically handle the error. 14 | 15 | All methods in the Bot API are case-insensitive. 16 | All queries must be made using UTF-8. */ 17 | export type ApiResponse = ApiError | ApiSuccess; 18 | 19 | /** Describes why a request was unsuccessful. */ 20 | export interface ResponseParameters { 21 | /** The group has been migrated to a supergroup with the specified identifier. */ 22 | migrate_to_chat_id?: number; 23 | /** In case of exceeding flood control, the number of seconds left to wait before the request can be repeated */ 24 | retry_after?: number; 25 | } 26 | -------------------------------------------------------------------------------- /deno.jsonc: -------------------------------------------------------------------------------- 1 | { 2 | "lock": false, 3 | "tasks": { 4 | "check": "deno cache --check=all mod.ts", 5 | "ok": "deno fmt && deno lint && deno task check", 6 | "build": "deno -RW=. https://deno.land/x/deno2node@v1.14.0/src/cli.ts tsconfig.json", 7 | "clean": "git clean -fX '*.d.ts'" 8 | }, 9 | "fmt": { "proseWrap": "preserve" }, 10 | "lint": { 11 | "exclude": [ 12 | "api.d.ts", 13 | "inline.d.ts", 14 | "manage.d.ts", 15 | "markup.d.ts", 16 | "message.d.ts", 17 | "methods.d.ts", 18 | "mod.d.ts", 19 | "passport.d.ts", 20 | "payment.d.ts", 21 | "settings.d.ts", 22 | "update.d.ts" 23 | ], 24 | "rules": { 25 | "exclude": [ 26 | // Many types have no properties 27 | "no-empty-interface" 28 | ] 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /inline.ts: -------------------------------------------------------------------------------- 1 | import type { Chat, User } from "./manage.ts"; 2 | import type { InlineKeyboardMarkup, WebAppInfo } from "./markup.ts"; 3 | import type { 4 | LinkPreviewOptions, 5 | Location, 6 | MessageEntity, 7 | ParseMode, 8 | } from "./message.ts"; 9 | import type { LabeledPrice } from "./payment.ts"; 10 | 11 | /** This object represents an incoming inline query. When the user sends an empty query, your bot could return some default or trending results. */ 12 | export interface InlineQuery { 13 | /** Unique identifier for this query */ 14 | id: string; 15 | /** Sender */ 16 | from: User; 17 | /** Text of the query (up to 256 characters) */ 18 | query: string; 19 | /** Offset of the results to be returned, can be controlled by the bot */ 20 | offset: string; 21 | /** Type of the chat from which the inline query was sent. Can be either “sender” for a private chat with the inline query sender, “private”, “group”, “supergroup”, or “channel”. The chat type should be always known for requests sent from official clients and most third-party clients, unless the request was sent from a secret chat */ 22 | chat_type?: "sender" | Chat["type"]; 23 | /** Sender location, only for bots that request user location */ 24 | location?: Location; 25 | } 26 | 27 | /** This object represents one result of an inline query. Telegram clients currently support results of the following 20 types: 28 | - InlineQueryResultCachedAudio 29 | - InlineQueryResultCachedDocument 30 | - InlineQueryResultCachedGif 31 | - InlineQueryResultCachedMpeg4Gif 32 | - InlineQueryResultCachedPhoto 33 | - InlineQueryResultCachedSticker 34 | - InlineQueryResultCachedVideo 35 | - InlineQueryResultCachedVoice 36 | - InlineQueryResultArticle 37 | - InlineQueryResultAudio 38 | - InlineQueryResultContact 39 | - InlineQueryResultGame 40 | - InlineQueryResultDocument 41 | - InlineQueryResultGif 42 | - InlineQueryResultLocation 43 | - InlineQueryResultMpeg4Gif 44 | - InlineQueryResultPhoto 45 | - InlineQueryResultVenue 46 | - InlineQueryResultVideo 47 | - InlineQueryResultVoice 48 | 49 | Note: All URLs passed in inline query results will be available to end users and therefore must be assumed to be public. */ 50 | export type InlineQueryResult = 51 | | InlineQueryResultCachedAudio 52 | | InlineQueryResultCachedDocument 53 | | InlineQueryResultCachedGif 54 | | InlineQueryResultCachedMpeg4Gif 55 | | InlineQueryResultCachedPhoto 56 | | InlineQueryResultCachedSticker 57 | | InlineQueryResultCachedVideo 58 | | InlineQueryResultCachedVoice 59 | | InlineQueryResultArticle 60 | | InlineQueryResultAudio 61 | | InlineQueryResultContact 62 | | InlineQueryResultGame 63 | | InlineQueryResultDocument 64 | | InlineQueryResultGif 65 | | InlineQueryResultLocation 66 | | InlineQueryResultMpeg4Gif 67 | | InlineQueryResultPhoto 68 | | InlineQueryResultVenue 69 | | InlineQueryResultVideo 70 | | InlineQueryResultVoice; 71 | 72 | /** Represents a link to an article or web page. */ 73 | export interface InlineQueryResultArticle { 74 | /** Type of the result, must be article */ 75 | type: "article"; 76 | /** Unique identifier for this result, 1-64 Bytes */ 77 | id: string; 78 | /** Title of the result */ 79 | title: string; 80 | /** Content of the message to be sent */ 81 | input_message_content: InputMessageContent; 82 | /** Inline keyboard attached to the message */ 83 | reply_markup?: InlineKeyboardMarkup; 84 | /** URL of the result */ 85 | url?: string; 86 | /** Short description of the result */ 87 | description?: string; 88 | /** Url of the thumbnail for the result */ 89 | thumbnail_url?: string; 90 | /** Thumbnail width */ 91 | thumbnail_width?: number; 92 | /** Thumbnail height */ 93 | thumbnail_height?: number; 94 | } 95 | 96 | /** Represents a link to a photo. By default, this photo will be sent by the user with optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the photo. */ 97 | export interface InlineQueryResultPhoto { 98 | /** Type of the result, must be photo */ 99 | type: "photo"; 100 | /** Unique identifier for this result, 1-64 bytes */ 101 | id: string; 102 | /** A valid URL of the photo. Photo must be in JPEG format. Photo size must not exceed 5MB */ 103 | photo_url: string; 104 | /** URL of the thumbnail for the photo */ 105 | thumbnail_url: string; 106 | /** Width of the photo */ 107 | photo_width?: number; 108 | /** Height of the photo */ 109 | photo_height?: number; 110 | /** Title for the result */ 111 | title?: string; 112 | /** Short description of the result */ 113 | description?: string; 114 | /** Caption of the photo to be sent, 0-1024 characters after entities parsing */ 115 | caption?: string; 116 | /** Pass True, if the caption must be shown above the message media */ 117 | show_caption_above_media?: boolean; 118 | /** Mode for parsing entities in the photo caption. See formatting options for more details. */ 119 | parse_mode?: ParseMode; 120 | /** List of special entities that appear in the caption, which can be specified instead of parse_mode */ 121 | caption_entities?: MessageEntity[]; 122 | /** Inline keyboard attached to the message */ 123 | reply_markup?: InlineKeyboardMarkup; 124 | /** Content of the message to be sent instead of the photo */ 125 | input_message_content?: InputMessageContent; 126 | } 127 | 128 | /** Represents a link to an animated GIF file. By default, this animated GIF file will be sent by the user with optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the animation. */ 129 | export interface InlineQueryResultGif { 130 | /** Type of the result, must be gif */ 131 | type: "gif"; 132 | /** Unique identifier for this result, 1-64 bytes */ 133 | id: string; 134 | /** A valid URL for the GIF file */ 135 | gif_url: string; 136 | /** Width of the GIF */ 137 | gif_width?: number; 138 | /** Height of the GIF */ 139 | gif_height?: number; 140 | /** Duration of the GIF in seconds */ 141 | gif_duration?: number; 142 | /** URL of the static (JPEG or GIF) or animated (MPEG4) thumbnail for the result */ 143 | thumbnail_url: string; 144 | /** MIME type of the thumbnail, must be one of “image/jpeg”, “image/gif”, or “video/mp4”. Defaults to “image/jpeg” */ 145 | thumbnail_mime_type?: "image/jpeg" | "image/gif" | "video/mp4"; 146 | /** Title for the result */ 147 | title?: string; 148 | /** Caption of the GIF file to be sent, 0-1024 characters after entities parsing */ 149 | caption?: string; 150 | /** Pass True, if the caption must be shown above the message media */ 151 | show_caption_above_media?: boolean; 152 | /** Mode for parsing entities in the caption. See formatting options for more details. */ 153 | parse_mode?: ParseMode; 154 | /** List of special entities that appear in the caption, which can be specified instead of parse_mode */ 155 | caption_entities?: MessageEntity[]; 156 | /** Inline keyboard attached to the message */ 157 | reply_markup?: InlineKeyboardMarkup; 158 | /** Content of the message to be sent instead of the GIF animation */ 159 | input_message_content?: InputMessageContent; 160 | } 161 | 162 | /** Represents a link to a video animation (H.264/MPEG-4 AVC video without sound). By default, this animated MPEG-4 file will be sent by the user with optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the animation. */ 163 | export interface InlineQueryResultMpeg4Gif { 164 | /** Type of the result, must be mpeg4_gif */ 165 | type: "mpeg4_gif"; 166 | /** Unique identifier for this result, 1-64 bytes */ 167 | id: string; 168 | /** A valid URL for the MPEG4 file */ 169 | mpeg4_url: string; 170 | /** Video width */ 171 | mpeg4_width?: number; 172 | /** Video height */ 173 | mpeg4_height?: number; 174 | /** Video duration in seconds */ 175 | mpeg4_duration?: number; 176 | /** URL of the static (JPEG or GIF) or animated (MPEG4) thumbnail for the result */ 177 | thumbnail_url: string; 178 | /** MIME type of the thumbnail, must be one of “image/jpeg”, “image/gif”, or “video/mp4”. Defaults to “image/jpeg” */ 179 | thumbnail_mime_type?: "image/jpeg" | "image/gif" | "video/mp4"; 180 | /** Title for the result */ 181 | title?: string; 182 | /** Caption of the MPEG-4 file to be sent, 0-1024 characters after entities parsing */ 183 | caption?: string; 184 | /** Pass True, if the caption must be shown above the message media */ 185 | show_caption_above_media?: boolean; 186 | /** Mode for parsing entities in the caption. See formatting options for more details. */ 187 | parse_mode?: ParseMode; 188 | /** List of special entities that appear in the caption, which can be specified instead of parse_mode */ 189 | caption_entities?: MessageEntity[]; 190 | /** Inline keyboard attached to the message */ 191 | reply_markup?: InlineKeyboardMarkup; 192 | /** Content of the message to be sent instead of the video animation */ 193 | input_message_content?: InputMessageContent; 194 | } 195 | 196 | /** Represents a link to a page containing an embedded video player or a video file. By default, this video file will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the video. 197 | 198 | > If an InlineQueryResultVideo message contains an embedded video (e.g., YouTube), you must replace its content using input_message_content. */ 199 | export interface InlineQueryResultVideo { 200 | /** Type of the result, must be video */ 201 | type: "video"; 202 | /** Unique identifier for this result, 1-64 bytes */ 203 | id: string; 204 | /** A valid URL for the embedded video player or video file */ 205 | video_url: string; 206 | /** MIME type of the content of the video URL, “text/html” or “video/mp4” */ 207 | mime_type: "text/html" | "video/mp4"; 208 | /** URL of the thumbnail (JPEG only) for the video */ 209 | thumbnail_url: string; 210 | /** Title for the result */ 211 | title: string; 212 | /** Caption of the video to be sent, 0-1024 characters after entities parsing */ 213 | caption?: string; 214 | /** Pass True, if the caption must be shown above the message media */ 215 | show_caption_above_media?: boolean; 216 | /** Mode for parsing entities in the video caption. See formatting options for more details. */ 217 | parse_mode?: ParseMode; 218 | /** List of special entities that appear in the caption, which can be specified instead of parse_mode */ 219 | caption_entities?: MessageEntity[]; 220 | /** Video width */ 221 | video_width?: number; 222 | /** Video height */ 223 | video_height?: number; 224 | /** Video duration in seconds */ 225 | video_duration?: number; 226 | /** Short description of the result */ 227 | description?: string; 228 | /** Inline keyboard attached to the message */ 229 | reply_markup?: InlineKeyboardMarkup; 230 | /** Content of the message to be sent instead of the video. This field is required if InlineQueryResultVideo is used to send an HTML-page as a result (e.g., a YouTube video). */ 231 | input_message_content?: InputMessageContent; 232 | } 233 | 234 | /** Represents a link to an MP3 audio file. By default, this audio file will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the audio. */ 235 | export interface InlineQueryResultAudio { 236 | /** Type of the result, must be audio */ 237 | type: "audio"; 238 | /** Unique identifier for this result, 1-64 bytes */ 239 | id: string; 240 | /** A valid URL for the audio file */ 241 | audio_url: string; 242 | /** Title */ 243 | title: string; 244 | /** Caption, 0-1024 characters after entities parsing */ 245 | caption?: string; 246 | /** Mode for parsing entities in the audio caption. See formatting options for more details. */ 247 | parse_mode?: ParseMode; 248 | /** List of special entities that appear in the caption, which can be specified instead of parse_mode */ 249 | caption_entities?: MessageEntity[]; 250 | /** Performer */ 251 | performer?: string; 252 | /** Audio duration in seconds */ 253 | audio_duration?: number; 254 | /** Inline keyboard attached to the message */ 255 | reply_markup?: InlineKeyboardMarkup; 256 | /** Content of the message to be sent instead of the audio */ 257 | input_message_content?: InputMessageContent; 258 | } 259 | 260 | /** Represents a link to a voice recording in an .OGG container encoded with OPUS. By default, this voice recording will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the the voice message. */ 261 | export interface InlineQueryResultVoice { 262 | /** Type of the result, must be voice */ 263 | type: "voice"; 264 | /** Unique identifier for this result, 1-64 bytes */ 265 | id: string; 266 | /** A valid URL for the voice recording */ 267 | voice_url: string; 268 | /** Recording title */ 269 | title: string; 270 | /** Caption, 0-1024 characters after entities parsing */ 271 | caption?: string; 272 | /** Mode for parsing entities in the voice message caption. See formatting options for more details. */ 273 | parse_mode?: ParseMode; 274 | /** List of special entities that appear in the caption, which can be specified instead of parse_mode */ 275 | caption_entities?: MessageEntity[]; 276 | /** Recording duration in seconds */ 277 | voice_duration?: number; 278 | /** Inline keyboard attached to the message */ 279 | reply_markup?: InlineKeyboardMarkup; 280 | /** Content of the message to be sent instead of the voice recording */ 281 | input_message_content?: InputMessageContent; 282 | } 283 | 284 | /** Represents a link to a file. By default, this file will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the file. Currently, only .PDF and .ZIP files can be sent using this method. */ 285 | export interface InlineQueryResultDocument { 286 | /** Type of the result, must be document */ 287 | type: "document"; 288 | /** Unique identifier for this result, 1-64 bytes */ 289 | id: string; 290 | /** Title for the result */ 291 | title: string; 292 | /** Caption of the document to be sent, 0-1024 characters after entities parsing */ 293 | caption?: string; 294 | /** Mode for parsing entities in the document caption. See formatting options for more details. */ 295 | parse_mode?: ParseMode; 296 | /** List of special entities that appear in the caption, which can be specified instead of parse_mode */ 297 | caption_entities?: MessageEntity[]; 298 | /** A valid URL for the file */ 299 | document_url: string; 300 | /** MIME type of the content of the file, either “application/pdf” or “application/zip” */ 301 | mime_type: "application/pdf" | "application/zip"; 302 | /** Short description of the result */ 303 | description?: string; 304 | /** Inline keyboard attached to the message */ 305 | reply_markup?: InlineKeyboardMarkup; 306 | /** Content of the message to be sent instead of the file */ 307 | input_message_content?: InputMessageContent; 308 | /** URL of the thumbnail (JPEG only) for the file */ 309 | thumbnail_url?: string; 310 | /** Thumbnail width */ 311 | thumbnail_width?: number; 312 | /** Thumbnail height */ 313 | thumbnail_height?: number; 314 | } 315 | 316 | /** Represents a location on a map. By default, the location will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the location. */ 317 | export interface InlineQueryResultLocation { 318 | /** Type of the result, must be location */ 319 | type: "location"; 320 | /** Unique identifier for this result, 1-64 Bytes */ 321 | id: string; 322 | /** Location latitude in degrees */ 323 | latitude: number; 324 | /** Location longitude in degrees */ 325 | longitude: number; 326 | /** Location title */ 327 | title: string; 328 | /** The radius of uncertainty for the location, measured in meters; 0-1500 */ 329 | horizontal_accuracy?: number; 330 | /** Period in seconds during which the location can be updated, should be between 60 and 86400, or 0x7FFFFFFF for live locations that can be edited indefinitely. */ 331 | live_period?: number; 332 | /** For live locations, a direction in which the user is moving, in degrees. Must be between 1 and 360 if specified. */ 333 | heading?: number; 334 | /** For live locations, a maximum distance for proximity alerts about approaching another chat member, in meters. Must be between 1 and 100000 if specified. */ 335 | proximity_alert_radius?: number; 336 | /** Inline keyboard attached to the message */ 337 | reply_markup?: InlineKeyboardMarkup; 338 | /** Content of the message to be sent instead of the location */ 339 | input_message_content?: InputMessageContent; 340 | /** Url of the thumbnail for the result */ 341 | thumbnail_url?: string; 342 | /** Thumbnail width */ 343 | thumbnail_width?: number; 344 | /** Thumbnail height */ 345 | thumbnail_height?: number; 346 | } 347 | 348 | /** Represents a venue. By default, the venue will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the venue. */ 349 | export interface InlineQueryResultVenue { 350 | /** Type of the result, must be venue */ 351 | type: "venue"; 352 | /** Unique identifier for this result, 1-64 Bytes */ 353 | id: string; 354 | /** Latitude of the venue location in degrees */ 355 | latitude: number; 356 | /** Longitude of the venue location in degrees */ 357 | longitude: number; 358 | /** Title of the venue */ 359 | title: string; 360 | /** Address of the venue */ 361 | address: string; 362 | /** Foursquare identifier of the venue if known */ 363 | foursquare_id?: string; 364 | /** Foursquare type of the venue, if known. (For example, “arts_entertainment/default”, “arts_entertainment/aquarium” or “food/icecream”.) */ 365 | foursquare_type?: string; 366 | /** Google Places identifier of the venue */ 367 | google_place_id?: string; 368 | /** Google Places type of the venue. (See supported types.) */ 369 | google_place_type?: string; 370 | /** Inline keyboard attached to the message */ 371 | reply_markup?: InlineKeyboardMarkup; 372 | /** Content of the message to be sent instead of the venue */ 373 | input_message_content?: InputMessageContent; 374 | /** Url of the thumbnail for the result */ 375 | thumbnail_url?: string; 376 | /** Thumbnail width */ 377 | thumbnail_width?: number; 378 | /** Thumbnail height */ 379 | thumbnail_height?: number; 380 | } 381 | 382 | /** Represents a contact with a phone number. By default, this contact will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the contact. */ 383 | export interface InlineQueryResultContact { 384 | /** Type of the result, must be contact */ 385 | type: "contact"; 386 | /** Unique identifier for this result, 1-64 Bytes */ 387 | id: string; 388 | /** Contact's phone number */ 389 | phone_number: string; 390 | /** Contact's first name */ 391 | first_name: string; 392 | /** Contact's last name */ 393 | last_name?: string; 394 | /** Additional data about the contact in the form of a vCard, 0-2048 bytes */ 395 | vcard?: string; 396 | /** Inline keyboard attached to the message */ 397 | reply_markup?: InlineKeyboardMarkup; 398 | /** Content of the message to be sent instead of the contact */ 399 | input_message_content?: InputMessageContent; 400 | /** Url of the thumbnail for the result */ 401 | thumbnail_url?: string; 402 | /** Thumbnail width */ 403 | thumbnail_width?: number; 404 | /** Thumbnail height */ 405 | thumbnail_height?: number; 406 | } 407 | 408 | /** Represents a Game. */ 409 | export interface InlineQueryResultGame { 410 | /** Type of the result, must be game */ 411 | type: "game"; 412 | /** Unique identifier for this result, 1-64 bytes */ 413 | id: string; 414 | /** Short name of the game */ 415 | game_short_name: string; 416 | /** Inline keyboard attached to the message */ 417 | reply_markup?: InlineKeyboardMarkup; 418 | } 419 | 420 | /** Represents a link to a photo stored on the Telegram servers. By default, this photo will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the photo. */ 421 | export interface InlineQueryResultCachedPhoto { 422 | /** Type of the result, must be photo */ 423 | type: "photo"; 424 | /** Unique identifier for this result, 1-64 bytes */ 425 | id: string; 426 | /** A valid file identifier of the photo */ 427 | photo_file_id: string; 428 | /** Title for the result */ 429 | title?: string; 430 | /** Short description of the result */ 431 | description?: string; 432 | /** Caption of the photo to be sent, 0-1024 characters after entities parsing */ 433 | caption?: string; 434 | /** Pass True, if the caption must be shown above the message media */ 435 | show_caption_above_media?: boolean; 436 | /** Mode for parsing entities in the photo caption. See formatting options for more details. */ 437 | parse_mode?: ParseMode; 438 | /** List of special entities that appear in the caption, which can be specified instead of parse_mode */ 439 | caption_entities?: MessageEntity[]; 440 | /** Inline keyboard attached to the message */ 441 | reply_markup?: InlineKeyboardMarkup; 442 | /** Content of the message to be sent instead of the photo */ 443 | input_message_content?: InputMessageContent; 444 | } 445 | 446 | /** Represents a link to an animated GIF file stored on the Telegram servers. By default, this animated GIF file will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with specified content instead of the animation. */ 447 | export interface InlineQueryResultCachedGif { 448 | /** Type of the result, must be gif */ 449 | type: "gif"; 450 | /** Unique identifier for this result, 1-64 bytes */ 451 | id: string; 452 | /** A valid file identifier for the GIF file */ 453 | gif_file_id: string; 454 | /** Title for the result */ 455 | title?: string; 456 | /** Caption of the GIF file to be sent, 0-1024 characters after entities parsing */ 457 | caption?: string; 458 | /** Pass True, if the caption must be shown above the message media */ 459 | show_caption_above_media?: boolean; 460 | /** Mode for parsing entities in the caption. See formatting options for more details. */ 461 | parse_mode?: ParseMode; 462 | /** List of special entities that appear in the caption, which can be specified instead of parse_mode */ 463 | caption_entities?: MessageEntity[]; 464 | /** Inline keyboard attached to the message */ 465 | reply_markup?: InlineKeyboardMarkup; 466 | /** Content of the message to be sent instead of the GIF animation */ 467 | input_message_content?: InputMessageContent; 468 | } 469 | 470 | /** Represents a link to a video animation (H.264/MPEG-4 AVC video without sound) stored on the Telegram servers. By default, this animated MPEG-4 file will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the animation. */ 471 | export interface InlineQueryResultCachedMpeg4Gif { 472 | /** Type of the result, must be mpeg4_gif */ 473 | type: "mpeg4_gif"; 474 | /** Unique identifier for this result, 1-64 bytes */ 475 | id: string; 476 | /** A valid file identifier for the MPEG4 file */ 477 | mpeg4_file_id: string; 478 | /** Title for the result */ 479 | title?: string; 480 | /** Caption of the MPEG-4 file to be sent, 0-1024 characters after entities parsing */ 481 | caption?: string; 482 | /** Pass True, if the caption must be shown above the message media */ 483 | show_caption_above_media?: boolean; 484 | /** Mode for parsing entities in the caption. See formatting options for more details. */ 485 | parse_mode?: ParseMode; 486 | /** List of special entities that appear in the caption, which can be specified instead of parse_mode */ 487 | caption_entities?: MessageEntity[]; 488 | /** Inline keyboard attached to the message */ 489 | reply_markup?: InlineKeyboardMarkup; 490 | /** Content of the message to be sent instead of the video animation */ 491 | input_message_content?: InputMessageContent; 492 | } 493 | 494 | /** Represents a link to a sticker stored on the Telegram servers. By default, this sticker will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the sticker. */ 495 | export interface InlineQueryResultCachedSticker { 496 | /** Type of the result, must be sticker */ 497 | type: "sticker"; 498 | /** Unique identifier for this result, 1-64 bytes */ 499 | id: string; 500 | /** A valid file identifier of the sticker */ 501 | sticker_file_id: string; 502 | /** Inline keyboard attached to the message */ 503 | reply_markup?: InlineKeyboardMarkup; 504 | /** Content of the message to be sent instead of the sticker */ 505 | input_message_content?: InputMessageContent; 506 | } 507 | 508 | /** Represents a link to a file stored on the Telegram servers. By default, this file will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the file. */ 509 | export interface InlineQueryResultCachedDocument { 510 | /** Type of the result, must be document */ 511 | type: "document"; 512 | /** Unique identifier for this result, 1-64 bytes */ 513 | id: string; 514 | /** Title for the result */ 515 | title: string; 516 | /** A valid file identifier for the file */ 517 | document_file_id: string; 518 | /** Short description of the result */ 519 | description?: string; 520 | /** Caption of the document to be sent, 0-1024 characters after entities parsing */ 521 | caption?: string; 522 | /** Mode for parsing entities in the document caption. See formatting options for more details. */ 523 | parse_mode?: ParseMode; 524 | /** List of special entities that appear in the caption, which can be specified instead of parse_mode */ 525 | caption_entities?: MessageEntity[]; 526 | /** Inline keyboard attached to the message */ 527 | reply_markup?: InlineKeyboardMarkup; 528 | /** Content of the message to be sent instead of the file */ 529 | input_message_content?: InputMessageContent; 530 | } 531 | 532 | /** Represents a link to a video file stored on the Telegram servers. By default, this video file will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the video. */ 533 | export interface InlineQueryResultCachedVideo { 534 | /** Type of the result, must be video */ 535 | type: "video"; 536 | /** Unique identifier for this result, 1-64 bytes */ 537 | id: string; 538 | /** A valid file identifier for the video file */ 539 | video_file_id: string; 540 | /** Title for the result */ 541 | title: string; 542 | /** Short description of the result */ 543 | description?: string; 544 | /** Caption of the video to be sent, 0-1024 characters after entities parsing */ 545 | caption?: string; 546 | /** Pass True, if the caption must be shown above the message media */ 547 | show_caption_above_media?: boolean; 548 | /** Mode for parsing entities in the video caption. See formatting options for more details. */ 549 | parse_mode?: ParseMode; 550 | /** List of special entities that appear in the caption, which can be specified instead of parse_mode */ 551 | caption_entities?: MessageEntity[]; 552 | /** Inline keyboard attached to the message */ 553 | reply_markup?: InlineKeyboardMarkup; 554 | /** Content of the message to be sent instead of the video */ 555 | input_message_content?: InputMessageContent; 556 | } 557 | 558 | /** Represents a link to a voice message stored on the Telegram servers. By default, this voice message will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the voice message. */ 559 | export interface InlineQueryResultCachedVoice { 560 | /** Type of the result, must be voice */ 561 | type: "voice"; 562 | /** Unique identifier for this result, 1-64 bytes */ 563 | id: string; 564 | /** A valid file identifier for the voice message */ 565 | voice_file_id: string; 566 | /** Voice message title */ 567 | title: string; 568 | /** Caption, 0-1024 characters after entities parsing */ 569 | caption?: string; 570 | /** Mode for parsing entities in the voice message caption. See formatting options for more details. */ 571 | parse_mode?: ParseMode; 572 | /** List of special entities that appear in the caption, which can be specified instead of parse_mode */ 573 | caption_entities?: MessageEntity[]; 574 | /** Inline keyboard attached to the message */ 575 | reply_markup?: InlineKeyboardMarkup; 576 | /** Content of the message to be sent instead of the voice message */ 577 | input_message_content?: InputMessageContent; 578 | } 579 | 580 | /** Represents a link to an MP3 audio file stored on the Telegram servers. By default, this audio file will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the audio. */ 581 | export interface InlineQueryResultCachedAudio { 582 | /** Type of the result, must be audio */ 583 | type: "audio"; 584 | /** Unique identifier for this result, 1-64 bytes */ 585 | id: string; 586 | /** A valid file identifier for the audio file */ 587 | audio_file_id: string; 588 | /** Caption, 0-1024 characters after entities parsing */ 589 | caption?: string; 590 | /** Mode for parsing entities in the audio caption. See formatting options for more details. */ 591 | parse_mode?: ParseMode; 592 | /** List of special entities that appear in the caption, which can be specified instead of parse_mode */ 593 | caption_entities?: MessageEntity[]; 594 | /** Inline keyboard attached to the message */ 595 | reply_markup?: InlineKeyboardMarkup; 596 | /** Content of the message to be sent instead of the audio */ 597 | input_message_content?: InputMessageContent; 598 | } 599 | 600 | /** This object represents the content of a message to be sent as a result of an inline query. Telegram clients currently support the following 5 types: 601 | 602 | - InputTextMessageContent 603 | - InputLocationMessageContent 604 | - InputVenueMessageContent 605 | - InputContactMessageContent 606 | - InputInvoiceMessageContent */ 607 | export type InputMessageContent = 608 | | InputTextMessageContent 609 | | InputLocationMessageContent 610 | | InputVenueMessageContent 611 | | InputContactMessageContent 612 | | InputInvoiceMessageContent; 613 | 614 | /** Represents the content of a text message to be sent as the result of an inline query. */ 615 | export interface InputTextMessageContent { 616 | /** Text of the message to be sent, 1-4096 characters */ 617 | message_text: string; 618 | /** Mode for parsing entities in the message text. See formatting options for more details. */ 619 | parse_mode?: ParseMode; 620 | /** List of special entities that appear in message text, which can be specified instead of parse_mode */ 621 | entities?: MessageEntity[]; 622 | /** Link preview generation options for the message */ 623 | link_preview_options?: LinkPreviewOptions; 624 | } 625 | 626 | /** Represents the content of a location message to be sent as the result of an inline query. */ 627 | export interface InputLocationMessageContent { 628 | /** Latitude of the location in degrees */ 629 | latitude: number; 630 | /** Longitude of the location in degrees */ 631 | longitude: number; 632 | /** The radius of uncertainty for the location, measured in meters; 0-1500 */ 633 | horizontal_accuracy?: number; 634 | /** Period in seconds during which the location can be updated, should be between 60 and 86400, or 0x7FFFFFFF for live locations that can be edited indefinitely. */ 635 | live_period?: number; 636 | /** For live locations, a direction in which the user is moving, in degrees. Must be between 1 and 360 if specified. */ 637 | heading?: number; 638 | /** For live locations, a maximum distance for proximity alerts about approaching another chat member, in meters. Must be between 1 and 100000 if specified. */ 639 | proximity_alert_radius?: number; 640 | } 641 | 642 | /** Represents the content of a venue message to be sent as the result of an inline query. */ 643 | export interface InputVenueMessageContent { 644 | /** Latitude of the venue in degrees */ 645 | latitude: number; 646 | /** Longitude of the venue in degrees */ 647 | longitude: number; 648 | /** Name of the venue */ 649 | title: string; 650 | /** Address of the venue */ 651 | address: string; 652 | /** Foursquare identifier of the venue, if known */ 653 | foursquare_id?: string; 654 | /** Foursquare type of the venue, if known. (For example, “arts_entertainment/default”, “arts_entertainment/aquarium” or “food/icecream”.) */ 655 | foursquare_type?: string; 656 | /** Google Places identifier of the venue */ 657 | google_place_id?: string; 658 | /** Google Places type of the venue. (See supported types.) */ 659 | google_place_type?: string; 660 | } 661 | 662 | /** Represents the content of a contact message to be sent as the result of an inline query. */ 663 | export interface InputContactMessageContent { 664 | /** Contact's phone number */ 665 | phone_number: string; 666 | /** Contact's first name */ 667 | first_name: string; 668 | /** Contact's last name */ 669 | last_name?: string; 670 | /** Additional data about the contact in the form of a vCard, 0-2048 bytes */ 671 | vcard?: string; 672 | } 673 | 674 | /** Represents the content of an invoice message to be sent as the result of an inline query. */ 675 | export interface InputInvoiceMessageContent { 676 | /** Product name, 1-32 characters */ 677 | title: string; 678 | /** Product description, 1-255 characters */ 679 | description: string; 680 | /** Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use it for your internal processes. */ 681 | payload: string; 682 | /** Payment provider token, obtained via @BotFather. Pass an empty string for payments in Telegram Stars. */ 683 | provider_token?: string; 684 | /** Three-letter ISO 4217 currency code, see more on currencies. Pass “XTR” for payments in Telegram Stars. */ 685 | currency: string; 686 | /** Price breakdown, a JSON-serialized list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.). Must contain exactly one item for payments in Telegram Stars. */ 687 | prices: LabeledPrice[]; 688 | /** The maximum accepted amount for tips in the smallest units of the currency (integer, not float/double). For example, for a maximum tip of US$ 1.45 pass max_tip_amount = 145. See the exp parameter in currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies). Defaults to 0. Not supported for payments in Telegram Stars. */ 689 | max_tip_amount?: number; 690 | /** An array of suggested amounts of tip in the smallest units of the currency (integer, not float/double). At most 4 suggested tip amounts can be specified. The suggested tip amounts must be positive, passed in a strictly increased order and must not exceed max_tip_amount. */ 691 | suggested_tip_amounts?: number[]; 692 | /** Data about the invoice, which will be shared with the payment provider. A detailed description of the required fields should be provided by the payment provider. */ 693 | provider_data?: string; 694 | /** URL of the product photo for the invoice. Can be a photo of the goods or a marketing image for a service. */ 695 | photo_url?: string; 696 | /** Photo size in bytes */ 697 | photo_size?: number; 698 | /** Photo width */ 699 | photo_width?: number; 700 | /** Photo height */ 701 | photo_height?: number; 702 | /** Pass True if you require the user's full name to complete the order. Ignored for payments in Telegram Stars. */ 703 | need_name?: boolean; 704 | /** Pass True if you require the user's phone number to complete the order. Ignored for payments in Telegram Stars. */ 705 | need_phone_number?: boolean; 706 | /** Pass True if you require the user's email address to complete the order. Ignored for payments in Telegram Stars. */ 707 | need_email?: boolean; 708 | /** Pass True if you require the user's shipping address to complete the order. Ignored for payments in Telegram Stars. */ 709 | need_shipping_address?: boolean; 710 | /** Pass True if the user's phone number should be sent to provider. Ignored for payments in Telegram Stars. */ 711 | send_phone_number_to_provider?: boolean; 712 | /** Pass True if the user's email address should be sent to provider. Ignored for payments in Telegram Stars. */ 713 | send_email_to_provider?: boolean; 714 | /** Pass True if the final price depends on the shipping method. Ignored for payments in Telegram Stars. */ 715 | is_flexible?: boolean; 716 | } 717 | 718 | /** Represents a result of an inline query that was chosen by the user and sent to their chat partner. 719 | 720 | Note: It is necessary to enable inline feedback via @BotFather in order to receive these objects in updates. */ 721 | export interface ChosenInlineResult { 722 | /** The unique identifier for the result that was chosen */ 723 | result_id: string; 724 | /** The user that chose the result */ 725 | from: User; 726 | /** Sender location, only for bots that require user location */ 727 | location?: Location; 728 | /** Identifier of the sent inline message. Available only if there is an inline keyboard attached to the message. Will be also received in callback queries and can be used to edit the message. */ 729 | inline_message_id?: string; 730 | /** The query that was used to obtain the result */ 731 | query: string; 732 | } 733 | 734 | /** This object represents a button to be shown above inline query results. You must use exactly one of the optional fields. 735 | 736 | Example: An inline bot that sends YouTube videos can ask the user to connect the bot to their YouTube account to adapt search results accordingly. To do this, it displays a 'Connect your YouTube account' button above the results, or even before showing any. The user presses the button, switches to a private chat with the bot and, in doing so, passes a start parameter that instructs the bot to return an OAuth link. Once done, the bot can offer a switch_inline button so that the user can easily return to the chat where they wanted to use the bot's inline capabilities. */ 737 | export interface InlineQueryResultsButton { 738 | /** Label text on the button */ 739 | text: string; 740 | /** Description of the Web App that will be launched when the user presses the button. The Web App will be able to switch back to the inline mode using the method web_app_switch_inline_query inside the Web App. */ 741 | web_app?: WebAppInfo; 742 | /** Deep-linking parameter for the /start message sent to the bot when a user presses the button. 1-64 characters, only `A-Z`, `a-z`, `0-9`, `_` and `-` are allowed. */ 743 | start_parameter?: string; 744 | } 745 | -------------------------------------------------------------------------------- /langs.ts: -------------------------------------------------------------------------------- 1 | /** A two-letter ISO 639-1 language code. 2 | * @see https://en.wikipedia.org/wiki/List_of_ISO_639_language_codes 3 | * @see https://www.loc.gov/standards/iso639-2/php/code_list.php 4 | */ 5 | export type LanguageCode = typeof LanguageCodes[keyof typeof LanguageCodes]; 6 | 7 | /** 8 | * @see {@link LanguageCode} 9 | */ 10 | export const LanguageCodes = { 11 | Abkhazian: "ab", 12 | Afar: "aa", 13 | Afrikaans: "af", 14 | Akan: "ak", 15 | Albanian: "sq", 16 | Amharic: "am", 17 | Arabic: "ar", 18 | Aragonese: "an", 19 | Armenian: "hy", 20 | Assamese: "as", 21 | Avaric: "av", 22 | Avestan: "ae", 23 | Aymara: "ay", 24 | Azerbaijani: "az", 25 | Bambara: "bm", 26 | Bashkir: "ba", 27 | Basque: "eu", 28 | Belarusian: "be", 29 | Bengali: "bn", 30 | Bislama: "bi", 31 | Bosnian: "bs", 32 | Breton: "br", 33 | Bulgarian: "bg", 34 | Burmese: "my", 35 | Catalan: "ca", 36 | Chamorro: "ch", 37 | Chechen: "ce", 38 | Chichewa: "ny", 39 | Chinese: "zh", 40 | ChurchSlavonic: "cu", 41 | Chuvash: "cv", 42 | Cornish: "kw", 43 | Corsican: "co", 44 | Cree: "cr", 45 | Croatian: "hr", 46 | Czech: "cs", 47 | Danish: "da", 48 | Divehi: "dv", 49 | Dutch: "nl", 50 | Dzongkha: "dz", 51 | English: "en", 52 | Esperanto: "eo", 53 | Estonian: "et", 54 | Ewe: "ee", 55 | Faroese: "fo", 56 | Fijian: "fj", 57 | Finnish: "fi", 58 | French: "fr", 59 | WesternFrisian: "fy", 60 | Fulah: "ff", 61 | Gaelic: "gd", 62 | Galician: "gl", 63 | Ganda: "lg", 64 | Georgian: "ka", 65 | German: "de", 66 | Greek: "el", 67 | Kalaallisut: "kl", 68 | Guarani: "gn", 69 | Gujarati: "gu", 70 | Haitian: "ht", 71 | Hausa: "ha", 72 | Hebrew: "he", 73 | Herero: "hz", 74 | Hindi: "hi", 75 | HiriMotu: "ho", 76 | Hungarian: "hu", 77 | Icelandic: "is", 78 | Ido: "io", 79 | Igbo: "ig", 80 | Indonesian: "id", 81 | Interlingua: "ia", 82 | Interlingue: "ie", 83 | Inuktitut: "iu", 84 | Inupiaq: "ik", 85 | Irish: "ga", 86 | Italian: "it", 87 | Japanese: "ja", 88 | Javanese: "jv", 89 | Kannada: "kn", 90 | Kanuri: "kr", 91 | Kashmiri: "ks", 92 | Kazakh: "kk", 93 | CentralKhmer: "km", 94 | Kikuyu: "ki", 95 | Kinyarwanda: "rw", 96 | Kirghiz: "ky", 97 | Komi: "kv", 98 | Kongo: "kg", 99 | Korean: "ko", 100 | Kuanyama: "kj", 101 | Kurdish: "ku", 102 | Lao: "lo", 103 | Latin: "la", 104 | Latvian: "lv", 105 | Limburgan: "li", 106 | Lingala: "ln", 107 | Lithuanian: "lt", 108 | LubaKatanga: "lu", 109 | Luxembourgish: "lb", 110 | Macedonian: "mk", 111 | Malagasy: "mg", 112 | Malay: "ms", 113 | Malayalam: "ml", 114 | Maltese: "mt", 115 | Manx: "gv", 116 | Maori: "mi", 117 | Marathi: "mr", 118 | Marshallese: "mh", 119 | Mongolian: "mn", 120 | Nauru: "na", 121 | Navajo: "nv", 122 | NorthNdebele: "nd", 123 | SouthNdebele: "nr", 124 | Ndonga: "ng", 125 | Nepali: "ne", 126 | Norwegian: "no", 127 | NorwegianBokmål: "nb", 128 | NorwegianNynorsk: "nn", 129 | SichuanYi: "ii", 130 | Occitan: "oc", 131 | Ojibwa: "oj", 132 | Oriya: "or", 133 | Oromo: "om", 134 | Ossetian: "os", 135 | Pali: "pi", 136 | Pashto: "ps", 137 | Persian: "fa", 138 | Polish: "pl", 139 | Portuguese: "pt", 140 | Punjabi: "pa", 141 | Quechua: "qu", 142 | Romanian: "ro", 143 | Romansh: "rm", 144 | Rundi: "rn", 145 | Russian: "ru", 146 | NorthernSami: "se", 147 | Samoan: "sm", 148 | Sango: "sg", 149 | Sanskrit: "sa", 150 | Sardinian: "sc", 151 | Serbian: "sr", 152 | Shona: "sn", 153 | Sindhi: "sd", 154 | Sinhala: "si", 155 | Slovak: "sk", 156 | Slovenian: "sl", 157 | Somali: "so", 158 | SouthernSotho: "st", 159 | Spanish: "es", 160 | Sundanese: "su", 161 | Swahili: "sw", 162 | Swati: "ss", 163 | Swedish: "sv", 164 | Tagalog: "tl", 165 | Tahitian: "ty", 166 | Tajik: "tg", 167 | Tamil: "ta", 168 | Tatar: "tt", 169 | Telugu: "te", 170 | Thai: "th", 171 | Tibetan: "bo", 172 | Tigrinya: "ti", 173 | Tonga: "to", 174 | Tsonga: "ts", 175 | Tswana: "tn", 176 | Turkish: "tr", 177 | Turkmen: "tk", 178 | Twi: "tw", 179 | Uighur: "ug", 180 | Ukrainian: "uk", 181 | Urdu: "ur", 182 | Uzbek: "uz", 183 | Venda: "ve", 184 | Vietnamese: "vi", 185 | Volapük: "vo", 186 | Walloon: "wa", 187 | Welsh: "cy", 188 | Wolof: "wo", 189 | Xhosa: "xh", 190 | Yiddish: "yi", 191 | Yoruba: "yo", 192 | Zhuang: "za", 193 | Zulu: "zu", 194 | } as const; 195 | -------------------------------------------------------------------------------- /manage.ts: -------------------------------------------------------------------------------- 1 | import type { 2 | Location, 3 | Message, 4 | PhotoSize, 5 | ReactionType, 6 | Sticker, 7 | } from "./message.ts"; 8 | import type { Update } from "./update.ts"; 9 | 10 | /** Describes the current status of a webhook. */ 11 | export interface WebhookInfo { 12 | /** Webhook URL, may be empty if webhook is not set up */ 13 | url?: string; 14 | /** True, if a custom certificate was provided for webhook certificate checks */ 15 | has_custom_certificate: boolean; 16 | /** Number of updates awaiting delivery */ 17 | pending_update_count: number; 18 | /** Currently used webhook IP address */ 19 | ip_address?: string; 20 | /** Unix time for the most recent error that happened when trying to deliver an update via webhook */ 21 | last_error_date?: number; 22 | /** Error message in human-readable format for the most recent error that happened when trying to deliver an update via webhook */ 23 | last_error_message?: string; 24 | /** Unix time of the most recent error that happened when trying to synchronize available updates with Telegram datacenters */ 25 | last_synchronization_error_date?: number; 26 | /** The maximum allowed number of simultaneous HTTPS connections to the webhook for update delivery */ 27 | max_connections?: number; 28 | /** A list of update types the bot is subscribed to. Defaults to all update types except chat_member */ 29 | allowed_updates?: Array>; 30 | } 31 | 32 | /** This object describes the types of gifts that can be gifted to a user or a chat. */ 33 | export interface AcceptedGiftTypes { 34 | /** True, if unlimited regular gifts are accepted */ 35 | unlimited_gifts: boolean; 36 | /** True, if limited regular gifts are accepted */ 37 | limited_gifts: boolean; 38 | /** True, if unique gifts or gifts that can be upgraded to unique for free are accepted */ 39 | unique_gifts: boolean; 40 | /** True, if a Telegram Premium subscription is accepted */ 41 | premium_subscription: boolean; 42 | } 43 | 44 | /** This object represents a Telegram user or bot. */ 45 | export interface User { 46 | /** Unique identifier for this user or bot. */ 47 | id: number; 48 | /** True, if this user is a bot */ 49 | is_bot: boolean; 50 | /** User's or bot's first name */ 51 | first_name: string; 52 | /** User's or bot's last name */ 53 | last_name?: string; 54 | /** User's or bot's username */ 55 | username?: string; 56 | /** IETF language tag of the user's language */ 57 | language_code?: string; 58 | /** True, if this user is a Telegram Premium user */ 59 | is_premium?: true; 60 | /** True, if this user added the bot to the attachment menu */ 61 | added_to_attachment_menu?: true; 62 | } 63 | 64 | /** This object represents a Telegram user or bot that was returned by `getMe`. */ 65 | export interface UserFromGetMe extends User { 66 | is_bot: true; 67 | username: string; 68 | /** True, if the bot can be invited to groups. Returned only in getMe. */ 69 | can_join_groups: boolean; 70 | /** True, if privacy mode is disabled for the bot. Returned only in getMe. */ 71 | can_read_all_group_messages: boolean; 72 | /** True, if the bot supports inline queries. Returned only in getMe. */ 73 | supports_inline_queries: boolean; 74 | /** True, if the bot can be connected to a Telegram Business account to receive its messages. Returned only in getMe. */ 75 | can_connect_to_business: boolean; 76 | /** True, if the bot has main Web App. Returned only in getMe. */ 77 | has_main_web_app: boolean; 78 | } 79 | 80 | export declare namespace Chat { 81 | /** Internal type for private chats */ 82 | export interface PrivateChat { 83 | /** Unique identifier for this chat. */ 84 | id: number; 85 | /** Type of the chat, can be either “private”, “group”, “supergroup” or “channel” */ 86 | type: "private"; 87 | /** Title, for supergroups, channels and group chats */ 88 | title?: undefined; 89 | /** Username, for private chats, supergroups and channels if available */ 90 | username?: string; 91 | /** First name of the other party in a private chat */ 92 | first_name: string; 93 | /** Last name of the other party in a private chat */ 94 | last_name?: string; 95 | /** True, if the supergroup chat is a forum (has topics enabled) */ 96 | is_forum?: undefined; 97 | } 98 | /** Internal type for group chats */ 99 | export interface GroupChat { 100 | /** Unique identifier for this chat. */ 101 | id: number; 102 | /** Type of the chat, can be either “private”, “group”, “supergroup” or “channel” */ 103 | type: "group"; 104 | /** Title, for supergroups, channels and group chats */ 105 | title: string; 106 | /** Username, for private chats, supergroups and channels if available */ 107 | username?: undefined; 108 | /** First name of the other party in a private chat */ 109 | first_name?: undefined; 110 | /** Last name of the other party in a private chat */ 111 | last_name?: undefined; 112 | /** True, if the supergroup chat is a forum (has topics enabled) */ 113 | is_forum?: undefined; 114 | } 115 | /** Internal type for supergroup chats */ 116 | export interface SupergroupChat { 117 | /** Unique identifier for this chat. */ 118 | id: number; 119 | /** Type of the chat, can be either “private”, “group”, “supergroup” or “channel” */ 120 | type: "supergroup"; 121 | /** Title, for supergroups, channels and group chats */ 122 | title: string; 123 | /** Username, for private chats, supergroups and channels if available */ 124 | username?: string; 125 | /** First name of the other party in a private chat */ 126 | first_name?: undefined; 127 | /** Last name of the other party in a private chat */ 128 | last_name?: undefined; 129 | /** True, if the supergroup chat is a forum (has topics enabled) */ 130 | is_forum?: true; 131 | } 132 | /** Internal type for channel chats */ 133 | export interface ChannelChat { 134 | /** Unique identifier for this chat. */ 135 | id: number; 136 | /** Type of the chat, can be either “private”, “group”, “supergroup” or “channel” */ 137 | type: "channel"; 138 | /** Title, for supergroups, channels and group chats */ 139 | title: string; 140 | /** Username, for private chats, supergroups and channels if available */ 141 | username?: string; 142 | /** First name of the other party in a private chat */ 143 | first_name?: undefined; 144 | /** Last name of the other party in a private chat */ 145 | last_name?: undefined; 146 | /** True, if the supergroup chat is a forum (has topics enabled) */ 147 | is_forum?: undefined; 148 | } 149 | } 150 | 151 | /** This object represents a chat. */ 152 | export type Chat = 153 | | Chat.PrivateChat 154 | | Chat.GroupChat 155 | | Chat.SupergroupChat 156 | | Chat.ChannelChat; 157 | 158 | export declare namespace ChatFullInfo { 159 | /** Internal type for private chats */ 160 | export interface PrivateChat { 161 | /** Unique identifier for this chat. */ 162 | id: number; 163 | /** Type of the chat, can be either “private”, “group”, “supergroup” or “channel” */ 164 | type: "private"; 165 | /** Title, for supergroups, channels and group chats */ 166 | title?: undefined; 167 | /** Username, for private chats, supergroups and channels if available */ 168 | username?: string; 169 | /** First name of the other party in a private chat */ 170 | first_name: string; 171 | /** Last name of the other party in a private chat */ 172 | last_name?: string; 173 | /** True, if the supergroup chat is a forum (has topics enabled) */ 174 | is_forum?: undefined; 175 | /** Identifier of the accent color for the chat name and backgrounds of the chat photo, reply header, and link preview. See accent colors for more details. */ 176 | accent_color_id: number; 177 | /** The maximum number of reactions that can be set on a message in the chat */ 178 | max_reaction_count: number; 179 | /** Chat photo */ 180 | photo?: ChatPhoto; 181 | /** If non-empty, the list of all active chat usernames; for private chats, supergroups and channels */ 182 | active_usernames?: string[]; 183 | /** For private chats, the date of birth of the user */ 184 | birthdate?: Birthdate; 185 | /** For private chats with business accounts, the intro of the business */ 186 | business_intro?: BusinessIntro; 187 | /** For private chats with business accounts, the location of the business */ 188 | business_location?: BusinessLocation; 189 | /** For private chats with business accounts, the opening hours of the business */ 190 | business_opening_hours?: BusinessOpeningHours; 191 | /** For private chats, the personal channel of the user */ 192 | personal_chat?: Chat; 193 | /** List of available reactions allowed in the chat. If omitted, then all emoji reactions are allowed. */ 194 | available_reactions?: ReactionType[]; 195 | /** Custom emoji identifier of the emoji chosen by the chat for the reply header and link preview background */ 196 | background_custom_emoji_id?: string; 197 | /** Identifier of the accent color for the chat's profile background. See profile accent colors for more details. */ 198 | profile_accent_color_id?: number; 199 | /** Custom emoji identifier of the emoji chosen by the chat for its profile background */ 200 | profile_background_custom_emoji_id?: string; 201 | /** Custom emoji identifier of the emoji status of the chat or the other party in a private chat */ 202 | emoji_status_custom_emoji_id?: string; 203 | /** Expiration date of the emoji status of the chat or the other party in a private chat, in Unix time, if any */ 204 | emoji_status_expiration_date?: number; 205 | /** Bio of the other party in a private chat */ 206 | bio?: string; 207 | /** True, if privacy settings of the other party in the private chat allows to use tg://user?id= links only in chats with the user */ 208 | has_private_forwards?: true; 209 | /** True, if the privacy settings of the other party restrict sending voice and video note messages in the private chat */ 210 | has_restricted_voice_and_video_messages?: true; 211 | /** True, if users need to join the supergroup before they can send messages */ 212 | join_to_send_messages?: undefined; 213 | /** True, if all users directly joining the supergroup without using an invite link need to be approved by supergroup administrators */ 214 | join_by_request?: undefined; 215 | /** Description, for groups, supergroups and channel chats */ 216 | description?: undefined; 217 | /** Primary invite link, for groups, supergroups and channel chats */ 218 | invite_link?: undefined; 219 | /** The most recent pinned message (by sending date) */ 220 | pinned_message?: Message; 221 | /** Default chat member permissions, for groups and supergroups */ 222 | permissions?: undefined; 223 | /** Information about types of gifts that are accepted by the chat or by the corresponding user for private chats */ 224 | accepted_gift_types: AcceptedGiftTypes; 225 | /** True, if paid media messages can be sent or forwarded to the channel chat. The field is available only for channel chats. */ 226 | can_send_paid_media?: undefined; 227 | /** For supergroups, the minimum allowed delay between consecutive messages sent by each unprivileged user; in seconds */ 228 | slow_mode_delay?: undefined; 229 | /** For supergroups, the minimum number of boosts that a non-administrator user needs to add in order to ignore slow mode and chat permissions */ 230 | unrestrict_boost_count?: undefined; 231 | /** The time after which all messages sent to the chat will be automatically deleted; in seconds */ 232 | message_auto_delete_time?: number; 233 | /** True, if aggressive anti-spam checks are enabled in the supergroup. The field is only available to chat administrators. */ 234 | has_aggressive_anti_spam_enabled?: undefined; 235 | /** True, if non-administrators can only get the list of bots and administrators in the chat */ 236 | has_hidden_members?: undefined; 237 | /** True, if messages from the chat can't be forwarded to other chats */ 238 | has_protected_content?: true; 239 | /** True, if new chat members will have access to old messages; available only to chat administrators */ 240 | has_visible_history?: undefined; 241 | /** For supergroups, name of the group sticker set */ 242 | sticker_set_name?: undefined; 243 | /** True, if the bot can change the group sticker set */ 244 | can_set_sticker_set?: undefined; 245 | /** For supergroups, the name of the group's custom emoji sticker set. Custom emoji from this set can be used by all users and bots in the group. */ 246 | custom_emoji_sticker_set_name?: undefined; 247 | /** Unique identifier for the linked chat, i.e. the discussion group identifier for a channel and vice versa; for supergroups and channel chats. */ 248 | linked_chat_id?: undefined; 249 | /** For supergroups, the location to which the supergroup is connected */ 250 | location?: undefined; 251 | } 252 | /** Internal type for group chats */ 253 | export interface GroupChat { 254 | /** Unique identifier for this chat. */ 255 | id: number; 256 | /** Type of the chat, can be either “private”, “group”, “supergroup” or “channel” */ 257 | type: "group"; 258 | /** Title, for supergroups, channels and group chats */ 259 | title: string; 260 | /** Username, for private chats, supergroups and channels if available */ 261 | username?: undefined; 262 | /** First name of the other party in a private chat */ 263 | first_name?: undefined; 264 | /** Last name of the other party in a private chat */ 265 | last_name?: undefined; 266 | /** True, if the supergroup chat is a forum (has topics enabled) */ 267 | is_forum?: undefined; 268 | /** Identifier of the accent color for the chat name and backgrounds of the chat photo, reply header, and link preview. See accent colors for more details. */ 269 | accent_color_id: number; 270 | /** The maximum number of reactions that can be set on a message in the chat */ 271 | max_reaction_count: number; 272 | /** Chat photo */ 273 | photo?: ChatPhoto; 274 | /** If non-empty, the list of all active chat usernames; for private chats, supergroups and channels */ 275 | active_usernames?: undefined; 276 | /** For private chats, the date of birth of the user */ 277 | birthdate?: undefined; 278 | /** For private chats with business accounts, the intro of the business */ 279 | business_intro?: undefined; 280 | /** For private chats with business accounts, the location of the business */ 281 | business_location?: undefined; 282 | /** For private chats with business accounts, the opening hours of the business */ 283 | business_opening_hours?: undefined; 284 | /** For private chats, the personal channel of the user */ 285 | personal_chat?: undefined; 286 | /** List of available reactions allowed in the chat. If omitted, then all emoji reactions are allowed. */ 287 | available_reactions?: ReactionType[]; 288 | /** Custom emoji identifier of the emoji chosen by the chat for the reply header and link preview background */ 289 | background_custom_emoji_id?: string; 290 | /** Identifier of the accent color for the chat's profile background. See profile accent colors for more details. */ 291 | profile_accent_color_id?: number; 292 | /** Custom emoji identifier of the emoji chosen by the chat for its profile background */ 293 | profile_background_custom_emoji_id?: string; 294 | /** Custom emoji identifier of the emoji status of the chat or the other party in a private chat */ 295 | emoji_status_custom_emoji_id?: string; 296 | /** Expiration date of the emoji status of the chat or the other party in a private chat, in Unix time, if any */ 297 | emoji_status_expiration_date?: number; 298 | /** Bio of the other party in a private chat */ 299 | bio?: undefined; 300 | /** True, if privacy settings of the other party in the private chat allows to use tg://user?id= links only in chats with the user */ 301 | has_private_forwards?: undefined; 302 | /** True, if the privacy settings of the other party restrict sending voice and video note messages in the private chat */ 303 | has_restricted_voice_and_video_messages?: undefined; 304 | /** True, if users need to join the supergroup before they can send messages */ 305 | join_to_send_messages?: undefined; 306 | /** True, if all users directly joining the supergroup without using an invite link need to be approved by supergroup administrators */ 307 | join_by_request?: undefined; 308 | /** Description, for groups, supergroups and channel chats */ 309 | description?: string; 310 | /** Primary invite link, for groups, supergroups and channel chats */ 311 | invite_link?: string; 312 | /** The most recent pinned message (by sending date) */ 313 | pinned_message?: Message; 314 | /** Default chat member permissions, for groups and supergroups */ 315 | permissions?: ChatPermissions; 316 | /** True, if gifts can be sent to the chat */ 317 | can_send_gift?: true; 318 | /** True, if paid media messages can be sent or forwarded to the channel chat. The field is available only for channel chats. */ 319 | can_send_paid_media?: undefined; 320 | /** For supergroups, the minimum allowed delay between consecutive messages sent by each unprivileged user; in seconds */ 321 | slow_mode_delay?: undefined; 322 | /** For supergroups, the minimum number of boosts that a non-administrator user needs to add in order to ignore slow mode and chat permissions */ 323 | unrestrict_boost_count?: undefined; 324 | /** The time after which all messages sent to the chat will be automatically deleted; in seconds */ 325 | message_auto_delete_time?: number; 326 | /** True, if aggressive anti-spam checks are enabled in the supergroup. The field is only available to chat administrators. */ 327 | has_aggressive_anti_spam_enabled?: undefined; 328 | /** True, if non-administrators can only get the list of bots and administrators in the chat */ 329 | has_hidden_members?: true; 330 | /** True, if messages from the chat can't be forwarded to other chats */ 331 | has_protected_content?: true; 332 | /** True, if new chat members will have access to old messages; available only to chat administrators */ 333 | has_visible_history?: true; 334 | /** For supergroups, name of the group sticker set */ 335 | sticker_set_name?: undefined; 336 | /** True, if the bot can change the group sticker set */ 337 | can_set_sticker_set?: true; 338 | /** For supergroups, the name of the group's custom emoji sticker set. Custom emoji from this set can be used by all users and bots in the group. */ 339 | custom_emoji_sticker_set_name?: undefined; 340 | /** Unique identifier for the linked chat, i.e. the discussion group identifier for a channel and vice versa; for supergroups and channel chats. */ 341 | linked_chat_id?: undefined; 342 | /** For supergroups, the location to which the supergroup is connected */ 343 | location?: undefined; 344 | } 345 | /** Internal type for supergroup chats */ 346 | export interface SupergroupChat { 347 | /** Unique identifier for this chat. */ 348 | id: number; 349 | /** Type of the chat, can be either “private”, “group”, “supergroup” or “channel” */ 350 | type: "supergroup"; 351 | /** Title, for supergroups, channels and group chats */ 352 | title: string; 353 | /** Username, for private chats, supergroups and channels if available */ 354 | username?: string; 355 | /** First name of the other party in a private chat */ 356 | first_name?: undefined; 357 | /** Last name of the other party in a private chat */ 358 | last_name?: undefined; 359 | /** True, if the supergroup chat is a forum (has topics enabled) */ 360 | is_forum?: true; 361 | /** Identifier of the accent color for the chat name and backgrounds of the chat photo, reply header, and link preview. See accent colors for more details. */ 362 | accent_color_id: number; 363 | /** The maximum number of reactions that can be set on a message in the chat */ 364 | max_reaction_count: number; 365 | /** Chat photo */ 366 | photo?: ChatPhoto; 367 | /** If non-empty, the list of all active chat usernames; for private chats, supergroups and channels */ 368 | active_usernames?: string[]; 369 | /** For private chats, the date of birth of the user */ 370 | birthdate?: undefined; 371 | /** For private chats with business accounts, the intro of the business */ 372 | business_intro?: undefined; 373 | /** For private chats with business accounts, the location of the business */ 374 | business_location?: undefined; 375 | /** For private chats with business accounts, the opening hours of the business */ 376 | business_opening_hours?: undefined; 377 | /** For private chats, the personal channel of the user */ 378 | personal_chat?: undefined; 379 | /** List of available reactions allowed in the chat. If omitted, then all emoji reactions are allowed. */ 380 | available_reactions?: ReactionType[]; 381 | /** Custom emoji identifier of the emoji chosen by the chat for the reply header and link preview background */ 382 | background_custom_emoji_id?: string; 383 | /** Identifier of the accent color for the chat's profile background. See profile accent colors for more details. */ 384 | profile_accent_color_id?: number; 385 | /** Custom emoji identifier of the emoji chosen by the chat for its profile background */ 386 | profile_background_custom_emoji_id?: string; 387 | /** Custom emoji identifier of the emoji status of the chat or the other party in a private chat */ 388 | emoji_status_custom_emoji_id?: string; 389 | /** Expiration date of the emoji status of the chat or the other party in a private chat, in Unix time, if any */ 390 | emoji_status_expiration_date?: number; 391 | /** Bio of the other party in a private chat */ 392 | bio?: string; 393 | /** True, if privacy settings of the other party in the private chat allows to use tg://user?id= links only in chats with the user */ 394 | has_private_forwards?: undefined; 395 | /** True, if the privacy settings of the other party restrict sending voice and video note messages in the private chat */ 396 | has_restricted_voice_and_video_messages?: undefined; 397 | /** True, if users need to join the supergroup before they can send messages */ 398 | join_to_send_messages?: true; 399 | /** True, if all users directly joining the supergroup without using an invite link need to be approved by supergroup administrators */ 400 | join_by_request?: true; 401 | /** Description, for groups, supergroups and channel chats */ 402 | description?: string; 403 | /** Primary invite link, for groups, supergroups and channel chats */ 404 | invite_link?: string; 405 | /** The most recent pinned message (by sending date) */ 406 | pinned_message?: Message; 407 | /** Default chat member permissions, for groups and supergroups */ 408 | permissions?: ChatPermissions; 409 | /** True, if gifts can be sent to the chat */ 410 | can_send_gift?: true; 411 | /** True, if paid media messages can be sent or forwarded to the channel chat. The field is available only for channel chats. */ 412 | can_send_paid_media?: undefined; 413 | /** For supergroups, the minimum allowed delay between consecutive messages sent by each unprivileged user; in seconds */ 414 | slow_mode_delay?: number; 415 | /** For supergroups, the minimum number of boosts that a non-administrator user needs to add in order to ignore slow mode and chat permissions */ 416 | unrestrict_boost_count?: number; 417 | /** The time after which all messages sent to the chat will be automatically deleted; in seconds */ 418 | message_auto_delete_time?: number; 419 | /** True, if aggressive anti-spam checks are enabled in the supergroup. The field is only available to chat administrators. */ 420 | has_aggressive_anti_spam_enabled?: true; 421 | /** True, if non-administrators can only get the list of bots and administrators in the chat */ 422 | has_hidden_members?: true; 423 | /** True, if messages from the chat can't be forwarded to other chats */ 424 | has_protected_content?: true; 425 | /** True, if new chat members will have access to old messages; available only to chat administrators */ 426 | has_visible_history?: true; 427 | /** For supergroups, name of the group sticker set */ 428 | sticker_set_name?: string; 429 | /** True, if the bot can change the group sticker set */ 430 | can_set_sticker_set?: true; 431 | /** For supergroups, the name of the group's custom emoji sticker set. Custom emoji from this set can be used by all users and bots in the group. */ 432 | custom_emoji_sticker_set_name?: string; 433 | /** Unique identifier for the linked chat, i.e. the discussion group identifier for a channel and vice versa; for supergroups and channel chats. */ 434 | linked_chat_id?: number; 435 | /** For supergroups, the location to which the supergroup is connected */ 436 | location?: ChatLocation; 437 | } 438 | /** Internal type for channel chats */ 439 | export interface ChannelChat { 440 | /** Unique identifier for this chat. */ 441 | id: number; 442 | /** Type of the chat, can be either “private”, “group”, “supergroup” or “channel” */ 443 | type: "channel"; 444 | /** Title, for supergroups, channels and group chats */ 445 | title: string; 446 | /** Username, for private chats, supergroups and channels if available */ 447 | username?: string; 448 | /** First name of the other party in a private chat */ 449 | first_name?: undefined; 450 | /** Last name of the other party in a private chat */ 451 | last_name?: undefined; 452 | /** True, if the supergroup chat is a forum (has topics enabled) */ 453 | is_forum?: undefined; 454 | /** Identifier of the accent color for the chat name and backgrounds of the chat photo, reply header, and link preview. See accent colors for more details. */ 455 | accent_color_id: number; 456 | /** The maximum number of reactions that can be set on a message in the chat */ 457 | max_reaction_count: number; 458 | /** Chat photo */ 459 | photo?: ChatPhoto; 460 | /** If non-empty, the list of all active chat usernames; for private chats, supergroups and channels */ 461 | active_usernames?: string[]; 462 | /** For private chats, the date of birth of the user */ 463 | birthdate?: undefined; 464 | /** For private chats with business accounts, the intro of the business */ 465 | business_intro?: undefined; 466 | /** For private chats with business accounts, the location of the business */ 467 | business_location?: undefined; 468 | /** For private chats with business accounts, the opening hours of the business */ 469 | business_opening_hours?: undefined; 470 | /** For private chats, the personal channel of the user */ 471 | personal_chat?: undefined; 472 | /** List of available reactions allowed in the chat. If omitted, then all emoji reactions are allowed. */ 473 | available_reactions?: ReactionType[]; 474 | /** Custom emoji identifier of the emoji chosen by the chat for the reply header and link preview background */ 475 | background_custom_emoji_id?: string; 476 | /** Identifier of the accent color for the chat's profile background. See profile accent colors for more details. */ 477 | profile_accent_color_id?: number; 478 | /** Custom emoji identifier of the emoji chosen by the chat for its profile background */ 479 | profile_background_custom_emoji_id?: string; 480 | /** Custom emoji identifier of the emoji status of the chat or the other party in a private chat */ 481 | emoji_status_custom_emoji_id?: string; 482 | /** Expiration date of the emoji status of the chat or the other party in a private chat, in Unix time, if any */ 483 | emoji_status_expiration_date?: number; 484 | /** Bio of the other party in a private chat */ 485 | bio?: undefined; 486 | /** True, if privacy settings of the other party in the private chat allows to use tg://user?id= links only in chats with the user */ 487 | has_private_forwards?: undefined; 488 | /** True, if the privacy settings of the other party restrict sending voice and video note messages in the private chat */ 489 | has_restricted_voice_and_video_messages?: undefined; 490 | /** True, if users need to join the supergroup before they can send messages */ 491 | join_to_send_messages?: true; 492 | /** True, if all users directly joining the supergroup without using an invite link need to be approved by supergroup administrators */ 493 | join_by_request?: undefined; 494 | /** Description, for groups, supergroups and channel chats */ 495 | description?: string; 496 | /** Primary invite link, for groups, supergroups and channel chats */ 497 | invite_link?: string; 498 | /** The most recent pinned message (by sending date) */ 499 | pinned_message?: Message; 500 | /** Default chat member permissions, for groups and supergroups */ 501 | permissions?: undefined; 502 | /** True, if gifts can be sent to the chat */ 503 | can_send_gift?: true; 504 | /** True, if paid media messages can be sent or forwarded to the channel chat. The field is available only for channel chats. */ 505 | can_send_paid_media?: true; 506 | /** For supergroups, the minimum allowed delay between consecutive messages sent by each unprivileged user; in seconds */ 507 | slow_mode_delay?: undefined; 508 | /** For supergroups, the minimum number of boosts that a non-administrator user needs to add in order to ignore slow mode and chat permissions */ 509 | unrestrict_boost_count?: undefined; 510 | /** The time after which all messages sent to the chat will be automatically deleted; in seconds */ 511 | message_auto_delete_time?: number; 512 | /** True, if aggressive anti-spam checks are enabled in the supergroup. The field is only available to chat administrators. */ 513 | has_aggressive_anti_spam_enabled?: undefined; 514 | /** True, if non-administrators can only get the list of bots and administrators in the chat */ 515 | has_hidden_members?: undefined; 516 | /** True, if messages from the chat can't be forwarded to other chats */ 517 | has_protected_content?: true; 518 | /** True, if new chat members will have access to old messages; available only to chat administrators */ 519 | has_visible_history?: undefined; 520 | /** For supergroups, name of the group sticker set */ 521 | sticker_set_name?: undefined; 522 | /** True, if the bot can change the group sticker set */ 523 | can_set_sticker_set?: undefined; 524 | /** For supergroups, the name of the group's custom emoji sticker set. Custom emoji from this set can be used by all users and bots in the group. */ 525 | custom_emoji_sticker_set_name?: undefined; 526 | /** Unique identifier for the linked chat, i.e. the discussion group identifier for a channel and vice versa; for supergroups and channel chats. */ 527 | linked_chat_id?: number; 528 | /** For supergroups, the location to which the supergroup is connected */ 529 | location?: undefined; 530 | } 531 | } 532 | 533 | /** This object contains full information about a chat. */ 534 | export type ChatFullInfo = 535 | | ChatFullInfo.PrivateChat 536 | | ChatFullInfo.GroupChat 537 | | ChatFullInfo.SupergroupChat 538 | | ChatFullInfo.ChannelChat; 539 | /** @deprecated use ChatFullInfo instead */ 540 | export type ChatFromGetChat = ChatFullInfo; 541 | 542 | /** This object represent a user's profile pictures. */ 543 | export interface UserProfilePhotos { 544 | /** Total number of profile pictures the target user has */ 545 | total_count: number; 546 | /** Requested profile pictures (in up to 4 sizes each) */ 547 | photos: PhotoSize[][]; 548 | } 549 | 550 | /** This object represents a chat photo. */ 551 | export interface ChatPhoto { 552 | /** File identifier of small (160x160) chat photo. This file_id can be used only for photo download and only for as long as the photo is not changed. */ 553 | small_file_id: string; 554 | /** Unique file identifier of small (160x160) chat photo, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file. */ 555 | small_file_unique_id: string; 556 | /** File identifier of big (640x640) chat photo. This file_id can be used only for photo download and only for as long as the photo is not changed. */ 557 | big_file_id: string; 558 | /** Unique file identifier of big (640x640) chat photo, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file. */ 559 | big_file_unique_id: string; 560 | } 561 | 562 | /** Represents an invite link for a chat. */ 563 | export interface ChatInviteLink { 564 | /** The invite link. If the link was created by another chat administrator, then the second part of the link will be replaced with "...". */ 565 | invite_link: string; 566 | /** Creator of the link */ 567 | creator: User; 568 | /** True, if users joining the chat via the link need to be approved by chat administrators */ 569 | creates_join_request: boolean; 570 | /** True, if the link is primary */ 571 | is_primary: boolean; 572 | /** True, if the link is revoked */ 573 | is_revoked: boolean; 574 | /** Invite link name */ 575 | name?: string; 576 | /** Point in time (Unix timestamp) when the link will expire or has been expired */ 577 | expire_date?: number; 578 | /** The maximum number of users that can be members of the chat simultaneously after joining the chat via this invite link; 1-99999 */ 579 | member_limit?: number; 580 | /** Number of pending join requests created using this link */ 581 | pending_join_request_count?: number; 582 | /** The number of seconds the subscription will be active for before the next payment */ 583 | subscription_period?: number; 584 | /** The amount of Telegram Stars a user must pay initially and after each subsequent subscription period to be a member of the chat using the link */ 585 | subscription_price?: number; 586 | } 587 | 588 | /** Represents the rights of an administrator in a chat. */ 589 | export interface ChatAdministratorRights { 590 | /** True, if the user's presence in the chat is hidden */ 591 | is_anonymous: boolean; 592 | /** True, if the administrator can access the chat event log, get boost list, see hidden supergroup and channel members, report spam messages and ignore slow mode. Implied by any other administrator privilege. */ 593 | can_manage_chat: boolean; 594 | /** True, if the administrator can delete messages of other users */ 595 | can_delete_messages: boolean; 596 | /** True, if the administrator can manage video chats */ 597 | can_manage_video_chats: boolean; 598 | /** True, if the administrator can restrict, ban or unban chat members, or access supergroup statistics */ 599 | can_restrict_members: boolean; 600 | /** True, if the administrator can add new administrators with a subset of their own privileges or demote administrators that they have promoted, directly or indirectly (promoted by administrators that were appointed by the user) */ 601 | can_promote_members: boolean; 602 | /** True, if the user is allowed to change the chat title, photo and other settings */ 603 | can_change_info: boolean; 604 | /** True, if the user is allowed to invite new users to the chat */ 605 | can_invite_users: boolean; 606 | /** True, if the administrator can post stories to the chat */ 607 | can_post_stories: boolean; 608 | /** True, if the administrator can edit stories posted by other users, post stories to the chat page, pin chat stories, and access the chat's story archive */ 609 | can_edit_stories: boolean; 610 | /** True, if the administrator can delete stories posted by other users */ 611 | can_delete_stories: boolean; 612 | /** True, if the administrator can post messages in the channel, or access channel statistics; for channels only */ 613 | can_post_messages?: boolean; 614 | /** True, if the administrator can edit messages of other users and can pin messages; for channels only */ 615 | can_edit_messages?: boolean; 616 | /** True, if the user is allowed to pin messages; for groups and supergroups only */ 617 | can_pin_messages?: boolean; 618 | /** True, if the user is allowed to create, rename, close, and reopen forum topics; for supergroups only */ 619 | can_manage_topics?: boolean; 620 | } 621 | 622 | /** This object represents changes in the status of a chat member. */ 623 | export interface ChatMemberUpdated { 624 | /** Chat the user belongs to */ 625 | chat: Chat; 626 | /** Performer of the action, which resulted in the change */ 627 | from: User; 628 | /** Date the change was done in Unix time */ 629 | date: number; 630 | /** Previous information about the chat member */ 631 | old_chat_member: ChatMember; 632 | /** New information about the chat member */ 633 | new_chat_member: ChatMember; 634 | /** Chat invite link, which was used by the user to join the chat; for joining by invite link events only. */ 635 | invite_link?: ChatInviteLink; 636 | /** True, if the user joined the chat after sending a direct join request without using an invite link without using an invite link and being approved by an administrator */ 637 | via_join_request?: boolean; 638 | /** True, if the user joined the chat via a chat folder invite link */ 639 | via_chat_folder_invite_link?: boolean; 640 | } 641 | 642 | /** This object contains information about one member of a chat. Currently, the following 6 types of chat members are supported: 643 | - ChatMemberOwner 644 | - ChatMemberAdministrator 645 | - ChatMemberMember 646 | - ChatMemberRestricted 647 | - ChatMemberLeft 648 | - ChatMemberBanned */ 649 | export type ChatMember = 650 | | ChatMemberOwner 651 | | ChatMemberAdministrator 652 | | ChatMemberMember 653 | | ChatMemberRestricted 654 | | ChatMemberLeft 655 | | ChatMemberBanned; 656 | 657 | /** Represents a chat member that owns the chat and has all administrator privileges. */ 658 | export interface ChatMemberOwner { 659 | /** The member's status in the chat, always “creator” */ 660 | status: "creator"; 661 | /** Information about the user */ 662 | user: User; 663 | /** True, if the user's presence in the chat is hidden */ 664 | is_anonymous: boolean; 665 | /** Custom title for this user */ 666 | custom_title?: string; 667 | } 668 | 669 | /** Represents a chat member that has some additional privileges. */ 670 | export interface ChatMemberAdministrator { 671 | /** The member's status in the chat, always “administrator” */ 672 | status: "administrator"; 673 | /** Information about the user */ 674 | user: User; 675 | /** True, if the bot is allowed to edit administrator privileges of that user */ 676 | can_be_edited: boolean; 677 | /** True, if the user's presence in the chat is hidden */ 678 | is_anonymous: boolean; 679 | /** True, if the administrator can access the chat event log, get boost list, see hidden supergroup and channel members, report spam messages and ignore slow mode. Implied by any other administrator privilege. */ 680 | can_manage_chat: boolean; 681 | /** True, if the administrator can delete messages of other users */ 682 | can_delete_messages: boolean; 683 | /** True, if the administrator can manage video chats */ 684 | can_manage_video_chats: boolean; 685 | /** True, if the administrator can restrict, ban or unban chat members, or access supergroup statistics */ 686 | can_restrict_members: boolean; 687 | /** True, if the administrator can add new administrators with a subset of their own privileges or demote administrators that they have promoted, directly or indirectly (promoted by administrators that were appointed by the user) */ 688 | can_promote_members: boolean; 689 | /** True, if the user is allowed to change the chat title, photo and other settings */ 690 | can_change_info: boolean; 691 | /** True, if the user is allowed to invite new users to the chat */ 692 | can_invite_users: boolean; 693 | /** True, if the administrator can post stories to the chat */ 694 | can_post_stories: boolean; 695 | /** True, if the administrator can edit stories posted by other users, post stories to the chat page, pin chat stories, and access the chat's story archive */ 696 | can_edit_stories: boolean; 697 | /** True, if the administrator can delete stories posted by other users */ 698 | can_delete_stories: boolean; 699 | /** True, if the administrator can post messages in the channel, or access channel statistics; for channels only */ 700 | can_post_messages?: boolean; 701 | /** True, if the administrator can edit messages of other users and can pin messages; for channels only */ 702 | can_edit_messages?: boolean; 703 | /** True, if the user is allowed to pin messages; for groups and supergroups only */ 704 | can_pin_messages?: boolean; 705 | /** True, if the user is allowed to create, rename, close, and reopen forum topics; for supergroups only */ 706 | can_manage_topics?: boolean; 707 | /** Custom title for this user */ 708 | custom_title?: string; 709 | } 710 | 711 | /** Represents a chat member that has no additional privileges or restrictions. */ 712 | export interface ChatMemberMember { 713 | /** The member's status in the chat, always “member” */ 714 | status: "member"; 715 | /** Information about the user */ 716 | user: User; 717 | /** Date when the user's subscription will expire; Unix time */ 718 | until_date?: number; 719 | } 720 | 721 | /** Represents a chat member that is under certain restrictions in the chat. Supergroups only. */ 722 | export interface ChatMemberRestricted { 723 | /** The member's status in the chat, always “restricted” */ 724 | status: "restricted"; 725 | /** Information about the user */ 726 | user: User; 727 | /** True, if the user is a member of the chat at the moment of the request */ 728 | is_member: boolean; 729 | /** True, if the user is allowed to send text messages, contacts, giveaways, giveaway winners, invoices, locations and venues */ 730 | can_send_messages: boolean; 731 | /** True, if the user is allowed to send audios */ 732 | can_send_audios: boolean; 733 | /** True, if the user is allowed to send documents */ 734 | can_send_documents: boolean; 735 | /** True, if the user is allowed to send photos */ 736 | can_send_photos: boolean; 737 | /** True, if the user is allowed to send videos */ 738 | can_send_videos: boolean; 739 | /** True, if the user is allowed to send video notes */ 740 | can_send_video_notes: boolean; 741 | /** True, if the user is allowed to send voice notes */ 742 | can_send_voice_notes: boolean; 743 | /** True, if the user is allowed to send polls */ 744 | can_send_polls: boolean; 745 | /** True, if the user is allowed to send animations, games, stickers and use inline bots */ 746 | can_send_other_messages: boolean; 747 | /** True, if the user is allowed to add web page previews to their messages */ 748 | can_add_web_page_previews: boolean; 749 | /** True, if the user is allowed to change the chat title, photo and other settings */ 750 | can_change_info: boolean; 751 | /** True, if the user is allowed to invite new users to the chat */ 752 | can_invite_users: boolean; 753 | /** True, if the user is allowed to pin messages */ 754 | can_pin_messages: boolean; 755 | /** True, if the user is allowed to create forum topics */ 756 | can_manage_topics: boolean; 757 | /** Date when restrictions will be lifted for this user; Unix time. If 0, then the user is restricted forever */ 758 | until_date: number; 759 | } 760 | 761 | /** Represents a chat member that isn't currently a member of the chat, but may join it themselves. */ 762 | export interface ChatMemberLeft { 763 | /** The member's status in the chat, always “left” */ 764 | status: "left"; 765 | /** Information about the user */ 766 | user: User; 767 | } 768 | 769 | /** Represents a chat member that was banned in the chat and can't return to the chat or view chat messages. */ 770 | export interface ChatMemberBanned { 771 | /** The member's status in the chat, always “kicked” */ 772 | status: "kicked"; 773 | /** Information about the user */ 774 | user: User; 775 | /** Date when restrictions will be lifted for this user; Unix time. If 0, then the user is banned forever */ 776 | until_date: number; 777 | } 778 | 779 | /** Represents a join request sent to a chat. */ 780 | export interface ChatJoinRequest { 781 | /** Chat to which the request was sent */ 782 | chat: Chat.SupergroupChat | Chat.ChannelChat; 783 | /** User that sent the join request */ 784 | from: User; 785 | /** Identifier of a private chat with the user who sent the join request. The bot can use this identifier for 5 minutes to send messages until the join request is processed, assuming no other administrator contacted the user. */ 786 | user_chat_id: number; 787 | /** Date the request was sent in Unix time */ 788 | date: number; 789 | /** Bio of the user. */ 790 | bio?: string; 791 | /** Chat invite link that was used by the user to send the join request */ 792 | invite_link?: ChatInviteLink; 793 | } 794 | 795 | /** Describes actions that a non-administrator user is allowed to take in a chat. */ 796 | export interface ChatPermissions { 797 | /** True, if the user is allowed to send text messages, contacts, giveaways, giveaway winners, invoices, locations and venues */ 798 | can_send_messages?: boolean; 799 | /** True, if the user is allowed to send audios */ 800 | can_send_audios?: boolean; 801 | /** True, if the user is allowed to send documents */ 802 | can_send_documents?: boolean; 803 | /** True, if the user is allowed to send photos */ 804 | can_send_photos?: boolean; 805 | /** True, if the user is allowed to send videos */ 806 | can_send_videos?: boolean; 807 | /** True, if the user is allowed to send video notes */ 808 | can_send_video_notes?: boolean; 809 | /** True, if the user is allowed to send voice notes */ 810 | can_send_voice_notes?: boolean; 811 | /** True, if the user is allowed to send polls */ 812 | can_send_polls?: boolean; 813 | /** True, if the user is allowed to send animations, games, stickers and use inline bots */ 814 | can_send_other_messages?: boolean; 815 | /** True, if the user is allowed to add web page previews to their messages */ 816 | can_add_web_page_previews?: boolean; 817 | /** True, if the user is allowed to change the chat title, photo and other settings. Ignored in public supergroups */ 818 | can_change_info?: boolean; 819 | /** True, if the user is allowed to invite new users to the chat */ 820 | can_invite_users?: boolean; 821 | /** True, if the user is allowed to pin messages. Ignored in public supergroups */ 822 | can_pin_messages?: boolean; 823 | /** True, if the user is allowed to create forum topics. If omitted defaults to the value of can_pin_messages */ 824 | can_manage_topics?: boolean; 825 | } 826 | 827 | /** Describes the birthdate of a user. */ 828 | export interface Birthdate { 829 | /** Day of the user's birth; 1-31 */ 830 | day: number; 831 | /** Month of the user's birth; 1-12 */ 832 | month: number; 833 | /** Year of the user's birth */ 834 | year?: number; 835 | } 836 | 837 | /** Contains information about the start page settings of a Telegram Business account. */ 838 | export interface BusinessIntro { 839 | /** Title text of the business intro */ 840 | title?: string; 841 | /** Message text of the business intro */ 842 | message?: string; 843 | /** Sticker of the business intro */ 844 | sticker?: Sticker; 845 | } 846 | 847 | /** Contains information about the location of a Telegram Business account. */ 848 | export interface BusinessLocation { 849 | /** Address of the business */ 850 | address: string; 851 | /** Location of the business */ 852 | location?: Location; 853 | } 854 | 855 | /** Describes an interval of time during which a business is open. */ 856 | export interface BusinessOpeningHoursInterval { 857 | /** The minute's sequence number in a week, starting on Monday, marking the start of the time interval during which the business is open; 0 - 7 * 24 * 60 */ 858 | opening_minute: number; 859 | /** The minute's sequence number in a week, starting on Monday, marking the end of the time interval during which the business is open; 0 - 8 * 24 * 60 */ 860 | closing_minute: number; 861 | } 862 | 863 | /** Describes the opening hours of a business. */ 864 | export interface BusinessOpeningHours { 865 | /** Unique name of the time zone for which the opening hours are defined */ 866 | time_zone_name: string; 867 | /** List of time intervals describing business opening hours */ 868 | opening_hours: BusinessOpeningHoursInterval[]; 869 | } 870 | 871 | /** Represents a location to which a chat is connected. */ 872 | export interface ChatLocation { 873 | /** The location to which the supergroup is connected. Can't be a live location. */ 874 | location: Location; 875 | /** Location address; 1-64 characters, as defined by the chat owner */ 876 | address: string; 877 | } 878 | 879 | /** This object represents a forum topic. */ 880 | export interface ForumTopic { 881 | /** Unique identifier of the forum topic */ 882 | message_thread_id: number; 883 | /** Name of the topic */ 884 | name: string; 885 | /** Color of the topic icon in RGB format */ 886 | icon_color: number; 887 | /** Unique identifier of the custom emoji shown as the topic icon */ 888 | icon_custom_emoji_id?: string; 889 | } 890 | 891 | /** This object represents a bot command. */ 892 | export interface BotCommand { 893 | /** Text of the command; 1-32 characters. Can contain only lowercase English letters, digits and underscores. */ 894 | command: string; 895 | /** Description of the command; 1-256 characters. */ 896 | description: string; 897 | } 898 | 899 | /** This object describes the source of a chat boost. It can be one of 900 | 901 | - ChatBoostSourcePremium 902 | - ChatBoostSourceGiftCode 903 | - ChatBoostSourceGiveaway */ 904 | export type ChatBoostSource = 905 | | ChatBoostSourcePremium 906 | | ChatBoostSourceGiftCode 907 | | ChatBoostSourceGiveaway; 908 | 909 | /** The boost was obtained by subscribing to Telegram Premium or by gifting a Telegram Premium subscription to another user. */ 910 | export interface ChatBoostSourcePremium { 911 | /** Source of the boost, always “premium” */ 912 | source: "premium"; 913 | /** User that boosted the chat */ 914 | user: User; 915 | } 916 | 917 | /** 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. */ 918 | export interface ChatBoostSourceGiftCode { 919 | /** Source of the boost, always “gift_code” */ 920 | source: "gift_code"; 921 | /** User for which the gift code was created */ 922 | user: User; 923 | } 924 | 925 | /** 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. */ 926 | export interface ChatBoostSourceGiveaway { 927 | /** Source of the boost, always “giveaway” */ 928 | source: "giveaway"; 929 | /** Identifier of a message in the chat with the giveaway; the message could have been deleted already */ 930 | giveaway_message_id: number; 931 | /** User that won the prize in the giveaway if any; for Telegram Premium giveaways only */ 932 | user?: User; 933 | /** The number of Telegram Stars to be split between giveaway winners; for Telegram Star giveaways only */ 934 | prize_star_count?: number; 935 | /** True, if the giveaway was completed, but there was no user to win the prize */ 936 | is_unclaimed?: true; 937 | } 938 | 939 | /** This object contains information about a chat boost. */ 940 | export interface ChatBoost { 941 | /** Unique identifier of the boost */ 942 | boost_id: string; 943 | /** Point in time (Unix timestamp) when the chat was boosted */ 944 | add_date: number; 945 | /** Point in time (Unix timestamp) when the boost will automatically expire, unless the booster's Telegram Premium subscription is prolonged */ 946 | expiration_date: number; 947 | /** Source of the added boost */ 948 | source: ChatBoostSource; 949 | } 950 | 951 | /** This object represents a boost added to a chat or changed. */ 952 | export interface ChatBoostUpdated { 953 | /** Chat which was boosted */ 954 | chat: Chat; 955 | /** Information about the chat boost */ 956 | boost: ChatBoost; 957 | } 958 | 959 | /** This object represents a boost removed from a chat. */ 960 | export interface ChatBoostRemoved { 961 | /** Chat which was boosted */ 962 | chat: Chat; 963 | /** Unique identifier of the boost */ 964 | boost_id: string; 965 | /** Point in time (Unix timestamp) when the boost was removed */ 966 | remove_date: number; 967 | /** Source of the removed boost */ 968 | source: ChatBoostSource; 969 | } 970 | 971 | /** This object represents a list of boosts added to a chat by a user. */ 972 | export interface UserChatBoosts { 973 | /** The list of boosts added to the chat by the user */ 974 | boosts: ChatBoost[]; 975 | } 976 | 977 | /** Represents the rights of a business bot. */ 978 | export interface BusinessBotRights { 979 | /** True, if the bot can send and edit messages in the private chats that had incoming messages in the last 24 hours */ 980 | can_reply?: true; 981 | /** True, if the bot can mark incoming private messages as read */ 982 | can_read_messages?: true; 983 | /** True, if the bot can delete messages sent by the bot */ 984 | can_delete_outgoing_messages?: true; 985 | /** True, if the bot can delete all private messages in managed chats */ 986 | can_delete_all_messages?: true; 987 | /** True, if the bot can edit the first and last name of the business account */ 988 | can_edit_name?: true; 989 | /** True, if the bot can edit the bio of the business account */ 990 | can_edit_bio?: true; 991 | /** True, if the bot can edit the profile photo of the business account */ 992 | can_edit_profile_photo?: true; 993 | /** True, if the bot can edit the username of the business account */ 994 | can_edit_username?: true; 995 | /** True, if the bot can change the privacy settings pertaining to gifts for the business account */ 996 | can_change_gift_settings?: true; 997 | /** True, if the bot can view gifts and the amount of Telegram Stars owned by the business account */ 998 | can_view_gifts_and_stars?: true; 999 | /** True, if the bot can convert regular gifts owned by the business account to Telegram Stars */ 1000 | can_convert_gifts_to_stars?: true; 1001 | /** True, if the bot can transfer and upgrade gifts owned by the business account */ 1002 | can_transfer_and_upgrade_gifts?: true; 1003 | /** True, if the bot can transfer Telegram Stars received by the business account to its own account, or use them to upgrade and transfer gifts */ 1004 | can_transfer_stars?: true; 1005 | /** True, if the bot can post, edit and delete stories on behalf of the business account */ 1006 | can_manage_stories?: true; 1007 | } 1008 | 1009 | /** Describes the connection of the bot with a business account. */ 1010 | export interface BusinessConnection { 1011 | /** Unique identifier of the business connection */ 1012 | id: string; 1013 | /** Business account user that created the business connection */ 1014 | user: User; 1015 | /** Identifier of a private chat with the user who created the business connection. */ 1016 | user_chat_id: number; 1017 | /** Date the connection was established in Unix time */ 1018 | date: number; 1019 | /** Rights of the business bot */ 1020 | rights?: BusinessBotRights; 1021 | /** True, if the connection is active */ 1022 | is_enabled: boolean; 1023 | } 1024 | 1025 | /** This object is received when messages are deleted from a connected business account. */ 1026 | export interface BusinessMessagesDeleted { 1027 | /** Unique identifier of the business connection */ 1028 | business_connection_id: string; 1029 | /** Information about a chat in the business account. The bot may not have access to the chat or the corresponding user. */ 1030 | chat: Chat.PrivateChat; 1031 | /** The list of identifiers of deleted messages in the chat of the business account */ 1032 | message_ids: number[]; 1033 | } 1034 | -------------------------------------------------------------------------------- /markup.ts: -------------------------------------------------------------------------------- 1 | import type { ChatAdministratorRights, User } from "./manage.ts"; 2 | import type { MaybeInaccessibleMessage } from "./message.ts"; 3 | 4 | /** This object represents one button of an inline keyboard. Exactly one of the optional fields must be used to specify type of the button. */ 5 | export interface InlineKeyboardMarkup { 6 | /** Array of button rows, each represented by an Array of InlineKeyboardButton objects */ 7 | inline_keyboard: InlineKeyboardButton[][]; 8 | } 9 | 10 | export declare namespace InlineKeyboardButton { 11 | interface AbstractInlineKeyboardButton { 12 | /** Label text on the button */ 13 | text: string; 14 | } 15 | export interface UrlButton extends AbstractInlineKeyboardButton { 16 | /** HTTP or tg:// URL to be opened when the button is pressed. Links tg://user?id= can be used to mention a user by their identifier without using a username, if this is allowed by their privacy settings. */ 17 | url: string; 18 | } 19 | export interface CallbackButton extends AbstractInlineKeyboardButton { 20 | /** Data to be sent in a callback query to the bot when the button is pressed, 1-64 bytes */ 21 | callback_data: string; 22 | } 23 | export interface WebAppButton extends AbstractInlineKeyboardButton { 24 | /** Description of the Web App that will be launched when the user presses the button. The Web App will be able to send an arbitrary message on behalf of the user using the method answerWebAppQuery. Available only in private chats between a user and the bot. Not supported for messages sent on behalf of a Telegram Business account. */ 25 | web_app: WebAppInfo; 26 | } 27 | export interface LoginButton extends AbstractInlineKeyboardButton { 28 | /** An HTTPS URL used to automatically authorize the user. Can be used as a replacement for the Telegram Login Widget. */ 29 | login_url: LoginUrl; 30 | } 31 | export interface SwitchInlineButton extends AbstractInlineKeyboardButton { 32 | /** 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. May be empty, in which case just the bot's username will be inserted. Not supported for messages sent on behalf of a Telegram Business account. */ 33 | switch_inline_query: string; 34 | } 35 | export interface SwitchInlineCurrentChatButton 36 | extends AbstractInlineKeyboardButton { 37 | /** 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. 38 | 39 | 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. Not supported in channels and for messages sent on behalf of a Telegram Business account. */ 40 | switch_inline_query_current_chat: string; 41 | } 42 | export interface SwitchInlineChosenChatButton 43 | extends AbstractInlineKeyboardButton { 44 | /** If set, pressing the button will prompt the user to select one of their chats of the specified type, open that chat and insert the bot's username and the specified inline query in the input field. Not supported for messages sent on behalf of a Telegram Business account. */ 45 | switch_inline_query_chosen_chat: SwitchInlineQueryChosenChat; 46 | } 47 | export interface CopyTextButtonButton extends AbstractInlineKeyboardButton { 48 | /** Description of the button that copies the specified text to the clipboard. */ 49 | copy_text: CopyTextButton; 50 | } 51 | export interface GameButton extends AbstractInlineKeyboardButton { 52 | /** Description of the game that will be launched when the user presses the button. 53 | 54 | NOTE: This type of button must always be the first button in the first row. */ 55 | callback_game: CallbackGame; 56 | } 57 | export interface PayButton extends AbstractInlineKeyboardButton { 58 | /** Specify True, to send a Pay button. Substrings “⭐” and “XTR” in the buttons's text will be replaced with a Telegram Star icon. 59 | 60 | NOTE: This type of button must always be the first button in the first row and can only be used in invoice messages. */ 61 | pay: boolean; 62 | } 63 | } 64 | 65 | /** This object represents one button of an inline keyboard. You must use exactly one of the optional fields. */ 66 | export type InlineKeyboardButton = 67 | | InlineKeyboardButton.CallbackButton 68 | | InlineKeyboardButton.GameButton 69 | | InlineKeyboardButton.LoginButton 70 | | InlineKeyboardButton.PayButton 71 | | InlineKeyboardButton.SwitchInlineButton 72 | | InlineKeyboardButton.SwitchInlineCurrentChatButton 73 | | InlineKeyboardButton.SwitchInlineChosenChatButton 74 | | InlineKeyboardButton.CopyTextButtonButton 75 | | InlineKeyboardButton.UrlButton 76 | | InlineKeyboardButton.WebAppButton; 77 | 78 | /** 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. 79 | Telegram apps support these buttons as of version 5.7. */ 80 | export interface LoginUrl { 81 | /** An HTTPS URL to be opened with user authorization data added to the query string when the button is pressed. If the user refuses to provide authorization data, the original URL without information about the user will be opened. The data added is the same as described in Receiving authorization data. 82 | 83 | NOTE: You must always check the hash of the received data to verify the authentication and the integrity of the data as described in Checking authorization. */ 84 | url: string; 85 | /** New text of the button in forwarded messages. */ 86 | forward_text?: string; 87 | /** Username of a bot, which will be used for user authorization. See Setting up a bot for more details. If not specified, the current bot's username will be assumed. The url's domain must be the same as the domain linked with the bot. See Linking your domain to the bot for more details. */ 88 | bot_username?: string; 89 | /** Pass True to request the permission for your bot to send messages to the user. */ 90 | request_write_access?: boolean; 91 | } 92 | 93 | /** This object represents an inline button that switches the current user to inline mode in a chosen chat, with an optional default inline query. */ 94 | export interface SwitchInlineQueryChosenChat { 95 | /** The default inline query to be inserted in the input field. If left empty, only the bot's username will be inserted */ 96 | query?: string; 97 | /** True, if private chats with users can be chosen */ 98 | allow_user_chats?: boolean; 99 | /** True, if private chats with bots can be chosen */ 100 | allow_bot_chats?: boolean; 101 | /** True, if group and supergroup chats can be chosen */ 102 | allow_group_chats?: boolean; 103 | /** True, if channel chats can be chosen */ 104 | allow_channel_chats?: boolean; 105 | } 106 | 107 | /** A placeholder, currently holds no information. Use BotFather to set up your game. */ 108 | export interface CallbackGame {} 109 | 110 | /** 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. 111 | 112 | NOTE: After the user presses a callback button, Telegram clients will display a progress bar until you call answerCallbackQuery. It is, therefore, necessary to react by calling answerCallbackQuery even if no notification to the user is needed (e.g., without specifying any of the optional parameters). */ 113 | export interface CallbackQuery { 114 | /** Unique identifier for this query */ 115 | id: string; 116 | /** Sender */ 117 | from: User; 118 | /** Message sent by the bot with the callback button that originated the query */ 119 | message?: MaybeInaccessibleMessage; 120 | /** Identifier of the message sent via the bot in inline mode, that originated the query. */ 121 | inline_message_id?: string; 122 | /** Global identifier, uniquely corresponding to the chat to which the message with the callback button was sent. Useful for high scores in games. */ 123 | chat_instance: string; 124 | /** Data associated with the callback button. Be aware that the message originated the query can contain no callback buttons with this data. */ 125 | data?: string; 126 | /** Short name of a Game to be returned, serves as the unique identifier for the game */ 127 | game_short_name?: string; 128 | } 129 | 130 | /** 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. */ 131 | export interface ReplyKeyboardMarkup { 132 | /** Array of button rows, each represented by an Array of KeyboardButton objects */ 133 | keyboard: KeyboardButton[][]; 134 | /** Requests clients to always show the keyboard when the regular keyboard is hidden. Defaults to false, in which case the custom keyboard can be hidden and opened with a keyboard icon. */ 135 | is_persistent?: boolean; 136 | /** 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. */ 137 | resize_keyboard?: boolean; 138 | /** 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. */ 139 | one_time_keyboard?: boolean; 140 | /** The placeholder to be shown in the input field when the keyboard is active; 1-64 characters */ 141 | input_field_placeholder?: string; 142 | /** 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 to a message in the same chat and forum topic, sender of the original message. 143 | 144 | 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. */ 145 | selective?: boolean; 146 | } 147 | 148 | export declare namespace KeyboardButton { 149 | export interface CommonButton { 150 | /** Text of the button. If none of the optional fields are used, it will be sent as a message when the button is pressed */ 151 | text: string; 152 | } 153 | export interface RequestUsersButton extends CommonButton { 154 | /** If specified, pressing the button will open a list of suitable users. Identifiers of selected users will be sent to the bot in a “users_shared” service message. Available in private chats only. */ 155 | request_users: KeyboardButtonRequestUsers; 156 | } 157 | export interface RequestChatButton extends CommonButton { 158 | /** If specified, pressing the button will open a list of suitable chats. Tapping on a chat will send its identifier to the bot in a “chat_shared” service message. Available in private chats only. */ 159 | request_chat: KeyboardButtonRequestChat; 160 | } 161 | export interface RequestContactButton extends CommonButton { 162 | /** If True, the user's phone number will be sent as a contact when the button is pressed. Available in private chats only. */ 163 | request_contact: boolean; 164 | } 165 | export interface RequestLocationButton extends CommonButton { 166 | /** If True, the user's current location will be sent when the button is pressed. Available in private chats only. */ 167 | request_location: boolean; 168 | } 169 | export interface RequestPollButton extends CommonButton { 170 | /** If specified, the user will be asked to create a poll and send it to the bot when the button is pressed. Available in private chats only. */ 171 | request_poll: KeyboardButtonPollType; 172 | } 173 | export interface WebAppButton extends CommonButton { 174 | /** If specified, the described Web App will be launched when the button is pressed. The Web App will be able to send a “web_app_data” service message. Available in private chats only. */ 175 | web_app: WebAppInfo; 176 | } 177 | } 178 | 179 | /** 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. */ 180 | export type KeyboardButton = 181 | | KeyboardButton.CommonButton 182 | | KeyboardButton.RequestUsersButton 183 | | KeyboardButton.RequestChatButton 184 | | KeyboardButton.RequestContactButton 185 | | KeyboardButton.RequestLocationButton 186 | | KeyboardButton.RequestPollButton 187 | | KeyboardButton.WebAppButton 188 | | string; 189 | 190 | /** This object represents type of a poll, which is allowed to be created and sent when the corresponding button is pressed. */ 191 | export interface KeyboardButtonPollType { 192 | /** If quiz is passed, the user will be allowed to create only polls in the quiz mode. If regular is passed, only regular polls will be allowed. Otherwise, the user will be allowed to create a poll of any type. */ 193 | type?: "quiz" | "regular"; 194 | } 195 | 196 | /** 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. */ 197 | export interface ReplyKeyboardRemove { 198 | /** 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) */ 199 | remove_keyboard: true; 200 | /** 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 to a message in the same chat and forum topic, sender of the original message. 201 | 202 | 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. */ 203 | selective?: boolean; 204 | } 205 | 206 | /** 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. 207 | 208 | Example: A poll bot for groups runs in privacy mode (only receives commands, replies to its messages and mentions). There could be two ways to create a new poll: 209 | 210 | Explain the user how to send a command with parameters (e.g. /newpoll question answer1 answer2). May be appealing for hardcore users but lacks modern day polish. 211 | 212 | Guide the user through a step-by-step process. 'Please send me your question', 'Cool, now let's add the first answer option', 'Great. Keep adding answer options, then send /done when you're ready'. 213 | 214 | The last option is definitely more attractive. And if you use ForceReply in your bot's questions, it will receive the user's answers even if it only receives replies, commands and mentions - without any extra work for the user. */ 215 | export interface ForceReply { 216 | /** Shows reply interface to the user, as if they manually selected the bot's message and tapped 'Reply' */ 217 | force_reply: true; 218 | /** The placeholder to be shown in the input field when the reply is active; 1-64 characters */ 219 | input_field_placeholder?: string; 220 | /** Use this parameter if you want to force reply from 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 to a message in the same chat and forum topic, sender of the original message. */ 221 | selective?: boolean; 222 | } 223 | 224 | /** This object represents an inline keyboard button that copies specified text to the clipboard. */ 225 | export interface CopyTextButton { 226 | /** The text to be copied to the clipboard; 1-256 characters */ 227 | text: string; 228 | } 229 | 230 | /** Describes a Web App. */ 231 | export interface WebAppInfo { 232 | /** An HTTPS URL of a Web App to be opened with additional data as specified in Initializing Web Apps */ 233 | url: string; 234 | } 235 | 236 | /** 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. */ 237 | export interface KeyboardButtonRequestUsers { 238 | /** Signed 32-bit identifier of the request that will be received back in the UsersShared object. Must be unique within the message */ 239 | request_id: number; 240 | /** Pass True to request bots, pass False to request regular users. If not specified, no additional restrictions are applied. */ 241 | user_is_bot?: boolean; 242 | /** Pass True to request premium users, pass False to request non-premium users. If not specified, no additional restrictions are applied. */ 243 | user_is_premium?: boolean; 244 | /** The maximum number of users to be selected; 1-10. Defaults to 1. */ 245 | max_quantity?: number; 246 | /** Pass True to request the users' first and last names */ 247 | request_name?: boolean; 248 | /** Pass True to request the users' usernames */ 249 | request_username?: boolean; 250 | /** Pass True to request the users' photos */ 251 | request_photo?: boolean; 252 | } 253 | 254 | /** 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. */ 255 | export interface KeyboardButtonRequestChat { 256 | /** Signed 32-bit identifier of the request, which will be received back in the ChatShared object. Must be unique within the message */ 257 | request_id: number; 258 | /** Pass True to request a channel chat, pass False to request a group or a supergroup chat. */ 259 | chat_is_channel: boolean; 260 | /** Pass True to request a forum supergroup, pass False to request a non-forum chat. If not specified, no additional restrictions are applied. */ 261 | chat_is_forum?: boolean; 262 | /** Pass True to request a supergroup or a channel with a username, pass False to request a chat without a username. If not specified, no additional restrictions are applied. */ 263 | chat_has_username?: boolean; 264 | /** Pass True to request a chat owned by the user. Otherwise, no additional restrictions are applied. */ 265 | chat_is_created?: boolean; 266 | /** An object listing the required administrator rights of the user in the chat. The rights must be a superset of bot_administrator_rights. If not specified, no additional restrictions are applied. */ 267 | user_administrator_rights?: ChatAdministratorRights; 268 | /** An object listing the required administrator rights of the bot in the chat. The rights must be a subset of user_administrator_rights. If not specified, no additional restrictions are applied. */ 269 | bot_administrator_rights?: ChatAdministratorRights; 270 | /** Pass True to request a chat with the bot as a member. Otherwise, no additional restrictions are applied. */ 271 | bot_is_member?: boolean; 272 | /** Pass True to request the chat's title */ 273 | request_title?: boolean; 274 | /** Pass True to request the chat's username */ 275 | request_username?: boolean; 276 | /** Pass True to request the chat's photo */ 277 | request_photo?: boolean; 278 | } 279 | -------------------------------------------------------------------------------- /mod.js: -------------------------------------------------------------------------------- 1 | /* The comment below makes Vite recognize an empty main file as a valid CJS module. */ 2 | // module.exports 3 | -------------------------------------------------------------------------------- /mod.ts: -------------------------------------------------------------------------------- 1 | export * from "./api.ts"; 2 | export * from "./inline.ts"; 3 | export * from "./manage.ts"; 4 | export * from "./markup.ts"; 5 | export * from "./message.ts"; 6 | export * from "./methods.ts"; 7 | export * from "./passport.ts"; 8 | export * from "./payment.ts"; 9 | export * from "./settings.ts"; 10 | export * from "./story.ts"; 11 | export * from "./update.ts"; 12 | export * from "./langs.ts"; 13 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@grammyjs/types", 3 | "version": "3.20.0", 4 | "description": "Telegram Bot API type declarations for grammY", 5 | "main": "mod.js", 6 | "repository": { 7 | "type": "git", 8 | "url": "git+https://github.com/grammyjs/types.git" 9 | }, 10 | "keywords": [ 11 | "grammy", 12 | "telegram", 13 | "bot", 14 | "api", 15 | "types" 16 | ], 17 | "scripts": { 18 | "prepare": "deno task build" 19 | }, 20 | "author": "KnorpelSenf", 21 | "types": "mod.d.ts", 22 | "license": "MIT", 23 | "bugs": { 24 | "url": "https://github.com/grammyjs/types/issues" 25 | }, 26 | "files": [ 27 | "*.d.ts", 28 | "mod.js" 29 | ], 30 | "homepage": "https://grammy.dev/", 31 | "devDependencies": { 32 | "deno-bin": "^1.31.1" 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /passport.ts: -------------------------------------------------------------------------------- 1 | /** Describes Telegram Passport data shared with the bot by the user. */ 2 | export interface PassportData { 3 | /** Array with information about documents and other Telegram Passport elements that was shared with the bot */ 4 | data: EncryptedPassportElement[]; 5 | /** Encrypted credentials required to decrypt the data */ 6 | credentials: EncryptedCredentials; 7 | } 8 | 9 | /** This object represents a file uploaded to Telegram Passport. Currently all Telegram Passport files are in JPEG format when decrypted and don't exceed 10MB. */ 10 | export interface PassportFile { 11 | /** Identifier for this file, which can be used to download or reuse the file */ 12 | file_id: string; 13 | /** Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file. */ 14 | file_unique_id: string; 15 | /** File size in bytes */ 16 | file_size: number; 17 | /** Unix time when the file was uploaded */ 18 | file_date: number; 19 | } 20 | 21 | /** Describes documents or other Telegram Passport elements shared with the bot by the user. */ 22 | export interface EncryptedPassportElement { 23 | /** Element type. One of “personal_details”, “passport”, “driver_license”, “identity_card”, “internal_passport”, “address”, “utility_bill”, “bank_statement”, “rental_agreement”, “passport_registration”, “temporary_registration”, “phone_number”, “email”. */ 24 | type: 25 | | "personal_details" 26 | | "passport" 27 | | "driver_license" 28 | | "identity_card" 29 | | "internal_passport" 30 | | "address" 31 | | "utility_bill" 32 | | "bank_statement" 33 | | "rental_agreement" 34 | | "passport_registration" 35 | | "temporary_registration" 36 | | "phone_number" 37 | | "email"; 38 | /** Base64-encoded encrypted Telegram Passport element data provided by the user; available only for “personal_details”, “passport”, “driver_license”, “identity_card”, “internal_passport” and “address” types. Can be decrypted and verified using the accompanying EncryptedCredentials. */ 39 | data?: string; 40 | /** User's verified phone number; available only for “phone_number” type */ 41 | phone_number?: string; 42 | /** User's verified email address; available only for “email” type */ 43 | email?: string; 44 | /** Array of encrypted files with documents provided by the user; available only for “utility_bill”, “bank_statement”, “rental_agreement”, “passport_registration” and “temporary_registration” types. Files can be decrypted and verified using the accompanying EncryptedCredentials. */ 45 | files?: PassportFile[]; 46 | /** Encrypted file with the front side of the document, provided by the user; available only for “passport”, “driver_license”, “identity_card” and “internal_passport”. The file can be decrypted and verified using the accompanying EncryptedCredentials. */ 47 | front_side?: PassportFile; 48 | /** Encrypted file with the reverse side of the document, provided by the user; available only for “driver_license” and “identity_card”. The file can be decrypted and verified using the accompanying EncryptedCredentials. */ 49 | reverse_side?: PassportFile; 50 | /** Encrypted file with the selfie of the user holding a document, provided by the user; available if requested for “passport”, “driver_license”, “identity_card” and “internal_passport”. The file can be decrypted and verified using the accompanying EncryptedCredentials. */ 51 | selfie?: PassportFile; 52 | /** Array of encrypted files with translated versions of documents provided by the user; available if requested for “passport”, “driver_license”, “identity_card”, “internal_passport”, “utility_bill”, “bank_statement”, “rental_agreement”, “passport_registration” and “temporary_registration” types. Files can be decrypted and verified using the accompanying EncryptedCredentials. */ 53 | translation?: PassportFile[]; 54 | /** Base64-encoded element hash for using in PassportElementErrorUnspecified */ 55 | hash: string; 56 | } 57 | 58 | /** Describes data required for decrypting and authenticating EncryptedPassportElement. See the Telegram Passport Documentation for a complete description of the data decryption and authentication processes. */ 59 | export interface EncryptedCredentials { 60 | /** Base64-encoded encrypted JSON-serialized data with unique user's payload, data hashes and secrets required for EncryptedPassportElement decryption and authentication */ 61 | data: string; 62 | /** Base64-encoded data hash for data authentication */ 63 | hash: string; 64 | /** Base64-encoded secret, encrypted with the bot's public RSA key, required for data decryption */ 65 | secret: string; 66 | } 67 | 68 | /** This object represents an error in the Telegram Passport element which was submitted that should be resolved by the user. It should be one of: 69 | - PassportElementErrorDataField 70 | - PassportElementErrorFrontSide 71 | - PassportElementErrorReverseSide 72 | - PassportElementErrorSelfie 73 | - PassportElementErrorFile 74 | - PassportElementErrorFiles 75 | - PassportElementErrorTranslationFile 76 | - PassportElementErrorTranslationFiles 77 | - PassportElementErrorUnspecified 78 | */ 79 | export type PassportElementError = 80 | | PassportElementErrorDataField 81 | | PassportElementErrorFrontSide 82 | | PassportElementErrorReverseSide 83 | | PassportElementErrorSelfie 84 | | PassportElementErrorFile 85 | | PassportElementErrorFiles 86 | | PassportElementErrorTranslationFile 87 | | PassportElementErrorTranslationFiles 88 | | PassportElementErrorUnspecified; 89 | 90 | /** Represents an issue in one of the data fields that was provided by the user. The error is considered resolved when the field's value changes. */ 91 | export interface PassportElementErrorDataField { 92 | /** Error source, must be data */ 93 | source: "data"; 94 | /** The section of the user's Telegram Passport which has the error, one of “personal_details”, “passport”, “driver_license”, “identity_card”, “internal_passport”, “address” */ 95 | type: 96 | | "personal_details" 97 | | "passport" 98 | | "driver_license" 99 | | "identity_card" 100 | | "internal_passport" 101 | | "address"; 102 | /** Name of the data field which has the error */ 103 | field_name: string; 104 | /** Base64-encoded data hash */ 105 | data_hash: string; 106 | /** Error message */ 107 | message: string; 108 | } 109 | 110 | /** Represents an issue with the front side of a document. The error is considered resolved when the file with the front side of the document changes. */ 111 | export interface PassportElementErrorFrontSide { 112 | /** Error source, must be front_side */ 113 | source: "front_side"; 114 | /** The section of the user's Telegram Passport which has the issue, one of “passport”, “driver_license”, “identity_card”, “internal_passport” */ 115 | type: "passport" | "driver_license" | "identity_card" | "internal_passport"; 116 | /** Base64-encoded hash of the file with the front side of the document */ 117 | file_hash: string; 118 | /** Error message */ 119 | message: string; 120 | } 121 | 122 | /** Represents an issue with the reverse side of a document. The error is considered resolved when the file with reverse side of the document changes. */ 123 | export interface PassportElementErrorReverseSide { 124 | /** Error source, must be reverse_side */ 125 | source: "reverse_side"; 126 | /** The section of the user's Telegram Passport which has the issue, one of “driver_license”, “identity_card” */ 127 | type: "driver_license" | "identity_card"; 128 | /** Base64-encoded hash of the file with the reverse side of the document */ 129 | file_hash: string; 130 | /** Error message */ 131 | message: string; 132 | } 133 | 134 | /** Represents an issue with the selfie with a document. The error is considered resolved when the file with the selfie changes. */ 135 | export interface PassportElementErrorSelfie { 136 | /** Error source, must be selfie */ 137 | source: "selfie"; 138 | /** The section of the user's Telegram Passport which has the issue, one of “passport”, “driver_license”, “identity_card”, “internal_passport” */ 139 | type: "passport" | "driver_license" | "identity_card" | "internal_passport"; 140 | /** Base64-encoded hash of the file with the selfie */ 141 | file_hash: string; 142 | /** Error message */ 143 | message: string; 144 | } 145 | 146 | /** Represents an issue with a document scan. The error is considered resolved when the file with the document scan changes. */ 147 | export interface PassportElementErrorFile { 148 | /** Error source, must be file */ 149 | source: "file"; 150 | /** The section of the user's Telegram Passport which has the issue, one of “utility_bill”, “bank_statement”, “rental_agreement”, “passport_registration”, “temporary_registration” */ 151 | type: 152 | | "utility_bill" 153 | | "bank_statement" 154 | | "rental_agreement" 155 | | "passport_registration" 156 | | "temporary_registration"; 157 | /** Base64-encoded file hash */ 158 | file_hash: string; 159 | /** Error message */ 160 | message: string; 161 | } 162 | 163 | /** Represents an issue with a list of scans. The error is considered resolved when the list of files containing the scans changes. */ 164 | export interface PassportElementErrorFiles { 165 | /** Error source, must be files */ 166 | source: "files"; 167 | /** The section of the user's Telegram Passport which has the issue, one of “utility_bill”, “bank_statement”, “rental_agreement”, “passport_registration”, “temporary_registration” */ 168 | type: 169 | | "utility_bill" 170 | | "bank_statement" 171 | | "rental_agreement" 172 | | "passport_registration" 173 | | "temporary_registration"; 174 | /** List of base64-encoded file hashes */ 175 | file_hashes: string[]; 176 | /** Error message */ 177 | message: string; 178 | } 179 | 180 | /** Represents an issue with one of the files that constitute the translation of a document. The error is considered resolved when the file changes. */ 181 | export interface PassportElementErrorTranslationFile { 182 | /** Error source, must be translation_file */ 183 | source: "translation_file"; 184 | /** Type of element of the user's Telegram Passport which has the issue, one of “passport”, “driver_license”, “identity_card”, “internal_passport”, “utility_bill”, “bank_statement”, “rental_agreement”, “passport_registration”, “temporary_registration” */ 185 | type: 186 | | "passport" 187 | | "driver_license" 188 | | "identity_card" 189 | | "internal_passport" 190 | | "utility_bill" 191 | | "bank_statement" 192 | | "rental_agreement" 193 | | "passport_registration" 194 | | "temporary_registration"; 195 | /** Base64-encoded file hash */ 196 | file_hash: string; 197 | /** Error message */ 198 | message: string; 199 | } 200 | 201 | /** Represents an issue with the translated version of a document. The error is considered resolved when a file with the document translation change. */ 202 | export interface PassportElementErrorTranslationFiles { 203 | /** Error source, must be translation_files */ 204 | source: "translation_files"; 205 | /** Type of element of the user's Telegram Passport which has the issue, one of “passport”, “driver_license”, “identity_card”, “internal_passport”, “utility_bill”, “bank_statement”, “rental_agreement”, “passport_registration”, “temporary_registration” */ 206 | type: 207 | | "passport" 208 | | "driver_license" 209 | | "identity_card" 210 | | "internal_passport" 211 | | "utility_bill" 212 | | "bank_statement" 213 | | "rental_agreement" 214 | | "passport_registration" 215 | | "temporary_registration"; 216 | /** List of base64-encoded file hashes */ 217 | file_hashes: string[]; 218 | /** Error message */ 219 | message: string; 220 | } 221 | 222 | /** Represents an issue in an unspecified place. The error is considered resolved when new data is added. */ 223 | export interface PassportElementErrorUnspecified { 224 | /** Error source, must be unspecified */ 225 | source: "unspecified"; 226 | /** Type of element of the user's Telegram Passport which has the issue */ 227 | type: string; 228 | /** Base64-encoded element hash */ 229 | element_hash: string; 230 | /** Error message */ 231 | message: string; 232 | } 233 | -------------------------------------------------------------------------------- /payment.ts: -------------------------------------------------------------------------------- 1 | import type { Chat, User } from "./manage.ts"; 2 | import type { MessageEntity, PaidMedia, Sticker } from "./message.ts"; 3 | 4 | /** This object represents a portion of the price for goods or services. */ 5 | export interface LabeledPrice { 6 | /** Portion label */ 7 | label: string; 8 | /** Price of the product in the smallest units of the currency (integer, not float/double). For example, for a price of US$ 1.45 pass amount = 145. See the exp parameter in currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies). */ 9 | amount: number; 10 | } 11 | 12 | /** This object contains basic information about an invoice. */ 13 | export interface Invoice { 14 | /** Product name */ 15 | title: string; 16 | /** Product description */ 17 | description: string; 18 | /** Unique bot deep-linking parameter that can be used to generate this invoice */ 19 | start_parameter: string; 20 | /** Three-letter ISO 4217 currency code, or “XTR” for payments in Telegram Stars */ 21 | currency: string; 22 | /** Total price in the smallest units of the currency (integer, not float/double). For example, for a price of US$ 1.45 pass amount = 145. See the exp parameter in currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies). */ 23 | total_amount: number; 24 | } 25 | 26 | /** This object represents a shipping address. */ 27 | export interface ShippingAddress { 28 | /** Two-letter ISO 3166-1 alpha-2 country code */ 29 | country_code: string; 30 | /** State, if applicable */ 31 | state: string; 32 | /** City */ 33 | city: string; 34 | /** First line for the address */ 35 | street_line1: string; 36 | /** Second line for the address */ 37 | street_line2: string; 38 | /** Address post code */ 39 | post_code: string; 40 | } 41 | 42 | /** This object represents information about an order. */ 43 | export interface OrderInfo { 44 | /** User name */ 45 | name?: string; 46 | /** User's phone number */ 47 | phone_number?: string; 48 | /** User email */ 49 | email?: string; 50 | /** User shipping address */ 51 | shipping_address?: ShippingAddress; 52 | } 53 | 54 | /** This object represents one shipping option. */ 55 | export interface ShippingOption { 56 | /** Shipping option identifier */ 57 | id: string; 58 | /** Option title */ 59 | title: string; 60 | /** List of price portions */ 61 | prices: LabeledPrice[]; 62 | } 63 | 64 | /** This object contains basic information about a successful payment. Note that if the buyer initiates a chargeback with the relevant payment provider following this transaction, the funds may be debited from your balance. This is outside of Telegram's control. */ 65 | export interface SuccessfulPayment { 66 | /** Three-letter ISO 4217 currency code, or “XTR” for payments in Telegram Stars */ 67 | currency: string; 68 | /** Total price in the smallest units of the currency (integer, not float/double). For example, for a price of US$ 1.45 pass amount = 145. See the exp parameter in currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies). */ 69 | total_amount: number; 70 | /** Bot specified invoice payload */ 71 | invoice_payload: string; 72 | /** Expiration date of the subscription, in Unix time; for recurring payments only */ 73 | subscription_expiration_date?: number; 74 | /** True, if the payment is a recurring payment for a subscription */ 75 | is_recurring?: true; 76 | /** True, if the payment is the first payment for a subscription */ 77 | is_first_recurring?: true; 78 | /** Identifier of the shipping option chosen by the user */ 79 | shipping_option_id?: string; 80 | /** Order information provided by the user */ 81 | order_info?: OrderInfo; 82 | /** Telegram payment identifier */ 83 | telegram_payment_charge_id: string; 84 | /** Provider payment identifier */ 85 | provider_payment_charge_id: string; 86 | } 87 | 88 | /** This object contains basic information about a refunded payment. */ 89 | export interface RefundedPayment { 90 | /** Three-letter ISO 4217 currency code, or “XTR” for payments in Telegram Stars. Currently, always “XTR” */ 91 | currency: string; 92 | /** Total refunded price in the smallest units of the currency (integer, not float/double). For example, for a price of US$ 1.45, total_amount = 145. See the exp parameter in currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies). */ 93 | total_amount: number; 94 | /** Bot-specified invoice payload */ 95 | invoice_payload: string; 96 | /** Telegram payment identifier */ 97 | telegram_payment_charge_id: string; 98 | /** Provider payment identifier */ 99 | provider_payment_charge_id?: string; 100 | } 101 | 102 | /** This object contains information about an incoming shipping query. */ 103 | export interface ShippingQuery { 104 | /** Unique query identifier */ 105 | id: string; 106 | /** User who sent the query */ 107 | from: User; 108 | /** Bot specified invoice payload */ 109 | invoice_payload: string; 110 | /** User specified shipping address */ 111 | shipping_address: ShippingAddress; 112 | } 113 | 114 | /** This object contains information about an incoming pre-checkout query. */ 115 | export interface PreCheckoutQuery { 116 | /** Unique query identifier */ 117 | id: string; 118 | /** User who sent the query */ 119 | from: User; 120 | /** Three-letter ISO 4217 currency code, or “XTR” for payments in Telegram Stars */ 121 | currency: string; 122 | /** Total price in the smallest units of the currency (integer, not float/double). For example, for a price of US$ 1.45 pass amount = 145. See the exp parameter in currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies). */ 123 | total_amount: number; 124 | /** Bot specified invoice payload */ 125 | invoice_payload: string; 126 | /** Identifier of the shipping option chosen by the user */ 127 | shipping_option_id?: string; 128 | /** Order information provided by the user */ 129 | order_info?: OrderInfo; 130 | } 131 | 132 | /** This object describes the state of a revenue withdrawal operation. Currently, it can be one of 133 | 134 | - RevenueWithdrawalStatePending 135 | - RevenueWithdrawalStateSucceeded 136 | - RevenueWithdrawalStateFailed */ 137 | export type RevenueWithdrawalState = 138 | | RevenueWithdrawalStatePending 139 | | RevenueWithdrawalStateSucceeded 140 | | RevenueWithdrawalStateFailed; 141 | 142 | /** The withdrawal is in progress. */ 143 | export interface RevenueWithdrawalStatePending { 144 | /** Type of the state, always “pending” */ 145 | type: "pending"; 146 | } 147 | 148 | /** The withdrawal succeeded. */ 149 | export interface RevenueWithdrawalStateSucceeded { 150 | /** Type of the state, always “succeeded” */ 151 | type: "succeeded"; 152 | /** Date the withdrawal was completed in Unix time */ 153 | date: number; 154 | /** An HTTPS URL that can be used to see transaction details */ 155 | url: string; 156 | } 157 | 158 | /** The withdrawal failed and the transaction was refunded. */ 159 | export interface RevenueWithdrawalStateFailed { 160 | /** Type of the state, always “failed” */ 161 | type: "failed"; 162 | } 163 | 164 | /** Contains information about the affiliate that received a commission via this transaction. */ 165 | export interface AffiliateInfo { 166 | /** The bot or the user that received an affiliate commission if it was received by a bot or a user */ 167 | affiliate_user?: User; 168 | /** The chat that received an affiliate commission if it was received by a chat */ 169 | affiliate_chat?: Chat; 170 | /** The number of Telegram Stars received by the affiliate for each 1000 Telegram Stars received by the bot from referred users */ 171 | commission_per_mille: number; 172 | /** Integer amount of Telegram Stars received by the affiliate from the transaction, rounded to 0; can be negative for refunds */ 173 | amount: number; 174 | /** The number of 1/1000000000 shares of Telegram Stars received by the affiliate; from -999999999 to 999999999; can be negative for refunds */ 175 | nanostar_amount?: number; 176 | } 177 | 178 | /** This object describes the source of a transaction, or its recipient for outgoing transactions. Currently, it can be one of 179 | 180 | - TransactionPartnerUser 181 | - TransactionPartnerChat 182 | - TransactionPartnerAffiliateProgram 183 | - TransactionPartnerFragment 184 | - TransactionPartnerTelegramAds 185 | - TransactionPartnerTelegramApi 186 | - TransactionPartnerOther */ 187 | export type TransactionPartner = 188 | | TransactionPartnerUser 189 | | TransactionPartnerChat 190 | | TransactionPartnerAffiliateProgram 191 | | TransactionPartnerFragment 192 | | TransactionPartnerTelegramAds 193 | | TransactionPartnerTelegramApi 194 | | TransactionPartnerOther; 195 | 196 | /** Describes a transaction with a user. */ 197 | export interface TransactionPartnerUser { 198 | /** Type of the transaction partner, always “user” */ 199 | type: "user"; 200 | /** Type of the transaction, currently one of “invoice_payment” for payments via invoices, “paid_media_payment” for payments for paid media, “gift_purchase” for gifts sent by the bot, “premium_purchase” for Telegram Premium subscriptions gifted by the bot, “business_account_transfer” for direct transfers from managed business accounts */ 201 | transaction_type: 202 | | "invoice_payment" 203 | | "paid_media_payment" 204 | | "gift_purchase" 205 | | "premium_purchase" 206 | | "business_account_transfer"; 207 | /** Information about the user */ 208 | user: User; 209 | /** Information about the affiliate that received a commission via this transaction. Can be available only for “invoice_payment” and “paid_media_payment” transactions. */ 210 | affiliate?: AffiliateInfo; 211 | /** Bot-specified invoice payload. Can be available only for “invoice_payment” transactions. */ 212 | invoice_payload?: string; 213 | /** The duration of the paid subscription. Can be available only for “invoice_payment” transactions. */ 214 | subscription_period?: number; 215 | /** Information about the paid media bought by the user; for “paid_media_payment” transactions only */ 216 | paid_media?: PaidMedia[]; 217 | /** Bot-specified paid media payload. Can be available only for “paid_media_payment” transactions. */ 218 | paid_media_payload?: string; 219 | /** The gift sent to the user by the bot; for “gift_purchase” transactions only */ 220 | gift?: Gift; 221 | /** Number of months the gifted Telegram Premium subscription will be active for; for “premium_purchase” transactions only */ 222 | premium_subscription_duration?: number; 223 | } 224 | 225 | /** Describes a transaction with a chat. */ 226 | export interface TransactionPartnerChat { 227 | /** Type of the transaction partner, always “chat” */ 228 | type: "chat"; 229 | /** Information about the chat */ 230 | chat: Chat; 231 | /** The gift sent to the chat by the bot */ 232 | gift?: Gift; 233 | } 234 | 235 | /** Describes the affiliate program that issued the affiliate commission received via this transaction. */ 236 | export interface TransactionPartnerAffiliateProgram { 237 | /** Type of the transaction partner, always “affiliate_program” */ 238 | type: "affiliate_program"; 239 | /** Information about the bot that sponsored the affiliate program */ 240 | sponsor_user?: User; 241 | /** The number of Telegram Stars received by the bot for each 1000 Telegram Stars received by the affiliate program sponsor from referred users */ 242 | commission_per_mille: number; 243 | } 244 | 245 | /** Describes a withdrawal transaction with Fragment. */ 246 | export interface TransactionPartnerFragment { 247 | /** Type of the transaction partner, always “fragment” */ 248 | type: "fragment"; 249 | /** State of the transaction if the transaction is outgoing */ 250 | withdrawal_state?: RevenueWithdrawalState; 251 | } 252 | 253 | /** Describes a withdrawal transaction to the Telegram Ads platform. */ 254 | export interface TransactionPartnerTelegramAds { 255 | /** Type of the transaction partner, always “telegram_ads” */ 256 | type: "telegram_ads"; 257 | } 258 | 259 | /** Describes a transaction with payment for paid broadcasting. */ 260 | export interface TransactionPartnerTelegramApi { 261 | /** Type of the transaction partner, always “telegram_api” */ 262 | type: "telegram_api"; 263 | /** The number of successful requests that exceeded regular limits and were therefore billed */ 264 | request_count: number; 265 | } 266 | 267 | /** Describes a transaction with an unknown source or recipient. */ 268 | export interface TransactionPartnerOther { 269 | /** Type of the transaction partner, always “other” */ 270 | type: "other"; 271 | } 272 | 273 | /** Describes a Telegram Star transaction. Note that if the buyer initiates a chargeback with the payment provider from whom they acquired Stars (e.g., Apple, Google) following this transaction, the refunded Stars will be deducted from the bot's balance. This is outside of Telegram's control. */ 274 | export interface StarTransaction { 275 | /** Unique identifier of the transaction. Coincides with the identifier of the original transaction for refund transactions. Coincides with SuccessfulPayment.telegram_payment_charge_id for successful incoming payments from users. */ 276 | id: string; 277 | /** Integer amount of Telegram Stars transferred by the transaction */ 278 | amount: number; 279 | /** The number of 1/1000000000 shares of Telegram Stars transferred by the transaction; from 0 to 999999999 */ 280 | nanostar_amount?: number; 281 | /** Date the transaction was created in Unix time */ 282 | date: number; 283 | /** Source of an incoming transaction (e.g., a user purchasing goods or services, Fragment refunding a failed withdrawal). Only for incoming transactions */ 284 | source?: TransactionPartner; 285 | /** Receiver of an outgoing transaction (e.g., a user for a purchase refund, Fragment for a withdrawal). Only for outgoing transactions */ 286 | receiver?: TransactionPartner; 287 | } 288 | 289 | /** Contains a list of Telegram Star transactions. */ 290 | export interface StarTransactions { 291 | /** The list of transactions */ 292 | transactions: StarTransaction[]; 293 | } 294 | 295 | /** This object contains information about a paid media purchase. */ 296 | export interface PaidMediaPurchased { 297 | /** User who purchased the media */ 298 | from: User; 299 | /** Bot-specified paid media payload */ 300 | paid_media_payload: string; 301 | } 302 | 303 | /** This object represents a gift that can be sent by the bot. */ 304 | export interface Gift { 305 | /** Unique identifier of the gift */ 306 | id: string; 307 | /** The sticker that represents the gift */ 308 | sticker: Sticker; 309 | /** The number of Telegram Stars that must be paid to send the sticker */ 310 | star_count: number; 311 | /** The number of Telegram Stars that must be paid to upgrade the gift to a unique one */ 312 | upgrade_star_count?: number; 313 | /** The total number of the gifts of this type that can be sent; for limited gifts only */ 314 | total_count?: number; 315 | /** The number of remaining gifts of this type that can be sent; for limited gifts only */ 316 | remaining_count?: number; 317 | } 318 | 319 | /** This object represent a list of gifts. */ 320 | export interface Gifts { 321 | /** The list of gifts */ 322 | gifts: Gift[]; 323 | } 324 | 325 | /** This object describes the model of a unique gift. */ 326 | export interface UniqueGiftModel { 327 | /** Name of the model */ 328 | name: string; 329 | /** The sticker that represents the unique gift */ 330 | sticker: Sticker; 331 | /** The number of unique gifts that receive this model for every 1000 gifts upgraded */ 332 | rarity_per_mille: number; 333 | } 334 | 335 | /** This object describes the symbol shown on the pattern of a unique gift. */ 336 | export interface UniqueGiftSymbol { 337 | /** Name of the symbol */ 338 | name: string; 339 | /** The sticker that represents the unique gift */ 340 | sticker: Sticker; 341 | /** The number of unique gifts that receive this model for every 1000 gifts upgraded */ 342 | rarity_per_mille: number; 343 | } 344 | 345 | /** This object describes the colors of the backdrop of a unique gift. */ 346 | export interface UniqueGiftBackdropColors { 347 | /** The color in the center of the backdrop in RGB format */ 348 | center_color: number; 349 | /** The color on the edges of the backdrop in RGB format */ 350 | edge_color: number; 351 | /** The color to be applied to the symbol in RGB format */ 352 | symbol_color: number; 353 | /** The color for the text on the backdrop in RGB format */ 354 | text_color: number; 355 | } 356 | 357 | /** This object describes the backdrop of a unique gift. */ 358 | export interface UniqueGiftBackdrop { 359 | /** Name of the backdrop */ 360 | name: string; 361 | /** Colors of the backdrop */ 362 | colors: UniqueGiftBackdropColors; 363 | /** The number of unique gifts that receive this backdrop for every 1000 gifts upgraded */ 364 | rarity_per_mille: number; 365 | } 366 | 367 | /** This object describes a unique gift that was upgraded from a regular gift. */ 368 | export interface UniqueGift { 369 | /** Human-readable name of the regular gift from which this unique gift was upgraded */ 370 | base_name: string; 371 | /** Unique name of the gift. This name can be used in https://t.me/nft/... links and story areas */ 372 | name: string; 373 | /** Unique number of the upgraded gift among gifts upgraded from the same regular gift */ 374 | number: number; 375 | /** Model of the gift */ 376 | model: UniqueGiftModel; 377 | /** Symbol of the gift */ 378 | symbol: UniqueGiftSymbol; 379 | /** Backdrop of the gift */ 380 | backdrop: UniqueGiftBackdrop; 381 | } 382 | 383 | /** Describes a service message about a regular gift that was sent or received. */ 384 | export interface GiftInfo { 385 | /** Information about the gift */ 386 | gift: Gift; 387 | /** Unique identifier of the received gift for the bot; only present for gifts received on behalf of business accounts */ 388 | owned_gift_id?: string; 389 | /** Number of Telegram Stars that can be claimed by the receiver by converting the gift; omitted if conversion to Telegram Stars is impossible */ 390 | convert_star_count?: number; 391 | /** Number of Telegram Stars that were prepaid by the sender for the ability to upgrade the gift */ 392 | prepaid_upgrade_star_count?: number; 393 | /** True, if the gift can be upgraded to a unique gift */ 394 | can_be_upgraded?: true; 395 | /** Text of the message that was added to the gift */ 396 | text?: string; 397 | /** Special entities that appear in the text */ 398 | entities?: MessageEntity[]; 399 | /** True, if the sender and gift text are shown only to the gift receiver; otherwise, everyone will be able to see them */ 400 | is_private?: true; 401 | } 402 | 403 | /** Describes a service message about a unique gift that was sent or received. */ 404 | export interface UniqueGiftInfo { 405 | /** Information about the gift */ 406 | gift: UniqueGift; 407 | /** Origin of the gift. Currently, either “upgrade” or “transfer” */ 408 | origin: "upgrade" | "transfer"; 409 | /** Unique identifier of the received gift for the bot; only present for gifts received on behalf of business accounts */ 410 | owned_gift_id?: string; 411 | /** Number of Telegram Stars that must be paid to transfer the gift; omitted if the bot cannot transfer the gift */ 412 | transfer_star_count?: number; 413 | } 414 | 415 | /** Describes a service message about a change in the price of paid messages within a chat. */ 416 | export interface PaidMessagePriceChanged { 417 | /** The new number of Telegram Stars that must be paid by non-administrator users of the supergroup chat for each sent message */ 418 | paid_message_star_count: number; 419 | } 420 | 421 | /** Describes an amount of Telegram Stars. */ 422 | export interface StarAmount { 423 | /** Integer amount of Telegram Stars, rounded to 0; can be negative */ 424 | amount: number; 425 | /** The number of 1/1000000000 shares of Telegram Stars; from -999999999 to 999999999; can be negative if and only if amount is non-positive */ 426 | nanostar_amount?: number; 427 | } 428 | 429 | /** This object describes a gift received and owned by a user or a chat. Currently, it can be one of 430 | 431 | - OwnedGiftRegular 432 | - OwnedGiftUnique */ 433 | export type OwnedGift = OwnedGiftRegular | OwnedGiftUnique; 434 | 435 | /** Describes a regular gift owned by a user or a chat. */ 436 | export interface OwnedGiftRegular { 437 | /** Type of the gift, always “regular” */ 438 | type: "regular"; 439 | /** Information about the regular gift */ 440 | gift: Gift; 441 | /** Unique identifier of the gift for the bot; for gifts received on behalf of business accounts only */ 442 | owned_gift_id?: string; 443 | /** Sender of the gift if it is a known user */ 444 | sender_user?: User; 445 | /** Date the gift was sent in Unix time */ 446 | send_date: number; 447 | /** Text of the message that was added to the gift */ 448 | text?: string; 449 | /** Special entities that appear in the text */ 450 | entities?: MessageEntity[]; 451 | /** True, if the sender and gift text are shown only to the gift receiver; otherwise, everyone will be able to see them */ 452 | is_private?: true; 453 | /** True, if the gift is displayed on the account's profile page; for gifts received on behalf of business accounts only */ 454 | is_saved?: true; 455 | /** True, if the gift can be upgraded to a unique gift; for gifts received on behalf of business accounts only */ 456 | can_be_upgraded?: true; 457 | /** True, if the gift was refunded and isn't available anymore */ 458 | was_refunded?: true; 459 | /** Number of Telegram Stars that can be claimed by the receiver instead of the gift; omitted if the gift cannot be converted to Telegram Stars */ 460 | convert_star_count?: number; 461 | /** Number of Telegram Stars that were paid by the sender for the ability to upgrade the gift */ 462 | prepaid_upgrade_star_count?: number; 463 | } 464 | 465 | /** Describes a unique gift received and owned by a user or a chat. */ 466 | export interface OwnedGiftUnique { 467 | /** Type of the gift, always “unique” */ 468 | type: "unique"; 469 | /** Information about the unique gift */ 470 | gift: UniqueGift; 471 | /** Unique identifier of the received gift for the bot; for gifts received on behalf of business accounts only */ 472 | owned_gift_id?: string; 473 | /** Sender of the gift if it is a known user */ 474 | sender_user?: User; 475 | /** Date the gift was sent in Unix time */ 476 | send_date: number; 477 | /** True, if the gift is displayed on the account's profile page; for gifts received on behalf of business accounts only */ 478 | is_saved?: true; 479 | /** True, if the gift can be transferred to another owner; for gifts received on behalf of business accounts only */ 480 | can_be_transferred?: true; 481 | /** Number of Telegram Stars that must be paid to transfer the gift; omitted if the bot cannot transfer the gift */ 482 | transfer_star_count?: number; 483 | } 484 | 485 | /** Contains the list of gifts received and owned by a user or a chat. */ 486 | export interface OwnedGifts { 487 | /** The total number of gifts owned by the user or the chat */ 488 | total_count: number; 489 | /** The list of gifts */ 490 | gifts: OwnedGift[]; 491 | /** Offset for the next request. If empty, then there are no more results */ 492 | next_offset?: string; 493 | } 494 | -------------------------------------------------------------------------------- /settings.ts: -------------------------------------------------------------------------------- 1 | import type { WebAppInfo } from "./markup.ts"; 2 | 3 | /** This object represents the bot's name. */ 4 | export interface BotName { 5 | /** The bot's name */ 6 | name: string; 7 | } 8 | 9 | /** This object represents the bot's description. */ 10 | export interface BotDescription { 11 | /** The bot's description */ 12 | description: string; 13 | } 14 | 15 | /** This object represents the bot's short description. */ 16 | export interface BotShortDescription { 17 | /** The bot's short description */ 18 | short_description: string; 19 | } 20 | 21 | /** This object describes the bot's menu button in a private chat. It should be one of 22 | - MenuButtonCommands 23 | - MenuButtonWebApp 24 | - MenuButtonDefault 25 | 26 | If a menu button other than MenuButtonDefault is set for a private chat, then it is applied in the chat. Otherwise the default menu button is applied. By default, the menu button opens the list of bot commands. */ 27 | export type MenuButton = 28 | | MenuButtonCommands 29 | | MenuButtonWebApp 30 | | MenuButtonDefault; 31 | 32 | /** Represents a menu button, which opens the bot's list of commands. */ 33 | export interface MenuButtonCommands { 34 | /** Type of the button, must be commands */ 35 | type: "commands"; 36 | } 37 | 38 | /** Represents a menu button, which launches a Web App. */ 39 | export interface MenuButtonWebApp { 40 | /** Button type, must be web_app */ 41 | type: "web_app"; 42 | /** Text on the button */ 43 | text: string; 44 | /** Description of the Web App that will be launched when the user presses the button. The Web App will be able to send an arbitrary message on behalf of the user using the method answerWebAppQuery. Alternatively, a t.me link to a Web App can be specified in the object instead of the Web App's URL, in which case the Web App will be opened as if the user pressed the link. */ 45 | web_app: WebAppInfo; 46 | } 47 | 48 | /** Describes that no specific value for the menu button was set. */ 49 | export interface MenuButtonDefault { 50 | /** Type of the button, must be default */ 51 | type: "default"; 52 | } 53 | 54 | /** This object represents the scope to which bot commands are applied. Currently, the following 7 scopes are supported: 55 | - BotCommandScopeDefault 56 | - BotCommandScopeAllPrivateChats 57 | - BotCommandScopeAllGroupChats 58 | - BotCommandScopeAllChatAdministrators 59 | - BotCommandScopeChat 60 | - BotCommandScopeChatAdministrators 61 | - BotCommandScopeChatMember 62 | 63 | ## Determining list of commands 64 | 65 | The following algorithm is used to determine the list of commands for a particular user viewing the bot menu. The first list of commands which is set is returned: 66 | 67 | ### Commands in the chat with the bot 68 | - botCommandScopeChat + language_code 69 | - botCommandScopeChat 70 | - botCommandScopeAllPrivateChats + language_code 71 | - botCommandScopeAllPrivateChats 72 | - botCommandScopeDefault + language_code 73 | - botCommandScopeDefault 74 | 75 | ### Commands in group and supergroup chats 76 | - botCommandScopeChatMember + language_code 77 | - botCommandScopeChatMember 78 | - botCommandScopeChatAdministrators + language_code (administrators only) 79 | - botCommandScopeChatAdministrators (administrators only) 80 | - botCommandScopeChat + language_code 81 | - botCommandScopeChat 82 | - botCommandScopeAllChatAdministrators + language_code (administrators only) 83 | - botCommandScopeAllChatAdministrators (administrators only) 84 | - botCommandScopeAllGroupChats + language_code 85 | - botCommandScopeAllGroupChats 86 | - botCommandScopeDefault + language_code 87 | - botCommandScopeDefault */ 88 | export type BotCommandScope = 89 | | BotCommandScopeDefault 90 | | BotCommandScopeAllPrivateChats 91 | | BotCommandScopeAllGroupChats 92 | | BotCommandScopeAllChatAdministrators 93 | | BotCommandScopeChat 94 | | BotCommandScopeChatAdministrators 95 | | BotCommandScopeChatMember; 96 | 97 | /** Represents the default scope of bot commands. Default commands are used if no commands with a narrower scope are specified for the user. */ 98 | export interface BotCommandScopeDefault { 99 | /** Scope type, must be default */ 100 | type: "default"; 101 | } 102 | 103 | /** Represents the scope of bot commands, covering all private chats. */ 104 | export interface BotCommandScopeAllPrivateChats { 105 | /** Scope type, must be all_private_chats */ 106 | type: "all_private_chats"; 107 | } 108 | 109 | /** Represents the scope of bot commands, covering all group and supergroup chats. */ 110 | export interface BotCommandScopeAllGroupChats { 111 | /** Scope type, must be all_group_chats */ 112 | type: "all_group_chats"; 113 | } 114 | 115 | /** Represents the scope of bot commands, covering all group and supergroup chat administrators. */ 116 | export interface BotCommandScopeAllChatAdministrators { 117 | /** Scope type, must be all_chat_administrators */ 118 | type: "all_chat_administrators"; 119 | } 120 | 121 | /** Represents the scope of bot commands, covering a specific chat. */ 122 | export interface BotCommandScopeChat { 123 | /** Scope type, must be chat */ 124 | type: "chat"; 125 | /** Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) */ 126 | chat_id: number | string; 127 | } 128 | 129 | /** Represents the scope of bot commands, covering all administrators of a specific group or supergroup chat. */ 130 | export interface BotCommandScopeChatAdministrators { 131 | /** Scope type, must be chat_administrators */ 132 | type: "chat_administrators"; 133 | /** Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) */ 134 | chat_id: number | string; 135 | } 136 | 137 | /** Represents the scope of bot commands, covering a specific member of a group or supergroup chat. */ 138 | export interface BotCommandScopeChatMember { 139 | /** Scope type, must be chat_member */ 140 | type: "chat_member"; 141 | /** Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) */ 142 | chat_id: number | string; 143 | /** Unique identifier of the target user */ 144 | user_id: number; 145 | } 146 | -------------------------------------------------------------------------------- /story.ts: -------------------------------------------------------------------------------- 1 | import type { ReactionType } from "./message.ts"; 2 | 3 | /** Describes the position of a clickable area within a story. */ 4 | export interface StoryAreaPosition { 5 | /** The abscissa of the area's center, as a percentage of the media width */ 6 | x_percentage: number; 7 | /** The ordinate of the area's center, as a percentage of the media height */ 8 | y_percentage: number; 9 | /** The width of the area's rectangle, as a percentage of the media width */ 10 | width_percentage: number; 11 | /** The height of the area's rectangle, as a percentage of the media height */ 12 | height_percentage: number; 13 | /** The clockwise rotation angle of the rectangle, in degrees; 0-360 */ 14 | rotation_angle: number; 15 | /** The radius of the rectangle corner rounding, as a percentage of the media width */ 16 | corner_radius_percentage: number; 17 | } 18 | 19 | /** Describes the physical address of a location. */ 20 | export interface LocationAddress { 21 | /** The two-letter ISO 3166-1 alpha-2 country code of the country where the location is located */ 22 | country_code: string; 23 | /** State of the location */ 24 | state?: string; 25 | /** City of the location */ 26 | city?: string; 27 | /** Street address of the location */ 28 | street?: string; 29 | } 30 | 31 | /** Describes the type of a clickable area on a story. Currently, it can be one of 32 | 33 | - StoryAreaTypeLocation 34 | - StoryAreaTypeSuggestedReaction 35 | - StoryAreaTypeLink 36 | - StoryAreaTypeWeather 37 | - StoryAreaTypeUniqueGift */ 38 | export type StoryAreaType = 39 | | StoryAreaTypeLocation 40 | | StoryAreaTypeSuggestedReaction 41 | | StoryAreaTypeLink 42 | | StoryAreaTypeWeather 43 | | StoryAreaTypeUniqueGift; 44 | 45 | /** Describes a story area pointing to a location. Currently, a story can have up to 10 location areas. */ 46 | export interface StoryAreaTypeLocation { 47 | /** Type of the area, always “location” */ 48 | type: "location"; 49 | /** Location latitude in degrees */ 50 | latitude: number; 51 | /** Location longitude in degrees */ 52 | longitude: number; 53 | /** Address of the location */ 54 | address?: LocationAddress; 55 | } 56 | 57 | /** Describes a story area pointing to a suggested reaction. Currently, a story can have up to 5 suggested reaction areas. */ 58 | export interface StoryAreaTypeSuggestedReaction { 59 | /** Type of the area, always “suggested_reaction” */ 60 | type: "suggested_reaction"; 61 | /** Type of the reaction */ 62 | reaction_type: ReactionType; 63 | /** Pass True if the reaction area has a dark background */ 64 | is_dark?: boolean; 65 | /** Pass True if reaction area corner is flipped */ 66 | is_flipped?: boolean; 67 | } 68 | 69 | /** Describes a story area pointing to an HTTP or tg:// link. Currently, a story can have up to 3 link areas. */ 70 | export interface StoryAreaTypeLink { 71 | /** Type of the area, always “link” */ 72 | type: "link"; 73 | /** HTTP or tg:// URL to be opened when the area is clicked */ 74 | url: string; 75 | } 76 | 77 | /** Describes a story area containing weather information. Currently, a story can have up to 3 weather areas. */ 78 | export interface StoryAreaTypeWeather { 79 | /** Type of the area, always “weather” */ 80 | type: "weather"; 81 | /** Temperature, in degree Celsius */ 82 | temperature: number; 83 | /** Emoji representing the weather */ 84 | emoji: string; 85 | /** A color of the area background in the ARGB format */ 86 | background_color: number; 87 | } 88 | 89 | /** Describes a story area pointing to a unique gift. Currently, a story can have at most 1 unique gift area. */ 90 | export interface StoryAreaTypeUniqueGift { 91 | /** Type of the area, always “unique_gift” */ 92 | type: "unique_gift"; 93 | /** Unique name of the gift */ 94 | name: string; 95 | } 96 | 97 | /** Describes a clickable area on a story media. */ 98 | export interface StoryArea { 99 | /** Position of the area */ 100 | position: StoryAreaPosition; 101 | /** Type of the area */ 102 | type: StoryAreaType; 103 | } 104 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "forceConsistentCasingInFileNames": true, 4 | "newLine": "lf", 5 | "noFallthroughCasesInSwitch": true, 6 | "noImplicitReturns": true, 7 | "noUnusedParameters": true, 8 | "strict": true, 9 | "declaration": true, 10 | "emitDeclarationOnly": true, 11 | "moduleResolution": "node", 12 | "module": "commonjs", 13 | "skipLibCheck": true, 14 | "target": "es2019" 15 | }, 16 | "include": ["*.ts"] 17 | } 18 | -------------------------------------------------------------------------------- /update.ts: -------------------------------------------------------------------------------- 1 | import type { ChosenInlineResult, InlineQuery } from "./inline.ts"; 2 | import type { 3 | BusinessConnection, 4 | BusinessMessagesDeleted, 5 | Chat, 6 | ChatBoostRemoved, 7 | ChatBoostUpdated, 8 | ChatJoinRequest, 9 | ChatMemberUpdated, 10 | User, 11 | } from "./manage.ts"; 12 | import type { CallbackQuery } from "./markup.ts"; 13 | import type { 14 | Message, 15 | MessageReactionCountUpdated, 16 | MessageReactionUpdated, 17 | Poll, 18 | PollAnswer, 19 | } from "./message.ts"; 20 | import type { 21 | PaidMediaPurchased, 22 | PreCheckoutQuery, 23 | ShippingQuery, 24 | } from "./payment.ts"; 25 | 26 | /** Internal namespace used to make some message types more accurate */ 27 | export declare namespace Update { 28 | /** Internal type holding properties that message updates in private chats share. */ 29 | export interface Private { 30 | chat: Chat.PrivateChat; 31 | } 32 | /** Internal type holding properties that message updates in channels share. */ 33 | export interface Channel { 34 | chat: Chat.ChannelChat; 35 | } 36 | /** Internal type holding properties that message updates outside of channels share. */ 37 | export interface NonChannel { 38 | chat: Exclude; 39 | from: User; 40 | } 41 | /** Internal type holding properties that updates about edited messages share. */ 42 | export interface Edited { 43 | /** Date the message was last edited in Unix time */ 44 | edit_date: number; 45 | } 46 | } 47 | 48 | /** This object represents an incoming update. 49 | At most one of the optional parameters can be present in any given update. */ 50 | export interface Update { 51 | /** The update's unique identifier. Update identifiers start from a certain positive number and increase sequentially. This identifier 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. */ 52 | update_id: number; 53 | /** New incoming message of any kind - text, photo, sticker, etc. */ 54 | message?: Message & Update.NonChannel; 55 | /** New version of a message that is known to the bot and was edited. This update may at times be triggered by changes to message fields that are either unavailable or not actively used by your bot. */ 56 | edited_message?: Message & Update.Edited & Update.NonChannel; 57 | /** New incoming channel post of any kind - text, photo, sticker, etc. */ 58 | channel_post?: Message & Update.Channel; 59 | /** New version of a channel post that is known to the bot and was edited. This update may at times be triggered by changes to message fields that are either unavailable or not actively used by your bot. */ 60 | edited_channel_post?: Message & Update.Edited & Update.Channel; 61 | /** The bot was connected to or disconnected from a business account, or a user edited an existing connection with the bot */ 62 | business_connection?: BusinessConnection; 63 | /** New message from a connected business account */ 64 | business_message?: Message & Update.Private; 65 | /** New version of a message from a connected business account */ 66 | edited_business_message?: Message & Update.Edited & Update.Private; 67 | /** Messages were deleted from a connected business account */ 68 | deleted_business_messages?: BusinessMessagesDeleted; 69 | /** A reaction to a message was changed by a user. The bot must be an administrator in the chat and must explicitly specify "message_reaction" in the list of allowed_updates to receive these updates. The update isn't received for reactions set by bots. */ 70 | message_reaction?: MessageReactionUpdated; 71 | /** Reactions to a message with anonymous reactions were changed. The bot must be an administrator in the chat and must explicitly specify "message_reaction_count" in the list of allowed_updates to receive these updates. The updates are grouped and can be sent with delay up to a few minutes. */ 72 | message_reaction_count?: MessageReactionCountUpdated; 73 | /** New incoming inline query */ 74 | inline_query?: InlineQuery; 75 | /** 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. */ 76 | chosen_inline_result?: ChosenInlineResult; 77 | /** New incoming callback query */ 78 | callback_query?: CallbackQuery; 79 | /** New incoming shipping query. Only for invoices with flexible price */ 80 | shipping_query?: ShippingQuery; 81 | /** New incoming pre-checkout query. Contains full information about checkout */ 82 | pre_checkout_query?: PreCheckoutQuery; 83 | /** New poll state. Bots receive only updates about manually stopped polls and polls, which are sent by the bot */ 84 | poll?: Poll; 85 | /** A user changed their answer in a non-anonymous poll. Bots receive new votes only in polls that were sent by the bot itself. */ 86 | poll_answer?: PollAnswer; 87 | /** The bot's chat member status was updated in a chat. For private chats, this update is received only when the bot is blocked or unblocked by the user. */ 88 | my_chat_member?: ChatMemberUpdated; 89 | /** A chat member's status was updated in a chat. The bot must be an administrator in the chat and must explicitly specify “chat_member” in the list of allowed_updates to receive these updates. */ 90 | chat_member?: ChatMemberUpdated; 91 | /** A request to join the chat has been sent. The bot must have the can_invite_users administrator right in the chat to receive these updates. */ 92 | chat_join_request?: ChatJoinRequest; 93 | /** A chat boost was added or changed. The bot must be an administrator in the chat to receive these updates. */ 94 | chat_boost?: ChatBoostUpdated; 95 | /** A boost was removed from a chat. The bot must be an administrator in the chat to receive these updates. */ 96 | removed_chat_boost?: ChatBoostRemoved; 97 | /** A user purchased paid media with a non-empty payload sent by the bot in a non-channel chat */ 98 | purchased_paid_media?: PaidMediaPurchased; 99 | } 100 | --------------------------------------------------------------------------------