@grammyjs/types 2.5.1 → 2.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2021 KnorpelSenf
3
+ Copyright (c) 2022 KnorpelSenf
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/index.d.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  export * from "./api";
2
- export * from "./callback";
3
2
  export * from "./inline";
4
3
  export * from "./manage";
4
+ export * from "./markup";
5
+ export * from "./menu-button";
5
6
  export * from "./message";
6
7
  export * from "./passport";
7
8
  export * from "./payment";
package/inline.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { Chat, User } from "./manage";
2
+ import { InlineKeyboardMarkup } from "./markup";
2
3
  import { Location, MessageEntity, ParseMode } from "./message";
3
4
  import { LabeledPrice } from "./payment";
4
5
 
@@ -12,90 +13,12 @@ export interface InlineQuery {
12
13
  query: string;
13
14
  /** Offset of the results to be returned, can be controlled by the bot */
14
15
  offset: string;
15
- /** 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 */
16
+ /** 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 */
16
17
  chat_type?: "sender" | Chat["type"];
17
18
  /** Sender location, only for bots that request user location */
18
19
  location?: Location;
19
20
  }
20
21
 
21
- /** This object represents an inline keyboard that appears right next to the message it belongs to. */
22
- export interface InlineKeyboardMarkup {
23
- /** Array of button rows, each represented by an Array of InlineKeyboardButton objects */
24
- inline_keyboard: InlineKeyboardButton[][];
25
- }
26
-
27
- export namespace InlineKeyboardButton {
28
- interface AbstractInlineKeyboardButton {
29
- /** Label text on the button */
30
- text: string;
31
- }
32
- export interface UrlButton extends AbstractInlineKeyboardButton {
33
- /** HTTP or tg:// url to be opened when the button is pressed. Links tg://user?id=<user_id> can be used to mention a user by their ID without using a username, if this is allowed by their privacy settings. */
34
- url: string;
35
- }
36
- export interface LoginButton extends AbstractInlineKeyboardButton {
37
- /** An HTTP URL used to automatically authorize the user. Can be used as a replacement for the Telegram Login Widget. */
38
- login_url: LoginUrl;
39
- }
40
- export interface CallbackButton extends AbstractInlineKeyboardButton {
41
- /** Data to be sent in a callback query to the bot when button is pressed, 1-64 bytes */
42
- callback_data: string;
43
- }
44
- export interface SwitchInlineButton extends AbstractInlineKeyboardButton {
45
- /** If set, pressing the button will prompt the user to select one of their chats, open that chat and insert the bot's username and the specified inline query in the input field. Can be empty, in which case just the bot's username will be inserted.
46
-
47
- Note: This offers an easy way for users to start using your bot in inline mode when they are currently in a private chat with it. Especially useful when combined with switch_pm… actions – in this case the user will be automatically returned to the chat they switched from, skipping the chat selection screen. */
48
- switch_inline_query: string;
49
- }
50
- export interface SwitchInlineCurrentChatButton
51
- extends AbstractInlineKeyboardButton {
52
- /** 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.
53
-
54
- 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. */
55
- switch_inline_query_current_chat: string;
56
- }
57
- export interface GameButton extends AbstractInlineKeyboardButton {
58
- /** Description of the game that will be launched when the user presses the button.
59
-
60
- NOTE: This type of button must always be the first button in the first row. */
61
- callback_game: CallbackGame;
62
- }
63
- export interface PayButton extends AbstractInlineKeyboardButton {
64
- /** Specify True, to send a Pay button.
65
-
66
- NOTE: This type of button must always be the first button in the first row and can only be used in invoice messages. */
67
- pay: boolean;
68
- }
69
- }
70
-
71
- /** This object represents one button of an inline keyboard. You must use exactly one of the optional fields. */
72
- export type InlineKeyboardButton =
73
- | InlineKeyboardButton.CallbackButton
74
- | InlineKeyboardButton.GameButton
75
- | InlineKeyboardButton.LoginButton
76
- | InlineKeyboardButton.PayButton
77
- | InlineKeyboardButton.SwitchInlineButton
78
- | InlineKeyboardButton.SwitchInlineCurrentChatButton
79
- | InlineKeyboardButton.UrlButton;
80
-
81
- /** 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.
82
- Telegram apps support these buttons as of version 5.7. */
83
- export interface LoginUrl {
84
- /** An HTTP 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.
85
-
86
- 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. */
87
- url: string;
88
- /** New text of the button in forwarded messages. */
89
- forward_text?: string;
90
- /** 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. */
91
- bot_username?: string;
92
- /** Pass True to request the permission for your bot to send messages to the user. */
93
- request_write_access?: boolean;
94
- }
95
-
96
- /** A placeholder, currently holds no information. Use BotFather to set up your game. */
97
- export interface CallbackGame {}
98
-
99
22
  /** This object represents one result of an inline query. Telegram clients currently support results of the following 20 types:
100
23
  - InlineQueryResultCachedAudio
101
24
  - InlineQueryResultCachedDocument
@@ -213,7 +136,7 @@ export interface InlineQueryResultGif {
213
136
  gif_duration?: number;
214
137
  /** URL of the static (JPEG or GIF) or animated (MPEG4) thumbnail for the result */
