@telegram.ts/types 1.4.0 → 1.6.0

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.
@@ -1,10 +1,12 @@
1
- import type { ChatAdministratorRights, User } from "./manageTypes.js";
2
- import type { Message } from "./messageTypes.js";
1
+ import type { ChatAdministratorRights, User } from "./manageTypes";
2
+ import type { MaybeInaccessibleMessage } from "./messageTypes";
3
+
3
4
  /** This object represents an inline keyboard that appears right next to the message it belongs to. */
4
5
  export interface InlineKeyboardMarkup {
5
6
  /** Array of button rows, each represented by an Array of InlineKeyboardButton objects */
6
7
  inline_keyboard: InlineKeyboardButton[][];
7
8
  }
9
+
8
10
  export declare namespace InlineKeyboardButton {
9
11
  interface AbstractInlineKeyboardButton {
10
12
  /** Label text on the button */
@@ -27,9 +29,7 @@ export declare namespace InlineKeyboardButton {
27
29
  login_url: LoginUrl;
28
30
  }
29
31
  export interface SwitchInlineButton extends AbstractInlineKeyboardButton {
30
- /** 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.
31
-
32
- 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. */
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
33
  switch_inline_query: string;
34
34
  }
35
35
  export interface SwitchInlineCurrentChatButton
@@ -56,8 +56,8 @@ export declare namespace InlineKeyboardButton {
56
56
  NOTE: This type of button must always be the first button in the first row and can only be used in invoice messages. */
57
57
  pay: boolean;
58
58
  }
59
- export {};
60
59
  }
60
+
61
61
  /** This object represents one button of an inline keyboard. You must use exactly one of the optional fields. */
62
62
  export type InlineKeyboardButton =
63
63
  | InlineKeyboardButton.CallbackButton
@@ -69,6 +69,7 @@ export type InlineKeyboardButton =
69
69
  | InlineKeyboardButton.SwitchInlineChosenChatButton
70
70
  | InlineKeyboardButton.UrlButton
71
71
  | InlineKeyboardButton.WebAppButton;
72
+
72
73
  /** 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.
73
74
  Telegram apps support these buttons as of version 5.7. */
74
75
  export interface LoginUrl {
@@ -83,6 +84,7 @@ export interface LoginUrl {
83
84
  /** Pass True to request the permission for your bot to send messages to the user. */
84
85
  request_write_access?: boolean;
85
86
  }
87
+
86
88
  /** This object represents an inline button that switches the current user to inline mode in a chosen chat, with an optional default inline query. */
87
89
  export interface SwitchInlineQueryChosenChat {
88
90
  /** The default inline query to be inserted in the input field. If left empty, only the bot's username will be inserted */
@@ -96,18 +98,20 @@ export interface SwitchInlineQueryChosenChat {
96
98
  /** True, if channel chats can be chosen */
97
99
  allow_channel_chats?: boolean;
98
100
  }
101
+
99
102
  /** A placeholder, currently holds no information. Use BotFather to set up your game. */
100
103
  export interface CallbackGame {}
104
+
101
105
  /** 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.
102
106
 
103
- 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). */
107
+ 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). */
104
108
  export interface CallbackQuery {
105
109
  /** Unique identifier for this query */
106
110
  id: string;
107
111
  /** Sender */
108
112
  from: User;
109
- /** 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 */
110
- message?: Message;
113
+ /** Message sent by the bot with the callback button that originated the query */
114
+ message?: MaybeInaccessibleMessage;
111
115
  /** Identifier of the message sent via the bot in inline mode, that originated the query. */
112
116
  inline_message_id?: string;
113
117
  /** Global identifier, uniquely corresponding to the chat to which the message with the callback button was sent. Useful for high scores in games. */
@@ -117,6 +121,7 @@ export interface CallbackQuery {
117
121
  /** Short name of a Game to be returned, serves as the unique identifier for the game */
118
122
  game_short_name?: string;
119
123
  }
124
+
120
125
  /** This object represents a custom keyboard with reply options (see Introduction to bots for details and examples). */
121
126
  export interface ReplyKeyboardMarkup {
122
127
  /** Array of button rows, each represented by an Array of KeyboardButton objects */
@@ -134,51 +139,55 @@ export interface ReplyKeyboardMarkup {
134
139
  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. */
135
140
  selective?: boolean;
136
141
  }
142
+
137
143
  export declare namespace KeyboardButton {
138
- interface CommonButton {
144
+ export interface CommonButton {
139
145
  /** Text of the button. If none of the optional fields are used, it will be sent as a message when the button is pressed */
140
146
  text: string;
141
147
  }
142
- interface RequestUserButton extends CommonButton {
143
- /** If specified, pressing the button will open a list of suitable users. Tapping on any user will send their identifier to the bot in a “user_shared” service message. Available in private chats only. */
144
- request_user: KeyboardButtonRequestUser;
148
+ export interface RequestUsersButton extends CommonButton {
149
+ /** 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. */
150
+ request_users: KeyboardButtonRequestUsers;
145
151
  }
146
- interface RequestChatButton extends CommonButton {
152
+ export interface RequestChatButton extends CommonButton {
147
153
  /** 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. */
148
154
  request_chat: KeyboardButtonRequestChat;
149
155
  }
150
- interface RequestContactButton extends CommonButton {
156
+ export interface RequestContactButton extends CommonButton {
151
157
  /** If True, the user's phone number will be sent as a contact when the button is pressed. Available in private chats only. */
152
158
  request_contact: boolean;
153
159
  }
154
- interface RequestLocationButton extends CommonButton {
160
+ export interface RequestLocationButton extends CommonButton {
155
161
  /** If True, the user's current location will be sent when the button is pressed. Available in private chats only. */
156
162
  request_location: boolean;
157
163
  }
158
- interface RequestPollButton extends CommonButton {
164
+ export interface RequestPollButton extends CommonButton {
159
165
  /** 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. */
160
166
  request_poll: KeyboardButtonPollType;
161
167
  }
162
- interface WebAppButton extends CommonButton {
168
+ export interface WebAppButton extends CommonButton {
163
169
  /** 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. */
164
170
  web_app: WebAppInfo;
165
171
  }
166
172
  }
167
- /** This object represents one button of the reply keyboard. For simple text buttons, String can be used instead of this object to specify the button text. The optional fields web_app, request_user, request_chat, request_contact, request_location, and request_poll are mutually exclusive. */
173
+
174
+ /** This object represents one button of the reply keyboard. For simple text buttons, String can be used instead of this object to specify the button text. The optional fields web_app, request_users, request_chat, request_contact, request_location, and request_poll are mutually exclusive. */
168
175
  export type KeyboardButton =
169
176
  | KeyboardButton.CommonButton
170
- | KeyboardButton.RequestUserButton
177
+ | KeyboardButton.RequestUsersButton
171
178
  | KeyboardButton.RequestChatButton
172
179
  | KeyboardButton.RequestContactButton
173
180
  | KeyboardButton.RequestLocationButton
174
181
  | KeyboardButton.RequestPollButton
175
182
  | KeyboardButton.WebAppButton
176
183
  | string;
184
+
177
185
  /** This object represents type of a poll, which is allowed to be created and sent when the corresponding button is pressed. */
178
186
  export interface KeyboardButtonPollType {
179
187
  /** 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. */
180
188
  type?: "quiz" | "regular";
181
189
  }
190
+
182
191
  /** 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). */
183
192
  export interface ReplyKeyboardRemove {
184
193
  /** 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) */
@@ -188,6 +197,7 @@ export interface ReplyKeyboardRemove {
188
197
  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. */
189
198
  selective?: boolean;
190
199
  }
200
+
191
201
  /** 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.
192
202
 
193
203
  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:
@@ -205,20 +215,25 @@ export interface ForceReply {
205
215
  /** 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. */
206
216
  selective?: boolean;
207
217
  }
218
+
208
219
  /** Describes a Web App. */
209
220
  export interface WebAppInfo {
210
221
  /** An HTTPS URL of a Web App to be opened with additional data as specified in Initializing Web Apps */
211
222
  url: string;
212
223
  }
213
- /** This object defines the criteria used to request a suitable user. The identifier of the selected user will be shared with the bot when the corresponding button is pressed. */
214
- export interface KeyboardButtonRequestUser {
215
- /** Signed 32-bit identifier of the request, which will be received back in the UserShared object. Must be unique within the message */
224
+
225
+ /** This object defines the criteria used to request suitable users. The identifiers of the selected users will be shared with the bot when the corresponding button is pressed. */
226
+ export interface KeyboardButtonRequestUsers {
227
+ /** Signed 32-bit identifier of the request that will be received back in the UsersShared object. Must be unique within the message */
216
228
  request_id: number;
217
- /** Pass True to request a bot, pass False to request a regular user. If not specified, no additional restrictions are applied. */
229
+ /** Pass True to request bots, pass False to request regular users. If not specified, no additional restrictions are applied. */
218
230
  user_is_bot?: boolean;
219
- /** Pass True to request a premium user, pass False to request a non-premium user. If not specified, no additional restrictions are applied. */
231
+ /** Pass True to request premium users, pass False to request non-premium users. If not specified, no additional restrictions are applied. */
220
232
  user_is_premium?: boolean;
233
+ /** The maximum number of users to be selected; 1-10. Defaults to 1. */
234
+ max_quantity?: boolean;
221
235
  }
236
+
222
237
  /** This object defines the criteria used to request a suitable chat. The identifier of the selected chat will be shared with the bot when the corresponding button is pressed. */
223
238
  export interface KeyboardButtonRequestChat {
224
239
  /** Signed 32-bit identifier of the request, which will be received back in the ChatShared object. Must be unique within the message */