@tgify/tgify 0.1.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.
Files changed (168) hide show
  1. package/LICENSE +23 -0
  2. package/README.md +356 -0
  3. package/filters.d.ts +1 -0
  4. package/filters.js +1 -0
  5. package/format.d.ts +1 -0
  6. package/format.js +1 -0
  7. package/future.d.ts +1 -0
  8. package/future.js +1 -0
  9. package/lib/button.js +100 -0
  10. package/lib/cli.mjs +105 -0
  11. package/lib/composer.js +582 -0
  12. package/lib/context.js +1219 -0
  13. package/lib/core/helpers/args.js +57 -0
  14. package/lib/core/helpers/check.js +55 -0
  15. package/lib/core/helpers/compact.js +16 -0
  16. package/lib/core/helpers/deunionize.js +12 -0
  17. package/lib/core/helpers/formatting.js +91 -0
  18. package/lib/core/helpers/util.js +50 -0
  19. package/lib/core/network/client.js +330 -0
  20. package/lib/core/network/error.js +21 -0
  21. package/lib/core/network/multipart-stream.js +71 -0
  22. package/lib/core/network/polling.js +87 -0
  23. package/lib/core/network/webhook.js +54 -0
  24. package/lib/core/types/typegram.js +27 -0
  25. package/lib/filters.js +69 -0
  26. package/lib/format.js +38 -0
  27. package/lib/future.js +149 -0
  28. package/lib/index.js +58 -0
  29. package/lib/input.js +61 -0
  30. package/lib/markup.js +121 -0
  31. package/lib/middleware.js +2 -0
  32. package/lib/reactions.js +84 -0
  33. package/lib/router.js +46 -0
  34. package/lib/scenes/base.js +39 -0
  35. package/lib/scenes/context.js +104 -0
  36. package/lib/scenes/index.js +21 -0
  37. package/lib/scenes/stage.js +49 -0
  38. package/lib/scenes/wizard/context.js +31 -0
  39. package/lib/scenes/wizard/index.js +45 -0
  40. package/lib/scenes.js +17 -0
  41. package/lib/session.js +166 -0
  42. package/lib/telegraf.js +256 -0
  43. package/lib/telegram-types.js +6 -0
  44. package/lib/telegram.js +1240 -0
  45. package/lib/types.js +2 -0
  46. package/lib/utils.js +5 -0
  47. package/markup.d.ts +1 -0
  48. package/markup.js +1 -0
  49. package/package.json +140 -0
  50. package/scenes.d.ts +1 -0
  51. package/scenes.js +1 -0
  52. package/session.d.ts +1 -0
  53. package/session.js +1 -0
  54. package/src/button.ts +182 -0
  55. package/src/composer.ts +1008 -0
  56. package/src/context.ts +1661 -0
  57. package/src/core/helpers/args.ts +63 -0
  58. package/src/core/helpers/check.ts +71 -0
  59. package/src/core/helpers/compact.ts +18 -0
  60. package/src/core/helpers/deunionize.ts +26 -0
  61. package/src/core/helpers/formatting.ts +119 -0
  62. package/src/core/helpers/util.ts +96 -0
  63. package/src/core/network/client.ts +396 -0
  64. package/src/core/network/error.ts +29 -0
  65. package/src/core/network/multipart-stream.ts +45 -0
  66. package/src/core/network/polling.ts +94 -0
  67. package/src/core/network/webhook.ts +58 -0
  68. package/src/core/types/typegram.ts +54 -0
  69. package/src/filters.ts +109 -0
  70. package/src/format.ts +110 -0
  71. package/src/future.ts +213 -0
  72. package/src/index.ts +17 -0
  73. package/src/input.ts +59 -0
  74. package/src/markup.ts +142 -0
  75. package/src/middleware.ts +24 -0
  76. package/src/reactions.ts +118 -0
  77. package/src/router.ts +55 -0
  78. package/src/scenes/base.ts +52 -0
  79. package/src/scenes/context.ts +136 -0
  80. package/src/scenes/index.ts +21 -0
  81. package/src/scenes/stage.ts +71 -0
  82. package/src/scenes/wizard/context.ts +58 -0
  83. package/src/scenes/wizard/index.ts +63 -0
  84. package/src/scenes.ts +1 -0
  85. package/src/session.ts +204 -0
  86. package/src/telegraf.ts +354 -0
  87. package/src/telegram-types.ts +219 -0
  88. package/src/telegram.ts +1635 -0
  89. package/src/types.ts +2 -0
  90. package/src/utils.ts +1 -0
  91. package/types.d.ts +1 -0
  92. package/types.js +1 -0
  93. package/typings/button.d.ts +36 -0
  94. package/typings/button.d.ts.map +1 -0
  95. package/typings/composer.d.ts +227 -0
  96. package/typings/composer.d.ts.map +1 -0
  97. package/typings/context.d.ts +655 -0
  98. package/typings/context.d.ts.map +1 -0
  99. package/typings/core/helpers/args.d.ts +11 -0
  100. package/typings/core/helpers/args.d.ts.map +1 -0
  101. package/typings/core/helpers/check.d.ts +56 -0
  102. package/typings/core/helpers/check.d.ts.map +1 -0
  103. package/typings/core/helpers/compact.d.ts +4 -0
  104. package/typings/core/helpers/compact.d.ts.map +1 -0
  105. package/typings/core/helpers/deunionize.d.ts +18 -0
  106. package/typings/core/helpers/deunionize.d.ts.map +1 -0
  107. package/typings/core/helpers/formatting.d.ts +30 -0
  108. package/typings/core/helpers/formatting.d.ts.map +1 -0
  109. package/typings/core/helpers/util.d.ts +26 -0
  110. package/typings/core/helpers/util.d.ts.map +1 -0
  111. package/typings/core/network/client.d.ts +53 -0
  112. package/typings/core/network/client.d.ts.map +1 -0
  113. package/typings/core/network/error.d.ts +16 -0
  114. package/typings/core/network/error.d.ts.map +1 -0
  115. package/typings/core/network/multipart-stream.d.ts +16 -0
  116. package/typings/core/network/multipart-stream.d.ts.map +1 -0
  117. package/typings/core/network/polling.d.ts +16 -0
  118. package/typings/core/network/polling.d.ts.map +1 -0
  119. package/typings/core/network/webhook.d.ts +6 -0
  120. package/typings/core/network/webhook.d.ts.map +1 -0
  121. package/typings/core/types/typegram.d.ts +42 -0
  122. package/typings/core/types/typegram.d.ts.map +1 -0
  123. package/typings/filters.d.ts +18 -0
  124. package/typings/filters.d.ts.map +1 -0
  125. package/typings/format.d.ts +22 -0
  126. package/typings/format.d.ts.map +1 -0
  127. package/typings/future.d.ts +12 -0
  128. package/typings/future.d.ts.map +1 -0
  129. package/typings/index.d.ts +15 -0
  130. package/typings/index.d.ts.map +1 -0
  131. package/typings/input.d.ts +50 -0
  132. package/typings/input.d.ts.map +1 -0
  133. package/typings/markup.d.ts +27 -0
  134. package/typings/markup.d.ts.map +1 -0
  135. package/typings/middleware.d.ts +8 -0
  136. package/typings/middleware.d.ts.map +1 -0
  137. package/typings/reactions.d.ts +32 -0
  138. package/typings/reactions.d.ts.map +1 -0
  139. package/typings/router.d.ts +21 -0
  140. package/typings/router.d.ts.map +1 -0
  141. package/typings/scenes/base.d.ts +22 -0
  142. package/typings/scenes/base.d.ts.map +1 -0
  143. package/typings/scenes/context.d.ts +36 -0
  144. package/typings/scenes/context.d.ts.map +1 -0
  145. package/typings/scenes/index.d.ts +11 -0
  146. package/typings/scenes/index.d.ts.map +1 -0
  147. package/typings/scenes/stage.d.ts +24 -0
  148. package/typings/scenes/stage.d.ts.map +1 -0
  149. package/typings/scenes/wizard/context.d.ts +29 -0
  150. package/typings/scenes/wizard/context.d.ts.map +1 -0
  151. package/typings/scenes/wizard/index.d.ts +16 -0
  152. package/typings/scenes/wizard/index.d.ts.map +1 -0
  153. package/typings/scenes.d.ts +2 -0
  154. package/typings/scenes.d.ts.map +1 -0
  155. package/typings/session.d.ts +55 -0
  156. package/typings/session.d.ts.map +1 -0
  157. package/typings/telegraf.d.ts +115 -0
  158. package/typings/telegraf.d.ts.map +1 -0
  159. package/typings/telegram-types.d.ts +117 -0
  160. package/typings/telegram-types.d.ts.map +1 -0
  161. package/typings/telegram.d.ts +675 -0
  162. package/typings/telegram.d.ts.map +1 -0
  163. package/typings/types.d.ts +3 -0
  164. package/typings/types.d.ts.map +1 -0
  165. package/typings/utils.d.ts +2 -0
  166. package/typings/utils.d.ts.map +1 -0
  167. package/utils.d.ts +1 -0
  168. package/utils.js +1 -0