215
138
  thumb_url: string;
216
- /** MIME type of the thumbnail, must be one of image/jpeg”, image/gif”, or video/mp4”. Defaults to image/jpeg */
139
+ /** MIME type of the thumbnail, must be one of "image/jpeg", "image/gif", or "video/mp4". Defaults to "image/jpeg" */
217
140
  thumb_mime_type?: "image/jpeg" | "image/gif" | "video/mp4";
218
141
  /** Title for the result */
219
142
  title?: string;
@@ -243,7 +166,7 @@ export interface InlineQueryResultMpeg4Gif {
243
166
  mpeg4_duration?: number;
244
167
  /** URL of the static (JPEG or GIF) or animated (MPEG4) thumbnail for the result */
245
168
  thumb_url: string;
246
- /** MIME type of the thumbnail, must be one of image/jpeg”, image/gif”, or video/mp4”. Defaults to image/jpeg */
169
+ /** MIME type of the thumbnail, must be one of "image/jpeg", "image/gif", or "video/mp4". Defaults to "image/jpeg" */
247
170
  thumb_mime_type?: "image/jpeg" | "image/gif" | "video/mp4";
248
171
  /** Title for the result */
249
172
  title?: string;
@@ -267,7 +190,7 @@ export interface InlineQueryResultVideo {
267
190
  id: string;
268
191
  /** A valid URL for the embedded video player or video file */
269
192
  video_url: string;
270
- /** Mime type of the content of video url, text/html or video/mp4 */
193
+ /** Mime type of the content of video url, "text/html" or "video/mp4" */
271
194
  mime_type: "text/html" | "video/mp4";
272
195
  /** URL of the thumbnail (JPEG only) for the video */
273
196
  thumb_url: string;
@@ -431,7 +354,7 @@ export interface InlineQueryResultVenue {
431
354
  address: string;
432
355
  /** Foursquare identifier of the venue if known */
433
356
  foursquare_id?: string;
434
- /** Foursquare type of the venue, if known. (For example, arts_entertainment/default”, arts_entertainment/aquarium or food/icecream”.) */
357
+ /** Foursquare type of the venue, if known. (For example, "arts_entertainment/default", "arts_entertainment/aquarium" or "food/icecream".) */
435
358
  foursquare_type?: string;
436
359
  /** Google Places identifier of the venue */
437
360
  google_place_id?: string;
@@ -720,7 +643,7 @@ export interface InputVenueMessageContent {
720
643
  address: string;
721
644
  /** Foursquare identifier of the venue, if known */
722
645
  foursquare_id?: string;
723
- /** Foursquare type of the venue, if known. (For example, arts_entertainment/default”, arts_entertainment/aquarium or food/icecream”.) */
646
+ /** Foursquare type of the venue, if known. (For example, "arts_entertainment/default", "arts_entertainment/aquarium" or "food/icecream".) */
724
647
  foursquare_type?: string;
725
648
  /** Google Places identifier of the venue */
726
649
  google_place_id?: string;
package/manage.d.ts CHANGED
@@ -15,6 +15,8 @@ export interface WebhookInfo {
15
15
  last_error_date: number;
16
16
  /** Error message in human-readable format for the most recent error that happened when trying to deliver an update via webhook */
17
17
  last_error_message: string;
18
+ /** Unix time of the most recent error that happened when trying to synchronize available updates with Telegram datacenters */
19
+ last_synchronization_error_date?: number;
18
20
  /** Maximum allowed number of simultaneous HTTPS connections to the webhook for update delivery */
19
21
  max_connections: number;
20
22
  /** A list of update types the bot is subscribed to. Defaults to all update types except chat_member */
@@ -53,7 +55,7 @@ export namespace Chat {
53
55
  // ABSTRACT
54
56
  /** Internal type holding properties that all kinds of chats share. */
55
57
  interface AbstractChat {
56
- /** Type of chat, can be either private”, group”, supergroup or channel */
58
+ /** Type of chat, can be either "private", "group", "supergroup" or "channel" */
57
59
  type: string;
58
60
  /** Unique identifier for this chat. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this identifier. */
59
61
  id: number;
@@ -86,7 +88,9 @@ export namespace Chat {
86
88
  }
87
89
  /** Internal type representing super group chats. */
88
90
  export interface SupergroupChat
89
- extends AbstractChat, UserNameChat, TitleChat {
91
+ extends AbstractChat,
92
+ UserNameChat,
93
+ TitleChat {
90
94
  type: "supergroup";
91
95
  }
92
96
  /** Internal type representing channel chats. */
@@ -138,7 +142,9 @@ export namespace Chat {
138
142
  export interface GroupGetChat extends GroupChat, MultiUserGetChat {}
139
143
  /** Internal type representing supergroup chats returned from `getChat`. */
140
144
  export interface SupergroupGetChat
141
- extends SupergroupChat, MultiUserGetChat, LargeGetChat {
145
+ extends SupergroupChat,
146
+ MultiUserGetChat,
147
+ LargeGetChat {
142
148
  /** For supergroups, the minimum allowed delay between consecutive messages sent by each unpriviledged user; in seconds. Returned only in getChat. */
143
149
  slow_mode_delay?: number;
144
150
  /** For supergroups, name of group sticker set. Returned only in getChat. */
@@ -186,7 +192,7 @@ export interface ChatPhoto {
186
192
 
187
193
  /** Represents an invite link for a chat. */
188
194
  export interface ChatInviteLink {
189
- /** The invite link. If the link was created by another chat administrator, then the second part of the link will be replaced with “…”. */
195
+ /** The invite link. If the link was created by another chat administrator, then the second part of the link will be replaced with "...". */
190
196
  invite_link: string;
191
197
  /** Creator of the link */
192
198
  creator: User;
@@ -206,6 +212,32 @@ export interface ChatInviteLink {
206
212
  pending_join_request_count?: number;
207
213
  }
208
214
 
215
+ /** Represents the rights of an administrator in a chat. */
216
+ export interface ChatAdministratorRights {
217
+ /** True, if the user's presence in the chat is hidden */
218
+ is_anonymous: boolean;
219
+ /** True, if the administrator can access the chat event log, chat statistics, message statistics in channels, see channel members, see anonymous administrators in supergroups and ignore slow mode. Implied by any other administrator privilege */
220
+ can_manage_chat: boolean;
221
+ /** True, if the administrator can delete messages of other users */
222
+ can_delete_messages: boolean;
223
+ /** True, if the administrator can manage video chats */
224
+ can_manage_video_chats: boolean;
225
+ /** True, if the administrator can restrict, ban or unban chat members */
226
+ can_restrict_members: boolean;
227
+ /** True, if the administrator can add new administrators with a subset of their own privileges or demote administrators that he has promoted, directly or indirectly (promoted by administrators that were appointed by the user) */
228
+ can_promote_members: boolean;
229
+ /** True, if the user is allowed to change the chat title, photo and other settings */
230
+ can_change_info: boolean;
231
+ /** True, if the user is allowed to invite new users to the chat */
232
+ can_invite_users: boolean;
233
+ /** True, if the administrator can post in the channel; channels only */
234
+ can_post_messages?: boolean;
235
+ /** True, if the administrator can edit messages of other users and can pin messages; channels only */
236
+ can_edit_messages?: boolean;
237
+ /** True, if the user is allowed to pin messages; groups and supergroups only */
238
+ can_pin_messages?: boolean;
239
+ }
240
+
209
241
  /** This object contains information about one member of a chat. Currently, the following 6 types of chat members are supported:
210
242
  - ChatMemberOwner
211
243
  - ChatMemberAdministrator
@@ -223,7 +255,7 @@ export type ChatMember =
223
255
 
224
256
  /** Represents a chat member that owns the chat and has all administrator privileges. */
225
257
  export interface ChatMemberOwner {
226
- /** The member's status in the chat, always creator */
258
+ /** The member's status in the chat, always "creator" */
227
259
  status: "creator";
228
260
  /** Information about the user */
229
261
  user: User;
@@ -235,7 +267,7 @@ export interface ChatMemberOwner {
235
267
 
236
268
  /** Represents a chat member that has some additional privileges. */
237
269
  export interface ChatMemberAdministrator {
238
- /** The member's status in the chat, always administrator */
270
+ /** The member's status in the chat, always "administrator" */
239
271
  status: "administrator";
240
272
  /** Information about the user */
241
273
  user: User;
@@ -247,8 +279,8 @@ export interface ChatMemberAdministrator {
247
279
  can_manage_chat: boolean;
248
280
  /** True, if the administrator can delete messages of other users */
249
281
  can_delete_messages: boolean;
250
- /** True, if the administrator can manage voice chats */
251
- can_manage_voice_chats: boolean;
282
+ /** True, if the administrator can manage video chats */
283
+ can_manage_video_chats: boolean;
252
284
  /** True, if the administrator can restrict, ban or unban chat members */
253
285
  can_restrict_members: boolean;
254
286
  /** True, if the administrator can add new administrators with a subset of their own privileges or demote administrators that he has promoted, directly or indirectly (promoted by administrators that were appointed by the user) */
@@ -269,7 +301,7 @@ export interface ChatMemberAdministrator {
269
301
 
270
302
  /** Represents a chat member that has no additional privileges or restrictions. */
271
303
  export interface ChatMemberMember {
272
- /** The member's status in the chat, always member */
304
+ /** The member's status in the chat, always "member" */
273
305
  status: "member";
274
306
  /** Information about the user */
275
307
  user: User;
@@ -277,7 +309,7 @@ export interface ChatMemberMember {
277
309
 
278
310
  /** Represents a chat member that is under certain restrictions in the chat. Supergroups only. */
279
311
  export interface ChatMemberRestricted {
280
- /** The member's status in the chat, always restricted */
312
+ /** The member's status in the chat, always "restricted" */
281
313
  status: "restricted";
282
314
  /** Information about the user */
283
315
  user: User;
@@ -305,7 +337,7 @@ export interface ChatMemberRestricted {
305
337
 
306
338
  /** Represents a chat member that isn't currently a member of the chat, but may join it themselves. */
307
339
  export interface ChatMemberLeft {
308
- /** The member's status in the chat, always left */
340
+ /** The member's status in the chat, always "left" */
309
341
  status: "left";
310
342
  /** Information about the user */
311
343
  user: User;
@@ -313,7 +345,7 @@ export interface ChatMemberLeft {
313
345
 
314
346
  /** Represents a chat member that was banned in the chat and can't return to the chat or view chat messages. */
315
347
  export interface ChatMemberBanned {
316
- /** The member's status in the chat, always kicked */
348
+ /** The member's status in the chat, always "kicked" */
317
349
  status: "kicked";
318
350
  /** Information about the user */
319
351
  user: User;
@@ -1,6 +1,109 @@
1
1
  import { User } from "./manage";
2
2
  import { Message } from "./message";
3
3
 
4
+ /** This object represents an inline keyboard that appears right next to the message it belongs to. */
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 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=<user_id> can be used to mention a user by their ID 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 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. */
25
+ web_app: WebAppInfo;
26
+ }
27
+ export interface LoginButton extends AbstractInlineKeyboardButton {
28
+ /** An HTTP 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. Can be empty, in which case just the bot's username will be inserted.
33
+
34
+ Note: This offers an easy way for users to start using your bot in inline mode when they are currently in a private chat with it. Especially useful when combined with switch_pm... actions – in this case the user will be automatically returned to the chat they switched from, skipping the chat selection screen. */
35
+ switch_inline_query: string;
36
+ }
37
+ export interface SwitchInlineCurrentChatButton
38
+ extends AbstractInlineKeyboardButton {
39
+ /** 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.
40
+
41
+ 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. */
42
+ switch_inline_query_current_chat: string;
43
+ }
44
+ export interface GameButton extends AbstractInlineKeyboardButton {
45
+ /** Description of the game that will be launched when the user presses the button.
46
+
47
+ NOTE: This type of button must always be the first button in the first row. */
48
+ callback_game: CallbackGame;
49
+ }
50
+ export interface PayButton extends AbstractInlineKeyboardButton {
51
+ /** Specify True, to send a Pay button.
52
+
53
+ NOTE: This type of button must always be the first button in the first row and can only be used in invoice messages. */
54
+ pay: boolean;
55
+ }
56
+ }
57
+
58
+ /** This object represents one button of an inline keyboard. You must use exactly one of the optional fields. */
59
+ export type InlineKeyboardButton =
60
+ | InlineKeyboardButton.CallbackButton
61
+ | InlineKeyboardButton.GameButton
62
+ | InlineKeyboardButton.LoginButton
63
+ | InlineKeyboardButton.PayButton
64
+ | InlineKeyboardButton.SwitchInlineButton
65
+ | InlineKeyboardButton.SwitchInlineCurrentChatButton
66
+ | InlineKeyboardButton.UrlButton
67
+ | InlineKeyboardButton.WebAppButton;
68
+
69
+ /** 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.
70
+ Telegram apps support these buttons as of version 5.7. */
71
+ export interface LoginUrl {
72
+ /** An HTTP 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.
73
+
74
+ 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. */
75
+ url: string;
76
+ /** New text of the button in forwarded messages. */
77
+ forward_text?: string;
78
+ /** 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. */
79
+ bot_username?: string;
80
+ /** Pass True to request the permission for your bot to send messages to the user. */
81
+ request_write_access?: boolean;
82
+ }
83
+
84
+ /** A placeholder, currently holds no information. Use BotFather to set up your game. */
85
+ export interface CallbackGame {}
86
+
87
+ /** 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.
88
+
89
+ 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). */
90
+ export interface CallbackQuery {
91
+ /** Unique identifier for this query */
92
+ id: string;
93
+ /** Sender */
94
+ from: User;
95
+ /** Message with the callback button that originated the query. Note that message content and message date will not be available if the message is too old */
96
+ message?: Message;
97
+ /** Identifier of the message sent via the bot in inline mode, that originated the query. */
98
+ inline_message_id?: string;
99
+ /** Global identifier, uniquely corresponding to the chat to which the message with the callback button was sent. Useful for high scores in games. */
100
+ chat_instance: string;
101
+ /** Data associated with the callback button. Be aware that a bad client can send arbitrary data in this field. */
102
+ data?: string;
103
+ /** Short name of a Game to be returned, serves as the unique identifier for the game */
104
+ game_short_name?: string;
105
+ }
106
+
4
107
  /** This object represents a custom keyboard with reply options (see Introduction to bots for details and examples). */
5
108
  export interface ReplyKeyboardMarkup {
6
109
  /** Array of button rows, each represented by an Array of KeyboardButton objects */
@@ -23,25 +126,30 @@ export namespace KeyboardButton {
23
126
  text: string;
24
127
  }
25
128
  export interface RequestContactButton extends CommonButton {
26
- /** If True, the user's phone number will be sent as a contact when the button is pressed. Available in private chats only */
129
+ /** If True, the user's phone number will be sent as a contact when the button is pressed. Available in private chats only. */
27
130
  request_contact: boolean;
28
131
  }
29
132
  export interface RequestLocationButton extends CommonButton {
30
- /** If True, the user's current location will be sent when the button is pressed. Available in private chats only */
133
+ /** If True, the user's current location will be sent when the button is pressed. Available in private chats only. */
31
134
  request_location: boolean;
32
135
  }
33
136
  export interface RequestPollButton extends CommonButton {
34
- /** 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 */
137
+ /** 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. */
35
138
  request_poll: KeyboardButtonPollType;
36
139
  }
140
+ export interface WebAppButton extends CommonButton {
141
+ /** 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. */
142
+ web_app: WebAppInfo;
143
+ }
37
144
  }
38
145
 
39
- /** This object represents one button of the reply keyboard. For simple text buttons String can be used instead of this object to specify text of the button. Optional fields request_contact, request_location, and request_poll are mutually exclusive. */
146
+ /** This object represents one button of the reply keyboard. For simple text buttons String can be used instead of this object to specify text of the button. Optional fields web_app, request_contact, request_location, and request_poll are mutually exclusive. */
40
147
  export type KeyboardButton =
41
148
  | KeyboardButton.CommonButton
42
149
  | KeyboardButton.RequestContactButton
43
150
  | KeyboardButton.RequestLocationButton
44
151
  | KeyboardButton.RequestPollButton
152
+ | KeyboardButton.WebAppButton
45
153
  | string;
46
154
 
47
155
  /** This object represents type of a poll, which is allowed to be created and sent when the corresponding button is pressed. */
@@ -60,26 +168,6 @@ export interface ReplyKeyboardRemove {
60
168
  selective?: boolean;
61
169
  }
62
170
 
63
- /** 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.
64
-
65
- 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). */
66
- export interface CallbackQuery {
67
- /** Unique identifier for this query */
68
- id: string;
69
- /** Sender */
70
- from: User;
71
- /** Message with the callback button that originated the query. Note that message content and message date will not be available if the message is too old */
72
- message?: Message;
73
- /** Identifier of the message sent via the bot in inline mode, that originated the query. */
74
- inline_message_id?: string;
75
- /** Global identifier, uniquely corresponding to the chat to which the message with the callback button was sent. Useful for high scores in games. */
76
- chat_instance: string;
77
- /** Data associated with the callback button. Be aware that a bad client can send arbitrary data in this field. */
78
- data?: string;
79
- /** Short name of a Game to be returned, serves as the unique identifier for the game */
80
- game_short_name?: string;
81
- }
82
-
83
171
  /** 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.
84
172
 
85
173
  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:
@@ -97,3 +185,9 @@ export interface ForceReply {
97
185
  /** 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 (has reply_to_message_id), sender of the original message. */
98
186
  selective?: boolean;
99
187
  }
188
+
189
+ /** Contains information about a Web App. */
190
+ export interface WebAppInfo {
191
+ /** An HTTPS URL of a Web App to be opened with additional data as specified in Initializing Web Apps */
192
+ url: string;
193
+ }
@@ -1,3 +1,38 @@
1
+ import { WebAppInfo } from "./markup";
2
+
3
+ /** This object describes the bot's menu button in a private chat. It should be one of
4
+ - MenuButtonCommands
5
+ - MenuButtonWebApp
6
+ - MenuButtonDefault
7
+
8
+ 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. */
9
+ export type MenuButton =
10
+ | MenuButtonCommands
11
+ | MenuButtonWebApp
12
+ | MenuButtonDefault;
13
+
14
+ /** Represents a menu button, which opens the bot's list of commands. */
15
+ export interface MenuButtonCommands {
16
+ /** Type of the button, must be commands */
17
+ type: "commands";
18
+ }
19
+
20
+ /** Represents a menu button, which launches a Web App. */
21
+ export interface MenuButtonWebApp {
22
+ /** Button type, must be web_app */
23
+ type: "web_app";
24
+ /** Text on the button */
25
+ text: string;
26
+ /** 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. */
27
+ web_app: WebAppInfo;
28
+ }
29
+
30
+ /** Describes that no specific value for the menu button was set. */
31
+ export interface MenuButtonDefault {
32
+ /** Type of the button, must be default */
33
+ type: "default";
34
+ }
35
+
1
36
  /** This object represents the scope to which bot commands are applied. Currently, the following 7 scopes are supported:
2
37
  - BotCommandScopeDefault
3
38
  - BotCommandScopeAllPrivateChats