@@ -0,0 +1,1240 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Telegram = void 0;
7
+ const client_1 = __importDefault(require("./core/network/client"));
8
+ const path_1 = require("path");
9
+ const url_1 = require("url");
10
+ const format_1 = require("./format");
11
+ const util_1 = require("./core/helpers/util");
12
+ class Telegram extends client_1.default {
13
+ /**
14
+ * Get basic information about the bot
15
+ */
16
+ getMe() {
17
+ return this.callApi('getMe', {});
18
+ }
19
+ /**
20
+ * Get basic info about a file and prepare it for downloading.
21
+ * @param fileId Id of file to get link to
22
+ */
23
+ getFile(fileId) {
24
+ return this.callApi('getFile', { file_id: fileId });
25
+ }
26
+ /**
27
+ * Get download link to a file.
28
+ */
29
+ async getFileLink(fileId) {
30
+ if (typeof fileId === 'string') {
31
+ fileId = await this.getFile(fileId);
32
+ }
33
+ else if (fileId.file_path === undefined) {
34
+ fileId = await this.getFile(fileId.file_id);
35
+ }
36
+ // Local bot API instances return the absolute path to the file
37
+ if (fileId.file_path !== undefined && (0, path_1.isAbsolute)(fileId.file_path)) {
38
+ const url = new url_1.URL(this.options.apiRoot);
39
+ url.port = '';
40
+ url.pathname = fileId.file_path;
41
+ url.protocol = 'file:';
42
+ return url;
43
+ }
44
+ return new url_1.URL(`./file/${this.options.apiMode}${this.token}${this.options.testEnv ? '/test' : ''
45
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
46
+ }/${fileId.file_path}`, this.options.apiRoot);
47
+ }
48
+ /**
49
+ * Directly request incoming updates.
50
+ * You should probably use `Telegraf::launch` instead.
51
+ */
52
+ getUpdates(timeout, limit, offset, allowedUpdates) {
53
+ return this.callApi('getUpdates', {
54
+ allowed_updates: allowedUpdates,
55
+ limit,
56
+ offset,
57
+ timeout,
58
+ });
59
+ }
60
+ getWebhookInfo() {
61
+ return this.callApi('getWebhookInfo', {});
62
+ }
63
+ getGameHighScores(userId, inlineMessageId, chatId, messageId) {
64
+ return this.callApi('getGameHighScores', {
65
+ user_id: userId,
66
+ inline_message_id: inlineMessageId,
67
+ chat_id: chatId,
68
+ message_id: messageId,
69
+ });
70
+ }
71
+ setGameScore(userId, score, inlineMessageId, chatId, messageId, editMessage = true, force = false) {
72
+ return this.callApi('setGameScore', {
73
+ force,
74
+ score,
75
+ user_id: userId,
76
+ inline_message_id: inlineMessageId,
77
+ chat_id: chatId,
78
+ message_id: messageId,
79
+ disable_edit_message: !editMessage,
80
+ });
81
+ }
82
+ /**
83
+ * Specify a url to receive incoming updates via an outgoing webhook.
84
+ * @param url HTTPS url to send updates to. Use an empty string to remove webhook integration
85
+ */
86
+ setWebhook(url, extra) {
87
+ return this.callApi('setWebhook', {
88
+ url,
89
+ ...extra,
90
+ });
91
+ }
92
+ /**
93
+ * Remove webhook integration.
94
+ */
95
+ deleteWebhook(extra) {
96
+ return this.callApi('deleteWebhook', {
97
+ ...extra,
98
+ });
99
+ }
100
+ /**
101
+ * Send a text message.
102
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
103
+ * @param text Text of the message to be sent
104
+ */
105
+ sendMessage(chatId, text, extra) {
106
+ const t = format_1.FmtString.normalise(text);
107
+ return this.callApi('sendMessage', { chat_id: chatId, ...extra, ...t });
108
+ }
109
+ /**
110
+ * Forward existing message.
111
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
112
+ * @param fromChatId Unique identifier for the chat where the original message was sent (or channel username in the format @channelusername)
113
+ * @param messageId Message identifier in the chat specified in from_chat_id
114
+ */
115
+ forwardMessage(chatId, fromChatId, messageId, extra) {
116
+ return this.callApi('forwardMessage', {
117
+ chat_id: chatId,
118
+ from_chat_id: fromChatId,
119
+ message_id: messageId,
120
+ ...extra,
121
+ });
122
+ }
123
+ /**
124
+ * Use this method to forward multiple messages of any kind. If some of the specified messages can't be found or forwarded, they are skipped. Service messages and messages with protected content can't be forwarded. Album grouping is kept for forwarded messages.
125
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
126
+ * @param fromChatId Unique identifier for the chat where the original messages were sent (or channel username in the format @channelusername)
127
+ * @param messageIds Identifiers of 1-100 messages in the chat from_chat_id to forward. The identifiers must be specified in a strictly increasing order.
128
+ */
129
+ forwardMessages(chatId, fromChatId, messageIds, extra) {
130
+ return this.callApi('forwardMessages', {
131
+ chat_id: chatId,
132
+ from_chat_id: fromChatId,
133
+ message_ids: messageIds,
134
+ ...extra,
135
+ });
136
+ }
137
+ /**
138
+ * Use this method when you need to tell the user that something is happening on the bot's side.
139
+ * The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status).
140
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
141
+ */
142
+ sendChatAction(chat_id, action, extra) {
143
+ return this.callApi('sendChatAction', { chat_id, action, ...extra });
144
+ }
145
+ /**
146
+ * Use this method to change the chosen reactions on a message. Service messages can't be reacted to.
147
+ * Automatically forwarded messages from a channel to its discussion group have the same available
148
+ * reactions as messages in the channel. In albums, bots must react to the first message.
149
+ * @param chat_id Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
150
+ * @param message_id Identifier of the target message
151
+ * @param reaction New list of reaction types to set on the message. Currently, as non-premium users, bots can set up
152
+ * to one reaction per message. A custom emoji reaction can be used if it is either already present on the message
153
+ * or explicitly allowed by chat administrators.
154
+ * @param is_big Pass True to set the reaction with a big animation
155
+ * @returns
156
+ */
157
+ setMessageReaction(chat_id, message_id, reaction, is_big) {
158
+ return this.callApi('setMessageReaction', {
159
+ chat_id,
160
+ message_id,
161
+ reaction,
162
+ is_big,
163
+ });
164
+ }
165
+ getUserProfilePhotos(userId, offset, limit) {
166
+ return this.callApi('getUserProfilePhotos', {
167
+ user_id: userId,
168
+ offset,
169
+ limit,
170
+ });
171
+ }
172
+ /**
173
+ * Send point on the map.
174
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
175
+ */
176
+ sendLocation(chatId, latitude, longitude, extra) {
177
+ return this.callApi('sendLocation', {
178
+ chat_id: chatId,
179
+ latitude,
180
+ longitude,
181
+ ...extra,
182
+ });
183
+ }
184
+ sendVenue(chatId, latitude, longitude, title, address, extra) {
185
+ return this.callApi('sendVenue', {
186
+ latitude,
187
+ longitude,
188
+ title,
189
+ address,
190
+ chat_id: chatId,
191
+ ...extra,
192
+ });
193
+ }
194
+ /**
195
+ * @param chatId Unique identifier for the target private chat
196
+ */
197
+ sendInvoice(chatId, invoice, extra) {
198
+ return this.callApi('sendInvoice', {
199
+ chat_id: chatId,
200
+ ...invoice,
201
+ ...extra,
202
+ });
203
+ }
204
+ sendContact(chatId, phoneNumber, firstName, extra) {
205
+ return this.callApi('sendContact', {
206
+ chat_id: chatId,
207
+ phone_number: phoneNumber,
208
+ first_name: firstName,
209
+ ...extra,
210
+ });
211
+ }
212
+ /**
213
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
214
+ */
215
+ sendPhoto(chatId, photo, extra) {
216
+ return this.callApi('sendPhoto', {
217
+ chat_id: chatId,
218
+ photo,
219
+ ...(0, util_1.fmtCaption)(extra),
220
+ });
221
+ }
222
+ /**
223
+ * Send a dice, which will have a random value from 1 to 6.
224
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
225
+ */
226
+ sendDice(chatId, extra) {
227
+ return this.callApi('sendDice', { chat_id: chatId, ...extra });
228
+ }
229
+ /**
230
+ * Send general files. Bots can currently send files of any type of up to 50 MB in size, this limit may be changed in the future.
231
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
232
+ */
233
+ sendDocument(chatId, document, extra) {
234
+ return this.callApi('sendDocument', {
235
+ chat_id: chatId,
236
+ document,
237
+ ...(0, util_1.fmtCaption)(extra),
238
+ });
239
+ }
240
+ /**
241
+ * Send audio files, if you want Telegram clients to display them in the music player.
242
+ * Your audio must be in the .mp3 format.
243
+ * Bots can currently send audio files of up to 50 MB in size, this limit may be changed in the future.
244
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
245
+ */
246
+ sendAudio(chatId, audio, extra) {
247
+ return this.callApi('sendAudio', {
248
+ chat_id: chatId,
249
+ audio,
250
+ ...(0, util_1.fmtCaption)(extra),
251
+ });
252
+ }
253
+ /**
254
+ * Send .webp, animated .tgs, or video .webm stickers
255
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
256
+ */
257
+ sendSticker(chatId, sticker, extra) {
258
+ return this.callApi('sendSticker', { chat_id: chatId, sticker, ...extra });
259
+ }
260
+ /**
261
+ * Send video files, Telegram clients support mp4 videos (other formats may be sent as Document).
262
+ * Bots can currently send video files of up to 50 MB in size, this limit may be changed in the future.
263
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
264
+ */
265
+ sendVideo(chatId, video, extra) {
266
+ return this.callApi('sendVideo', {
267
+ chat_id: chatId,
268
+ video,
269
+ ...(0, util_1.fmtCaption)(extra),
270
+ });
271
+ }
272
+ /**
273
+ * Send .gif animations.
274
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
275
+ */
276
+ sendAnimation(chatId, animation, extra) {
277
+ return this.callApi('sendAnimation', {
278
+ chat_id: chatId,
279
+ animation,
280
+ ...(0, util_1.fmtCaption)(extra),
281
+ });
282
+ }
283
+ /**
284
+ * Send video messages.
285
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
286
+ */
287
+ sendVideoNote(chatId, videoNote, extra) {
288
+ return this.callApi('sendVideoNote', {
289
+ chat_id: chatId,
290
+ video_note: videoNote,
291
+ ...extra,
292
+ });
293
+ }
294
+ /**
295
+ * Send audio files, if you want Telegram clients to display the file as a playable voice message. For this to work, your audio must be in an .ogg file encoded with OPUS (other formats may be sent as Audio or Document). On success, the sent Message is returned. Bots can currently send voice messages of up to 50 MB in size, this limit may be changed in the future.
296
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
297
+ */
298
+ sendVoice(chatId, voice, extra) {
299
+ return this.callApi('sendVoice', {
300
+ chat_id: chatId,
301
+ voice,
302
+ ...(0, util_1.fmtCaption)(extra),
303
+ });
304
+ }
305
+ /**
306
+ * @param chatId Unique identifier for the target chat
307
+ * @param gameShortName Short name of the game, serves as the unique identifier for the game. Set up your games via Botfather.
308
+ */
309
+ sendGame(chatId, gameName, extra) {
310
+ return this.callApi('sendGame', {
311
+ chat_id: chatId,
312
+ game_short_name: gameName,
313
+ ...extra,
314
+ });
315
+ }
316
+ /**
317
+ * Send a group of photos or videos as an album.
318
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
319
+ * @param media A JSON-serialized array describing photos and videos to be sent, must include 2–10 items
320
+ */
321
+ sendMediaGroup(chatId, media, extra) {
322
+ return this.callApi('sendMediaGroup', { chat_id: chatId, media, ...extra });
323
+ }
324
+ /**
325
+ * Send a native poll.
326
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
327
+ * @param question Poll question, 1-255 characters
328
+ * @param options A JSON-serialized list of answer options, 2-10 strings 1-100 characters each
329
+ */
330
+ sendPoll(chatId, question, options, extra) {
331
+ return this.callApi('sendPoll', {
332
+ chat_id: chatId,
333
+ type: 'regular',
334
+ question,
335
+ options,
336
+ ...extra,
337
+ });
338
+ }
339
+ /**
340
+ * Send a native quiz.
341
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
342
+ * @param question Poll question, 1-255 characters
343
+ * @param options A JSON-serialized list of answer options, 2-10 strings 1-100 characters each
344
+ */
345
+ sendQuiz(chatId, question, options, extra) {
346
+ return this.callApi('sendPoll', {
347
+ chat_id: chatId,
348
+ type: 'quiz',
349
+ question,
350
+ options,
351
+ ...extra,
352
+ });
353
+ }
354
+ /**
355
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
356
+ * @param messageId Identifier of the original message with the poll
357
+ */
358
+ stopPoll(chatId, messageId, extra) {
359
+ return this.callApi('stopPoll', {
360
+ chat_id: chatId,
361
+ message_id: messageId,
362
+ ...extra,
363
+ });
364
+ }
365
+ /**
366
+ * Get up to date information about the chat (current name of the user for one-on-one conversations, current username of a user, group or channel, etc.).
367
+ * @param chatId Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
368
+ */
369
+ getChat(chatId) {
370
+ return this.callApi('getChat', { chat_id: chatId });
371
+ }
372
+ /**
373
+ * @param chatId Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
374
+ */
375
+ getChatAdministrators(chatId) {
376
+ return this.callApi('getChatAdministrators', { chat_id: chatId });
377
+ }
378
+ /**
379
+ * Get information about a member of a chat.
380
+ * @param chatId Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
381
+ * @param userId Unique identifier of the target user
382
+ */
383
+ getChatMember(chatId, userId) {
384
+ return this.callApi('getChatMember', { chat_id: chatId, user_id: userId });
385
+ }
386
+ /**
387
+ * Get the number of members in a chat.
388
+ * @param chatId Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
389
+ */
390
+ getChatMembersCount(chatId) {
391
+ return this.callApi('getChatMembersCount', { chat_id: chatId });
392
+ }
393
+ /**
394
+ * Send answers to an inline query.
395
+ * No more than 50 results per query are allowed.
396
+ */
397
+ answerInlineQuery(inlineQueryId, results, extra) {
398
+ return this.callApi('answerInlineQuery', {
399
+ inline_query_id: inlineQueryId,
400
+ results,
401
+ ...extra,
402
+ });
403
+ }
404
+ setChatPermissions(chatId, permissions, extra) {
405
+ return this.callApi('setChatPermissions', {
406
+ chat_id: chatId,
407
+ permissions,
408
+ ...extra,
409
+ });
410
+ }
411
+ /**
412
+ * Kick a user from a group, a supergroup or a channel. In the case of supergroups and channels, the user will not be able to return to the group on their own using invite links, etc., unless unbanned first. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
413
+ * @param chatId Unique identifier for the target group or username of the target supergroup or channel (in the format `@channelusername`)
414
+ * @param untilDate Date when the user will be unbanned, unix time. If user is banned for more than 366 days or less than 30 seconds from the current time they are considered to be banned forever
415
+ */
416
+ banChatMember(chatId, userId, untilDate, extra) {
417
+ return this.callApi('banChatMember', {
418
+ chat_id: chatId,
419
+ user_id: userId,
420
+ until_date: untilDate,
421
+ ...extra,
422
+ });
423
+ }
424
+ /**
425
+ * Kick a user from a group, a supergroup or a channel. In the case of supergroups and channels, the user will not be able to return to the group on their own using invite links, etc., unless unbanned first. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
426
+ * @param chatId Unique identifier for the target group or username of the target supergroup or channel (in the format `@channelusername`)
427
+ * @param untilDate Date when the user will be unbanned, unix time. If user is banned for more than 366 days or less than 30 seconds from the current time they are considered to be banned forever
428
+ * @deprecated since API 5.3. Use {@link Telegram.banChatMember}
429
+ */
430
+ get kickChatMember() {
431
+ return this.banChatMember;
432
+ }
433
+ /**
434
+ * Promote or demote a user in a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Pass False for all boolean parameters to demote a user.
435
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
436
+ */
437
+ promoteChatMember(chatId, userId, extra) {
438
+ return this.callApi('promoteChatMember', {
439
+ chat_id: chatId,
440
+ user_id: userId,
441
+ ...extra,
442
+ });
443
+ }
444
+ /**
445
+ * Restrict a user in a supergroup. The bot must be an administrator in the supergroup for this to work and must have the appropriate admin rights. Pass True for all boolean parameters to lift restrictions from a user.
446
+ * @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
447
+ */
448
+ restrictChatMember(chatId, userId, extra) {
449
+ return this.callApi('restrictChatMember', {
450
+ chat_id: chatId,
451
+ user_id: userId,
452
+ ...extra,
453
+ });
454
+ }
455
+ setChatAdministratorCustomTitle(chatId, userId, title) {
456
+ return this.callApi('setChatAdministratorCustomTitle', {
457
+ chat_id: chatId,
458
+ user_id: userId,
459
+ custom_title: title,
460
+ });
461
+ }
462
+ /**
463
+ * Export an invite link to a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
464
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
465
+ */
466
+ exportChatInviteLink(chatId) {
467
+ return this.callApi('exportChatInviteLink', { chat_id: chatId });
468
+ }
469
+ createChatInviteLink(chatId, extra) {
470
+ return this.callApi('createChatInviteLink', {
471
+ chat_id: chatId,
472
+ ...extra,
473
+ });
474
+ }
475
+ createInvoiceLink(invoice) {
476
+ return this.callApi('createInvoiceLink', {
477
+ ...invoice,
478
+ });
479
+ }
480
+ editChatInviteLink(chatId, inviteLink, extra) {
481
+ return this.callApi('editChatInviteLink', {
482
+ chat_id: chatId,
483
+ invite_link: inviteLink,
484
+ ...extra,
485
+ });
486
+ }
487
+ revokeChatInviteLink(chatId, inviteLink) {
488
+ return this.callApi('revokeChatInviteLink', {
489
+ chat_id: chatId,
490
+ invite_link: inviteLink,
491
+ });
492
+ }
493
+ setChatPhoto(chatId, photo) {
494
+ return this.callApi('setChatPhoto', { chat_id: chatId, photo });
495
+ }
496
+ deleteChatPhoto(chatId) {
497
+ return this.callApi('deleteChatPhoto', { chat_id: chatId });
498
+ }
499
+ /**
500
+ * Change the title of a chat. Titles can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
501
+ * @param chatId Unique identifier for the target group or username of the target supergroup or channel (in the format `@channelusername`)
502
+ * @param title New chat title, 1-255 characters
503
+ */
504
+ setChatTitle(chatId, title) {
505
+ return this.callApi('setChatTitle', { chat_id: chatId, title });
506
+ }
507
+ setChatDescription(chatId, description) {
508
+ return this.callApi('setChatDescription', { chat_id: chatId, description });
509
+ }
510
+ /**
511
+ * Pin a message in a group, a supergroup, or a channel. The bot must be an administrator in the chat for this to work and must have the 'can_pin_messages' admin right in the supergroup or 'can_edit_messages' admin right in the channel.
512
+ * @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
513
+ */
514
+ pinChatMessage(chatId, messageId, extra) {
515
+ return this.callApi('pinChatMessage', {
516
+ chat_id: chatId,
517
+ message_id: messageId,
518
+ ...extra,
519
+ });
520
+ }
521
+ /**
522
+ * Unpin a message in a group, a supergroup, or a channel. The bot must be an administrator in the chat for this to work and must have the 'can_pin_messages' admin right in the supergroup or 'can_edit_messages' admin right in the channel.
523
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
524
+ */
525
+ unpinChatMessage(chatId, messageId) {
526
+ return this.callApi('unpinChatMessage', {
527
+ chat_id: chatId,
528
+ message_id: messageId,
529
+ });
530
+ }
531
+ /**
532
+ * Clear the list of pinned messages in a chat.
533
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
534
+ */
535
+ unpinAllChatMessages(chatId) {
536
+ return this.callApi('unpinAllChatMessages', { chat_id: chatId });
537
+ }
538
+ /**
539
+ * Use this method for your bot to leave a group, supergroup or channel.
540
+ * @param chatId Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
541
+ */
542
+ leaveChat(chatId) {
543
+ return this.callApi('leaveChat', { chat_id: chatId });
544
+ }
545
+ /**
546
+ * Unban a user from a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
547
+ * @param chatId Unique identifier for the target group or username of the target supergroup or channel (in the format @username)
548
+ * @param userId Unique identifier of the target user
549
+ */
550
+ unbanChatMember(chatId, userId, extra) {
551
+ return this.callApi('unbanChatMember', {
552
+ chat_id: chatId,
553
+ user_id: userId,
554
+ ...extra,
555
+ });
556
+ }
557
+ answerCbQuery(callbackQueryId, text, extra) {
558
+ return this.callApi('answerCallbackQuery', {
559
+ text,
560
+ callback_query_id: callbackQueryId,
561
+ ...extra,
562
+ });
563
+ }
564
+ answerGameQuery(callbackQueryId, url) {
565
+ return this.callApi('answerCallbackQuery', {
566
+ url,
567
+ callback_query_id: callbackQueryId,
568
+ });
569
+ }
570
+ /**
571
+ * Use this method to get the list of boosts added to a chat by a user. Requires administrator rights in the chat. Returns a UserChatBoosts object.
572
+ * @param chat_id Unique identifier for the chat or username of the channel (in the format `@channelusername`)
573
+ * @param user_id Unique identifier of the target user
574
+ */
575
+ getUserChatBoosts(chat_id, user_id) {
576
+ return this.callApi('getUserChatBoosts', {
577
+ chat_id,
578
+ user_id,
579
+ });
580
+ }
581
+ /**
582
+ * If you sent an invoice requesting a shipping address and the parameter is_flexible was specified,
583
+ * the Bot API will send an Update with a shipping_query field to the bot.
584
+ * Reply to shipping queries.
585
+ * @param ok Specify True if delivery to the specified address is possible and False if there are any problems (for example, if delivery to the specified address is not possible)
586
+ * @param shippingOptions Required if ok is True. A JSON-serialized array of available shipping options.
587
+ * @param errorMessage Required if ok is False. Error message in human readable form that explains why it is impossible to complete the order (e.g. "Sorry, delivery to your desired address is unavailable'). Telegram will display this message to the user.
588
+ */
589
+ answerShippingQuery(shippingQueryId, ok, shippingOptions, errorMessage) {
590
+ return this.callApi('answerShippingQuery', {
591
+ ok,
592
+ shipping_query_id: shippingQueryId,
593
+ shipping_options: shippingOptions,
594
+ error_message: errorMessage,
595
+ });
596
+ }
597
+ /**
598
+ * Once the user has confirmed their payment and shipping details, the Bot API sends the final confirmation in the form of an Update with the field pre_checkout_query.
599
+ * Respond to such pre-checkout queries. On success, True is returned.
600
+ * Note: The Bot API must receive an answer within 10 seconds after the pre-checkout query was sent.
601
+ * @param ok Specify True if everything is alright (goods are available, etc.) and the bot is ready to proceed with the order. Use False if there are any problems.
602
+ * @param errorMessage Required if ok is False. Error message in human readable form that explains the reason for failure to proceed with the checkout (e.g. "Sorry, somebody just bought the last of our amazing black T-shirts while you were busy filling out your payment details. Please choose a different color or garment!"). Telegram will display this message to the user.
603
+ */
604
+ answerPreCheckoutQuery(preCheckoutQueryId, ok, errorMessage) {
605
+ return this.callApi('answerPreCheckoutQuery', {
606
+ ok,
607
+ pre_checkout_query_id: preCheckoutQueryId,
608
+ error_message: errorMessage,
609
+ });
610
+ }
611
+ answerWebAppQuery(webAppQueryId, result) {
612
+ return this.callApi('answerWebAppQuery', {
613
+ web_app_query_id: webAppQueryId,
614
+ result,
615
+ });
616
+ }
617
+ /**
618
+ * Edit text and game messages sent by the bot or via the bot (for inline bots).
619
+ * On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned.
620
+ * @param chatId Required if inlineMessageId is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
621
+ * @param messageId Required if inlineMessageId is not specified. Identifier of the sent message
622
+ * @param inlineMessageId Required if chatId and messageId are not specified. Identifier of the inline message
623
+ * @param text New text of the message
624
+ */
625
+ editMessageText(chatId, messageId, inlineMessageId, text, extra) {
626
+ const t = format_1.FmtString.normalise(text);
627
+ return this.callApi('editMessageText', {
628
+ chat_id: chatId,
629
+ message_id: messageId,
630
+ inline_message_id: inlineMessageId,
631
+ ...extra,
632
+ ...t,
633
+ });
634
+ }
635
+ /**
636
+ * Edit captions of messages sent by the bot or via the bot (for inline bots).
637
+ * On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned.
638
+ * @param chatId Required if inlineMessageId is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
639
+ * @param messageId Required if inlineMessageId is not specified. Identifier of the sent message
640
+ * @param inlineMessageId Required if chatId and messageId are not specified. Identifier of the inline message
641
+ * @param caption New caption of the message
642
+ * @param markup A JSON-serialized object for an inline keyboard.
643
+ */
644
+ editMessageCaption(chatId, messageId, inlineMessageId, caption, extra) {
645
+ return this.callApi('editMessageCaption', {
646
+ chat_id: chatId,
647
+ message_id: messageId,
648
+ inline_message_id: inlineMessageId,
649
+ ...extra,
650
+ ...(0, util_1.fmtCaption)({ caption }),
651
+ });
652
+ }
653
+ /**
654
+ * Edit animation, audio, document, photo, or video messages.
655
+ * If a message is a part of a message album, then it can be edited only to a photo or a video.
656
+ * Otherwise, message type can be changed arbitrarily.
657
+ * When inline message is edited, new file can't be uploaded.
658
+ * Use previously uploaded file via its file_id or specify a URL.
659
+ * @param chatId Required if inlineMessageId is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
660
+ * @param messageId Required if inlineMessageId is not specified. Identifier of the sent message
661
+ * @param inlineMessageId Required if chatId and messageId are not specified. Identifier of the inline message
662
+ * @param media New media of message
663
+ * @param extra Additional parameters, such as reply_markup
664
+ */
665
+ editMessageMedia(chatId, messageId, inlineMessageId, media, extra) {
666
+ return this.callApi('editMessageMedia', {
667
+ chat_id: chatId,
668
+ message_id: messageId,
669
+ inline_message_id: inlineMessageId,
670
+ media: (0, util_1.fmtCaption)(media),
671
+ ...extra,
672
+ });
673
+ }
674
+ /**
675
+ * Edit only the reply markup of messages sent by the bot or via the bot (for inline bots).
676
+ * @param chatId Required if inlineMessageId is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
677
+ * @param messageId Required if inlineMessageId is not specified. Identifier of the sent message
678
+ * @param inlineMessageId Required if chatId and messageId are not specified. Identifier of the inline message
679
+ * @param markup A JSON-serialized object for an inline keyboard.
680
+ * @returns If edited message is sent by the bot, the edited Message is returned, otherwise True is returned.
681
+ */
682
+ editMessageReplyMarkup(chatId, messageId, inlineMessageId, markup) {
683
+ return this.callApi('editMessageReplyMarkup', {
684
+ chat_id: chatId,
685
+ message_id: messageId,
686
+ inline_message_id: inlineMessageId,
687
+ reply_markup: markup,
688
+ });
689
+ }
690
+ editMessageLiveLocation(chatId, messageId, inlineMessageId, latitude, longitude, extra) {
691
+ return this.callApi('editMessageLiveLocation', {
692
+ latitude,
693
+ longitude,
694
+ chat_id: chatId,
695
+ message_id: messageId,
696
+ inline_message_id: inlineMessageId,
697
+ ...extra,
698
+ });
699
+ }
700
+ stopMessageLiveLocation(chatId, messageId, inlineMessageId, markup) {
701
+ return this.callApi('stopMessageLiveLocation', {
702
+ chat_id: chatId,
703
+ message_id: messageId,
704
+ inline_message_id: inlineMessageId,
705
+ reply_markup: markup,
706
+ });
707
+ }
708
+ /**
709
+ * Delete a message, including service messages, with the following limitations:
710
+ * - A message can only be deleted if it was sent less than 48 hours ago.
711
+ * - Bots can delete outgoing messages in groups and supergroups.
712
+ * - Bots granted can_post_messages permissions can delete outgoing messages in channels.
713
+ * - If the bot is an administrator of a group, it can delete any message there.
714
+ * - If the bot has can_delete_messages permission in a supergroup or a channel, it can delete any message there.
715
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
716
+ * @param messageId Identifier of the message to delete
717
+ */
718
+ deleteMessage(chatId, messageId) {
719
+ return this.callApi('deleteMessage', {
720
+ chat_id: chatId,
721
+ message_id: messageId,
722
+ });
723
+ }
724
+ /**
725
+ * Use this method to delete multiple messages simultaneously. If some of the specified messages can't be found, they are skipped.
726
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
727
+ * @param messageIds Identifiers of 1-100 messages to delete. See deleteMessage for limitations on which messages can be deleted
728
+ */
729
+ deleteMessages(chatId, messageIds) {
730
+ return this.callApi('deleteMessages', {
731
+ chat_id: chatId,
732
+ message_ids: messageIds,
733
+ });
734
+ }
735
+ setChatStickerSet(chatId, setName) {
736
+ return this.callApi('setChatStickerSet', {
737
+ chat_id: chatId,
738
+ sticker_set_name: setName,
739
+ });
740
+ }
741
+ deleteChatStickerSet(chatId) {
742
+ return this.callApi('deleteChatStickerSet', { chat_id: chatId });
743
+ }
744
+ /**
745
+ * Use this method to get custom emoji stickers, which can be used as a forum topic icon by any user.
746
+ * Requires no parameters. Returns an Array of Sticker objects.
747
+ *
748
+ * @see https://core.telegram.org/bots/api#getforumtopiciconstickers
749
+ */
750
+ getForumTopicIconStickers() {
751
+ return this.callApi('getForumTopicIconStickers', {});
752
+ }
753
+ /**
754
+ * Use this method to create a topic in a forum supergroup chat. The bot must be an administrator in the chat for this
755
+ * to work and must have the can_manage_topics administrator rights. Returns information about the created topic as a
756
+ * ForumTopic object.
757
+ *
758
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
759
+ * @param name Topic name, 1-128 characters
760
+ *
761
+ * @see https://core.telegram.org/bots/api#createforumtopic
762
+ */
763
+ createForumTopic(chat_id, name, extra) {
764
+ return this.callApi('createForumTopic', {
765
+ chat_id,
766
+ name,
767
+ ...extra,
768
+ });
769
+ }
770
+ /**
771
+ * Use this method to edit name and icon of a topic in a forum supergroup chat. The bot must be an administrator in
772
+ * the chat for this to work and must have can_manage_topics administrator rights, unless it is the creator of the
773
+ * topic. Returns True on success.
774
+ *
775
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
776
+ * @param message_thread_id Unique identifier for the target message thread of the forum topic
777
+ *
778
+ * @see https://core.telegram.org/bots/api#editforumtopic
779
+ */
780
+ editForumTopic(chat_id, message_thread_id, extra) {
781
+ return this.callApi('editForumTopic', {
782
+ chat_id,
783
+ message_thread_id,
784
+ ...extra,
785
+ });
786
+ }
787
+ /**
788
+ * Use this method to close an open topic in a forum supergroup chat. The bot must be an administrator in the chat
789
+ * for this to work and must have the can_manage_topics administrator rights, unless it is the creator of the topic.
790
+ * Returns True on success.
791
+ *
792
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
793
+ * @param message_thread_id Unique identifier for the target message thread of the forum topic
794
+ *
795
+ * @see https://core.telegram.org/bots/api#closeforumtopic
796
+ */
797
+ closeForumTopic(chat_id, message_thread_id) {
798
+ return this.callApi('closeForumTopic', {
799
+ chat_id,
800
+ message_thread_id,
801
+ });
802
+ }
803
+ /**
804
+ * Use this method to reopen a closed topic in a forum supergroup chat. The bot must be an administrator in the chat
805
+ * for this to work and must have the can_manage_topics administrator rights, unless it is the creator of the topic.
806
+ * Returns True on success.
807
+ *
808
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
809
+ * @param message_thread_id Unique identifier for the target message thread of the forum topic
810
+ *
811
+ * @see https://core.telegram.org/bots/api#reopenforumtopic
812
+ */
813
+ reopenForumTopic(chat_id, message_thread_id) {
814
+ return this.callApi('reopenForumTopic', {
815
+ chat_id,
816
+ message_thread_id,
817
+ });
818
+ }
819
+ /**
820
+ * Use this method to delete a forum topic along with all its messages in a forum supergroup chat. The bot must be an
821
+ * administrator in the chat for this to work and must have the can_delete_messages administrator rights.
822
+ * Returns True on success.
823
+ *
824
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
825
+ * @param message_thread_id Unique identifier for the target message thread of the forum topic
826
+ *
827
+ * @see https://core.telegram.org/bots/api#deleteforumtopic
828
+ */
829
+ deleteForumTopic(chat_id, message_thread_id) {
830
+ return this.callApi('deleteForumTopic', {
831
+ chat_id,
832
+ message_thread_id,
833
+ });
834
+ }
835
+ /**
836
+ * Use this method to clear the list of pinned messages in a forum topic. The bot must be an administrator in the chat
837
+ * for this to work and must have the can_pin_messages administrator right in the supergroup. Returns True on success.
838
+ *
839
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
840
+ * @param message_thread_id Unique identifier for the target message thread of the forum topic
841
+ *
842
+ * @see https://core.telegram.org/bots/api#unpinallforumtopicmessages
843
+ */
844
+ unpinAllForumTopicMessages(chat_id, message_thread_id) {
845
+ return this.callApi('unpinAllForumTopicMessages', {
846
+ chat_id,
847
+ message_thread_id,
848
+ });
849
+ }
850
+ /**
851
+ * Use this method to edit the name of the 'General' topic in a forum supergroup chat. The bot must be an administrator
852
+ * in the chat for this to work and must have can_manage_topics administrator rights. Returns True on success.
853
+ *
854
+ * @param chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
855
+ * @param name New topic name, 1-128 characters
856
+ *
857
+ * @see https://core.telegram.org/bots/api#editgeneralforumtopic
858
+ */
859
+ editGeneralForumTopic(chat_id, name) {
860
+ return this.callApi('editGeneralForumTopic', { chat_id, name });
861
+ }
862
+ /**
863
+ * Use this method to close an open 'General' topic in a forum supergroup chat. The bot must be an administrator in the
864
+ * chat for this to work and must have the can_manage_topics administrator rights. Returns True on success.
865
+ *
866
+ * @param chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
867
+ *
868
+ * @see https://core.telegram.org/bots/api#closegeneralforumtopic
869
+ */
870
+ closeGeneralForumTopic(chat_id) {
871
+ return this.callApi('closeGeneralForumTopic', { chat_id });
872
+ }
873
+ /**
874
+ * Use this method to reopen a closed 'General' topic in a forum supergroup chat. The bot must be an administrator in
875
+ * the chat for this to work and must have the can_manage_topics administrator rights. The topic will be automatically
876
+ * unhidden if it was hidden. Returns True on success.
877
+ *
878
+ * @param chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
879
+ *
880
+ * @see https://core.telegram.org/bots/api#reopengeneralforumtopic
881
+ */
882
+ reopenGeneralForumTopic(chat_id) {
883
+ return this.callApi('reopenGeneralForumTopic', { chat_id });
884
+ }
885
+ /**
886
+ * Use this method to hide the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat
887
+ * for this to work and must have the can_manage_topics administrator rights. The topic will be automatically closed
888
+ * if it was open. Returns True on success.
889
+ *
890
+ * @param chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
891
+ *
892
+ * @see https://core.telegram.org/bots/api#hidegeneralforumtopic
893
+ */
894
+ hideGeneralForumTopic(chat_id) {
895
+ return this.callApi('hideGeneralForumTopic', { chat_id });
896
+ }
897
+ /**
898
+ * Use this method to unhide the 'General' topic in a forum supergroup chat. The bot must be an administrator in the
899
+ * chat for this to work and must have the can_manage_topics administrator rights. Returns True on success.
900
+ *
901
+ * @param chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
902
+ *
903
+ * @see https://core.telegram.org/bots/api#unhidegeneralforumtopic
904
+ */
905
+ unhideGeneralForumTopic(chat_id) {
906
+ return this.callApi('unhideGeneralForumTopic', { chat_id });
907
+ }
908
+ /**
909
+ * Use this method to clear the list of pinned messages in a General forum topic.
910
+ * The bot must be an administrator in the chat for this to work and must have the can_pin_messages administrator
911
+ * right in the supergroup.
912
+ *
913
+ * @param chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
914
+ */
915
+ unpinAllGeneralForumTopicMessages(chat_id) {
916
+ return this.callApi('unpinAllGeneralForumTopicMessages', { chat_id });
917
+ }
918
+ getStickerSet(name) {
919
+ return this.callApi('getStickerSet', { name });
920
+ }
921
+ /**
922
+ * Upload a .png file with a sticker for later use in createNewStickerSet and addStickerToSet methods (can be used multiple times).
923
+ * https://core.telegram.org/bots/api#sending-files
924
+ * @param ownerId User identifier of sticker file owner
925
+ * @param stickerFile Png image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px.
926
+ */
927
+ uploadStickerFile(ownerId, sticker, sticker_format) {
928
+ return this.callApi('uploadStickerFile', {
929
+ user_id: ownerId,
930
+ sticker_format,
931
+ sticker,
932
+ });
933
+ }
934
+ /**
935
+ * Create new sticker set owned by a user. The bot will be able to edit the created sticker set.
936
+ * @param ownerId User identifier of created sticker set owner
937
+ * @param name Short name of sticker set, to be used in t.me/addstickers/ URLs (e.g., animals). Can contain only english letters, digits and underscores. Must begin with a letter, can't contain consecutive underscores and must end in “_by_<bot username>”. <bot_username> is case insensitive. 1-64 characters.
938
+ * @param title Sticker set title, 1-64 characters
939
+ */
940
+ createNewStickerSet(ownerId, name, title, stickerData) {
941
+ return this.callApi('createNewStickerSet', {
942
+ name,
943
+ title,
944
+ user_id: ownerId,
945
+ ...stickerData,
946
+ });
947
+ }
948
+ /**
949
+ * Add a new sticker to a set created by the bot.
950
+ * @param ownerId User identifier of sticker set owner
951
+ * @param name Sticker set name
952
+ */
953
+ addStickerToSet(ownerId, name, stickerData) {
954
+ return this.callApi('addStickerToSet', {
955
+ name,
956
+ user_id: ownerId,
957
+ ...stickerData,
958
+ });
959
+ }
960
+ /**
961
+ * Move a sticker in a set created by the bot to a specific position.
962
+ * @param sticker File identifier of the sticker
963
+ * @param position New sticker position in the set, zero-based
964
+ */
965
+ setStickerPositionInSet(sticker, position) {
966
+ return this.callApi('setStickerPositionInSet', {
967
+ sticker,
968
+ position,
969
+ });
970
+ }
971
+ /**
972
+ * @deprecated since API 6.8. Use {@link Telegram.setStickerSetThumbnail}
973
+ */
974
+ get setStickerSetThumb() {
975
+ return this.setStickerSetThumbnail;
976
+ }
977
+ /**
978
+ * Use this method to set the thumbnail of a regular or mask sticker set.
979
+ * The format of the thumbnail file must match the format of the stickers in the set.
980
+ * @param name Sticker set name
981
+ * @param userId User identifier of the sticker set owner
982
+ * @param thumbnail A .WEBP or .PNG image with the thumbnail, must be up to 128 kilobytes in size
983
+ * and have a width and height of exactly 100px, or a .TGS animation with a thumbnail up to
984
+ * 32 kilobytes in size (see
985
+ * [animated sticker technical requirements](https://core.telegram.org/stickers#animated-sticker-requirements)),
986
+ * or a WEBM video with the thumbnail up to 32 kilobytes in size; see
987
+ * [video sticker technical requirements](https://core.telegram.org/stickers#video-sticker-requirements).
988
+ * Pass a file_id as a String to send a file that already exists on the Telegram servers, pass a
989
+ * HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using
990
+ * Input helpers. Animated and video sticker set thumbnails can't be uploaded via HTTP URL.
991
+ * If omitted, then the thumbnail is dropped and the first sticker is used as the thumbnail.
992
+ */
993
+ setStickerSetThumbnail(name, userId, thumbnail) {
994
+ return this.callApi('setStickerSetThumbnail', {
995
+ name,
996
+ user_id: userId,
997
+ thumbnail,
998
+ });
999
+ }
1000
+ setStickerMaskPosition(sticker, mask_position) {
1001
+ return this.callApi('setStickerMaskPosition', { sticker, mask_position });
1002
+ }
1003
+ setStickerKeywords(sticker, keywords) {
1004
+ return this.callApi('setStickerKeywords', { sticker, keywords });
1005
+ }
1006
+ setStickerEmojiList(sticker, emoji_list) {
1007
+ return this.callApi('setStickerEmojiList', { sticker, emoji_list });
1008
+ }
1009
+ deleteStickerSet(name) {
1010
+ return this.callApi('deleteStickerSet', { name });
1011
+ }
1012
+ setStickerSetTitle(name, title) {
1013
+ return this.callApi('setStickerSetTitle', { name, title });
1014
+ }
1015
+ setCustomEmojiStickerSetThumbnail(name, custom_emoji_id) {
1016
+ return this.callApi('setCustomEmojiStickerSetThumbnail', {
1017
+ name,
1018
+ custom_emoji_id,
1019
+ });
1020
+ }
1021
+ /**
1022
+ * Delete a sticker from a set created by the bot.
1023
+ * @param sticker File identifier of the sticker
1024
+ */
1025
+ deleteStickerFromSet(sticker) {
1026
+ return this.callApi('deleteStickerFromSet', { sticker });
1027
+ }
1028
+ getCustomEmojiStickers(custom_emoji_ids) {
1029
+ return this.callApi('getCustomEmojiStickers', { custom_emoji_ids });
1030
+ }
1031
+ /**
1032
+ * Change the list of the bot's commands.
1033
+ * @param commands A list of bot commands to be set as the list of the bot's commands. At most 100 commands can be specified.
1034
+ */
1035
+ setMyCommands(commands, extra) {
1036
+ return this.callApi('setMyCommands', { commands, ...extra });
1037
+ }
1038
+ deleteMyCommands(extra = {}) {
1039
+ return this.callApi('deleteMyCommands', extra);
1040
+ }
1041
+ /**
1042
+ * Get the current list of the bot's commands.
1043
+ */
1044
+ getMyCommands(extra = {}) {
1045
+ return this.callApi('getMyCommands', extra);
1046
+ }
1047
+ /**
1048
+ * Use this method to change the bot's description, which is shown in the chat with the bot if the chat is empty.
1049
+ * @param description New bot description; 0-512 characters. Pass an empty string to remove the dedicated description for the given language.
1050
+ * @param language_code A two-letter ISO 639-1 language code. If empty, the description will be applied to all users for whose language there is no dedicated description.
1051
+ */
1052
+ setMyDescription(description, language_code) {
1053
+ return this.callApi('setMyDescription', { description, language_code });
1054
+ }
1055
+ /**
1056
+ * Use this method to change the bot's name.
1057
+ * @param name New bot name; 0-64 characters. Pass an empty string to remove the dedicated name for the given language.
1058
+ * @param language_code A two-letter ISO 639-1 language code. If empty, the name will be shown to all users for whose language there is no dedicated name.
1059
+ */
1060
+ setMyName(name, language_code) {
1061
+ return this.callApi('setMyName', { name, language_code });
1062
+ }
1063
+ /**
1064
+ * Use this method to get the current bot name for the given user language.
1065
+ * @param language_code A two-letter ISO 639-1 language code or an empty string
1066
+ */
1067
+ getMyName(language_code) {
1068
+ return this.callApi('getMyName', { language_code });
1069
+ }
1070
+ /**
1071
+ * Use this method to get the current bot description for the given user language.
1072
+ * @param language_code A two-letter ISO 639-1 language code.
1073
+ */
1074
+ getMyDescription(language_code) {
1075
+ return this.callApi('getMyDescription', { language_code });
1076
+ }
1077
+ /**
1078
+ * Use this method to change the bot's short description, which is shown on the bot's profile page and is sent together with the link when users share the bot.
1079
+ * @param description New short description for the bot; 0-120 characters. Pass an empty string to remove the dedicated short description for the given language.
1080
+ * @param language_code A two-letter ISO 639-1 language code. If empty, the short description will be applied to all users for whose language there is no dedicated short description.
1081
+ */
1082
+ setMyShortDescription(short_description, language_code) {
1083
+ return this.callApi('setMyShortDescription', {
1084
+ short_description,
1085
+ language_code,
1086
+ });
1087
+ }
1088
+ /**
1089
+ * Use this method to get the current bot short description for the given user language.
1090
+ * @param language_code A two-letter ISO 639-1 language code or an empty string
1091
+ */
1092
+ getMyShortDescription(language_code) {
1093
+ return this.callApi('getMyShortDescription', { language_code });
1094
+ }
1095
+ setPassportDataErrors(userId, errors) {
1096
+ return this.callApi('setPassportDataErrors', {
1097
+ user_id: userId,
1098
+ errors: errors,
1099
+ });
1100
+ }
1101
+ /**
1102
+ * Send copy of existing message.
1103
+ * @deprecated use `copyMessage` instead
1104
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
1105
+ * @param message Received message object
1106
+ */
1107
+ sendCopy(chatId, message, extra) {
1108
+ return this.copyMessage(chatId, message.chat.id, message.message_id, extra);
1109
+ }
1110
+ /**
1111
+ * Send copy of existing message.
1112
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
1113
+ * @param fromChatId Unique identifier for the chat where the original message was sent (or channel username in the format @channelusername)
1114
+ * @param messageId Message identifier in the chat specified in from_chat_id
1115
+ */
1116
+ copyMessage(chatId, fromChatId, messageId, extra) {
1117
+ return this.callApi('copyMessage', {
1118
+ chat_id: chatId,
1119
+ from_chat_id: fromChatId,
1120
+ message_id: messageId,
1121
+ ...(0, util_1.fmtCaption)(extra),
1122
+ });
1123
+ }
1124
+ /**
1125
+ * Use this method to copy messages of any kind. If some of the specified messages can't be found or copied, they are skipped. Service messages, giveaway messages, giveaway winners messages, and invoice messages can't be copied. A quiz poll can be copied only if the value of the field correct_option_id is known to the bot. The method is analogous to the method forwardMessages, but the copied messages don't have a link to the original message. Album grouping is kept for copied messages.
1126
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
1127
+ * @param fromChatId Unique identifier for the chat where the original messages were sent (or channel username in the format @channelusername)
1128
+ * @param messageIds Identifiers of 1-100 messages in the chat from_chat_id to copy. The identifiers must be specified in a strictly increasing order.
1129
+ */
1130
+ copyMessages(chatId, fromChatId, messageIds, extra) {
1131
+ return this.callApi('copyMessages', {
1132
+ chat_id: chatId,
1133
+ from_chat_id: fromChatId,
1134
+ message_ids: messageIds,
1135
+ ...extra,
1136
+ });
1137
+ }
1138
+ /**
1139
+ * Approve a chat join request.
1140
+ * The bot must be an administrator in the chat for this to work and must have the can_invite_users administrator right.
1141
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
1142
+ * @param userId Unique identifier of the target user
1143
+ */
1144
+ approveChatJoinRequest(chatId, userId) {
1145
+ return this.callApi('approveChatJoinRequest', {
1146
+ chat_id: chatId,
1147
+ user_id: userId,
1148
+ });
1149
+ }
1150
+ /**
1151
+ * Decline a chat join request.
1152
+ * The bot must be an administrator in the chat for this to work and must have the can_invite_users administrator right.
1153
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
1154
+ * @param userId Unique identifier of the target user
1155
+ */
1156
+ declineChatJoinRequest(chatId, userId) {
1157
+ return this.callApi('declineChatJoinRequest', {
1158
+ chat_id: chatId,
1159
+ user_id: userId,
1160
+ });
1161
+ }
1162
+ /**
1163
+ * Ban a channel chat in a supergroup or a channel. The owner of the chat will not be able to send messages and join live streams on behalf of the chat, unless it is unbanned first.
1164
+ * The bot must be an administrator in the supergroup or channel for this to work and must have the appropriate administrator rights.
1165
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
1166
+ * @param senderChatId Unique identifier of the target sender chat
1167
+ */
1168
+ banChatSenderChat(chatId, senderChatId, extra) {
1169
+ return this.callApi('banChatSenderChat', {
1170
+ chat_id: chatId,
1171
+ sender_chat_id: senderChatId,
1172
+ ...extra,
1173
+ });
1174
+ }
1175
+ /**
1176
+ * Unban a previously banned channel chat in a supergroup or channel.
1177
+ * The bot must be an administrator for this to work and must have the appropriate administrator rights.
1178
+ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
1179
+ * @param senderChatId Unique identifier of the target sender chat
1180
+ */
1181
+ unbanChatSenderChat(chatId, senderChatId) {
1182
+ return this.callApi('unbanChatSenderChat', {
1183
+ chat_id: chatId,
1184
+ sender_chat_id: senderChatId,
1185
+ });
1186
+ }
1187
+ /**
1188
+ * Use this method to change the bot's menu button in a private chat, or the default menu button. Returns true on success.
1189
+ * @param chatId Unique identifier for the target private chat. If not specified, default bot's menu button will be changed.
1190
+ * @param menuButton An object for the bot's new menu button.
1191
+ */
1192
+ setChatMenuButton({ chatId, menuButton, } = {}) {
1193
+ return this.callApi('setChatMenuButton', {
1194
+ chat_id: chatId,
1195
+ menu_button: menuButton,
1196
+ });
1197
+ }
1198
+ /**
1199
+ * Use this method to get the current value of the bot's menu button in a private chat, or the default menu button. Returns MenuButton on success.
1200
+ * @param chatId Unique identifier for the target private chat. If not specified, default bot's menu button will be returned.
1201
+ */
1202
+ getChatMenuButton({ chatId } = {}) {
1203
+ return this.callApi('getChatMenuButton', {
1204
+ chat_id: chatId,
1205
+ });
1206
+ }
1207
+ /**
1208
+ * Use this method to change the default administrator rights requested by the bot when it's added as an administrator to groups or channels.
1209
+ * These rights will be suggested to users, but they are are free to modify the list before adding the bot.
1210
+ */
1211
+ setMyDefaultAdministratorRights({ rights, forChannels, } = {}) {
1212
+ return this.callApi('setMyDefaultAdministratorRights', {
1213
+ rights,
1214
+ for_channels: forChannels,
1215
+ });
1216
+ }
1217
+ /**
1218
+ * Use this method to get the current default administrator rights of the bot. Returns ChatAdministratorRights on success.
1219
+ * @param forChannels Pass true to get default administrator rights of the bot in channels. Otherwise, default administrator rights of the bot for groups and supergroups will be returned.
1220
+ */
1221
+ getMyDefaultAdministratorRights({ forChannels, } = {}) {
1222
+ return this.callApi('getMyDefaultAdministratorRights', {
1223
+ for_channels: forChannels,
1224
+ });
1225
+ }
1226
+ /**
1227
+ * Log out from the cloud Bot API server before launching the bot locally.
1228
+ */
1229
+ logOut() {
1230
+ return this.callApi('logOut', {});
1231
+ }
1232
+ /**
1233
+ * Close the bot instance before moving it from one local server to another.
1234
+ */
1235
+ close() {
1236
+ return this.callApi('close', {});
1237
+ }
1238
+ }
1239
+ exports.Telegram = Telegram;
1240
+ exports.default = Telegram;