UNPKG

33.3 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.Telegram = void 0;
4const client_1 = require("./core/network/client");
5const path_1 = require("path");
6const url_1 = require("url");
7class Telegram extends client_1.default {
8 /**
9 * Get basic information about the bot
10 */
11 getMe() {
12 return this.callApi('getMe', {});
13 }
14 /**
15 * Get basic info about a file and prepare it for downloading
16 * @param fileId Id of file to get link to
17 */
18 getFile(fileId) {
19 return this.callApi('getFile', { file_id: fileId });
20 }
21 /**
22 * Get download link to a file
23 */
24 async getFileLink(fileId) {
25 if (typeof fileId === 'string') {
26 fileId = await this.getFile(fileId);
27 }
28 else if (fileId.file_path === undefined) {
29 fileId = await this.getFile(fileId.file_id);
30 }
31 // Local bot API instances return the absolute path to the file
32 if (fileId.file_path !== undefined && (0, path_1.isAbsolute)(fileId.file_path)) {
33 const url = new url_1.URL(this.options.apiRoot);
34 url.port = '';
35 url.pathname = fileId.file_path;
36 url.protocol = 'file:';
37 return url;
38 }
39 return new url_1.URL(`./file/${this.options.apiMode}${this.token}/${fileId.file_path}`, this.options.apiRoot);
40 }
41 /**
42 * Directly request incoming updates.
43 * You should probably use `Telegraf::launch` instead.
44 */
45 getUpdates(timeout, limit, offset, allowedUpdates) {
46 return this.callApi('getUpdates', {
47 allowed_updates: allowedUpdates,
48 limit,
49 offset,
50 timeout,
51 });
52 }
53 getWebhookInfo() {
54 return this.callApi('getWebhookInfo', {});
55 }
56 getGameHighScores(userId, inlineMessageId, chatId, messageId) {
57 return this.callApi('getGameHighScores', {
58 user_id: userId,
59 inline_message_id: inlineMessageId,
60 chat_id: chatId,
61 message_id: messageId,
62 });
63 }
64 setGameScore(userId, score, inlineMessageId, chatId, messageId, editMessage = true, force = false) {
65 return this.callApi('setGameScore', {
66 force,
67 score,
68 user_id: userId,
69 inline_message_id: inlineMessageId,
70 chat_id: chatId,
71 message_id: messageId,
72 disable_edit_message: !editMessage,
73 });
74 }
75 /**
76 * Specify a url to receive incoming updates via an outgoing webhook
77 * @param url HTTPS url to send updates to. Use an empty string to remove webhook integration
78 */
79 setWebhook(url, extra) {
80 return this.callApi('setWebhook', {
81 url,
82 ...extra,
83 });
84 }
85 /**
86 * Remove webhook integration
87 */
88 deleteWebhook(extra) {
89 return this.callApi('deleteWebhook', {
90 ...extra,
91 });
92 }
93 /**
94 * Send a text message
95 * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
96 * @param text Text of the message to be sent
97 */
98 sendMessage(chatId, text, extra) {
99 return this.callApi('sendMessage', { chat_id: chatId, text, ...extra });
100 }
101 /**
102 * Forward existing message.
103 * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
104 * @param fromChatId Unique identifier for the chat where the original message was sent (or channel username in the format @channelusername)
105 * @param messageId Message identifier in the chat specified in from_chat_id
106 */
107 forwardMessage(chatId, fromChatId, messageId, extra) {
108 return this.callApi('forwardMessage', {
109 chat_id: chatId,
110 from_chat_id: fromChatId,
111 message_id: messageId,
112 ...extra,
113 });
114 }
115 /**
116 * Use this method when you need to tell the user that something is happening on the bot's side.
117 * The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status).
118 * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
119 */
120 sendChatAction(chatId, action) {
121 return this.callApi('sendChatAction', { chat_id: chatId, action });
122 }
123 getUserProfilePhotos(userId, offset, limit) {
124 return this.callApi('getUserProfilePhotos', {
125 user_id: userId,
126 offset,
127 limit,
128 });
129 }
130 /**
131 * Send point on the map
132 * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
133 */
134 sendLocation(chatId, latitude, longitude, extra) {
135 return this.callApi('sendLocation', {
136 chat_id: chatId,
137 latitude,
138 longitude,
139 ...extra,
140 });
141 }
142 sendVenue(chatId, latitude, longitude, title, address, extra) {
143 return this.callApi('sendVenue', {
144 latitude,
145 longitude,
146 title,
147 address,
148 chat_id: chatId,
149 ...extra,
150 });
151 }
152 /**
153 * @param chatId Unique identifier for the target private chat
154 */
155 sendInvoice(chatId, invoice, extra) {
156 return this.callApi('sendInvoice', {
157 chat_id: chatId,
158 ...invoice,
159 ...extra,
160 });
161 }
162 sendContact(chatId, phoneNumber, firstName, extra) {
163 return this.callApi('sendContact', {
164 chat_id: chatId,
165 phone_number: phoneNumber,
166 first_name: firstName,
167 ...extra,
168 });
169 }
170 /**
171 * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
172 */
173 sendPhoto(chatId, photo, extra) {
174 return this.callApi('sendPhoto', { chat_id: chatId, photo, ...extra });
175 }
176 /**
177 * Send a dice, which will have a random value from 1 to 6.
178 * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
179 */
180 sendDice(chatId, extra) {
181 return this.callApi('sendDice', { chat_id: chatId, ...extra });
182 }
183 /**
184 * 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.
185 * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
186 */
187 sendDocument(chatId, document, extra) {
188 return this.callApi('sendDocument', { chat_id: chatId, document, ...extra });
189 }
190 /**
191 * Send audio files, if you want Telegram clients to display them in the music player.
192 * Your audio must be in the .mp3 format.
193 * Bots can currently send audio files of up to 50 MB in size, this limit may be changed in the future.
194 * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
195 */
196 sendAudio(chatId, audio, extra) {
197 return this.callApi('sendAudio', { chat_id: chatId, audio, ...extra });
198 }
199 /**
200 * Send .webp stickers
201 * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
202 */
203 sendSticker(chatId, sticker, extra) {
204 return this.callApi('sendSticker', { chat_id: chatId, sticker, ...extra });
205 }
206 /**
207 * Send video files, Telegram clients support mp4 videos (other formats may be sent as Document)
208 * Bots can currently send video files of up to 50 MB in size, this limit may be changed in the future.
209 * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
210 */
211 sendVideo(chatId, video, extra) {
212 return this.callApi('sendVideo', { chat_id: chatId, video, ...extra });
213 }
214 /**
215 * Send .gif animations
216 * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
217 */
218 sendAnimation(chatId, animation, extra) {
219 return this.callApi('sendAnimation', {
220 chat_id: chatId,
221 animation,
222 ...extra,
223 });
224 }
225 /**
226 * Send video messages
227 * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
228 */
229 sendVideoNote(chatId, videoNote, extra) {
230 return this.callApi('sendVideoNote', {
231 chat_id: chatId,
232 video_note: videoNote,
233 ...extra,
234 });
235 }
236 /**
237 * 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.
238 * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
239 */
240 sendVoice(chatId, voice, extra) {
241 return this.callApi('sendVoice', { chat_id: chatId, voice, ...extra });
242 }
243 /**
244 * @param chatId Unique identifier for the target chat
245 * @param gameShortName Short name of the game, serves as the unique identifier for the game. Set up your games via Botfather.
246 */
247 sendGame(chatId, gameName, extra) {
248 return this.callApi('sendGame', {
249 chat_id: chatId,
250 game_short_name: gameName,
251 ...extra,
252 });
253 }
254 /**
255 * Send a group of photos or videos as an album
256 * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
257 * @param media A JSON-serialized array describing photos and videos to be sent, must include 2–10 items
258 */
259 sendMediaGroup(chatId, media, extra) {
260 return this.callApi('sendMediaGroup', { chat_id: chatId, media, ...extra });
261 }
262 /**
263 * Send a native poll.
264 * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
265 * @param question Poll question, 1-255 characters
266 * @param options A JSON-serialized list of answer options, 2-10 strings 1-100 characters each
267 */
268 sendPoll(chatId, question, options, extra) {
269 return this.callApi('sendPoll', {
270 chat_id: chatId,
271 type: 'regular',
272 question,
273 options,
274 ...extra,
275 });
276 }
277 /**
278 * Send a native quiz.
279 * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
280 * @param question Poll question, 1-255 characters
281 * @param options A JSON-serialized list of answer options, 2-10 strings 1-100 characters each
282 */
283 sendQuiz(chatId, question, options, extra) {
284 return this.callApi('sendPoll', {
285 chat_id: chatId,
286 type: 'quiz',
287 question,
288 options,
289 ...extra,
290 });
291 }
292 /**
293 * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
294 * @param messageId Identifier of the original message with the poll
295 */
296 stopPoll(chatId, messageId, extra) {
297 return this.callApi('stopPoll', {
298 chat_id: chatId,
299 message_id: messageId,
300 ...extra,
301 });
302 }
303 /**
304 * 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.)
305 * @param chatId Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
306 */
307 getChat(chatId) {
308 return this.callApi('getChat', { chat_id: chatId });
309 }
310 /**
311 * @param chatId Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
312 */
313 getChatAdministrators(chatId) {
314 return this.callApi('getChatAdministrators', { chat_id: chatId });
315 }
316 /**
317 * Get information about a member of a chat.
318 * @param chatId Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
319 * @param userId Unique identifier of the target user
320 */
321 getChatMember(chatId, userId) {
322 return this.callApi('getChatMember', { chat_id: chatId, user_id: userId });
323 }
324 /**
325 * Get the number of members in a chat
326 * @param chatId Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
327 */
328 getChatMembersCount(chatId) {
329 return this.callApi('getChatMembersCount', { chat_id: chatId });
330 }
331 /**
332 * Send answers to an inline query.
333 * No more than 50 results per query are allowed.
334 */
335 answerInlineQuery(inlineQueryId, results, extra) {
336 return this.callApi('answerInlineQuery', {
337 inline_query_id: inlineQueryId,
338 results,
339 ...extra,
340 });
341 }
342 setChatPermissions(chatId, permissions) {
343 return this.callApi('setChatPermissions', { chat_id: chatId, permissions });
344 }
345 /**
346 * 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
347 * @param chatId Unique identifier for the target group or username of the target supergroup or channel (in the format `@channelusername`)
348 * @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
349 */
350 kickChatMember(chatId, userId, untilDate, extra) {
351 return this.callApi('kickChatMember', {
352 chat_id: chatId,
353 user_id: userId,
354 until_date: untilDate,
355 ...extra,
356 });
357 }
358 /**
359 * 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.
360 * @param chatId Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
361 */
362 promoteChatMember(chatId, userId, extra) {
363 return this.callApi('promoteChatMember', {
364 chat_id: chatId,
365 user_id: userId,
366 ...extra,
367 });
368 }
369 /**
370 * 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.
371 * @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
372 */
373 restrictChatMember(chatId, userId, extra) {
374 return this.callApi('restrictChatMember', {
375 chat_id: chatId,
376 user_id: userId,
377 ...extra,
378 });
379 }
380 setChatAdministratorCustomTitle(chatId, userId, title) {
381 return this.callApi('setChatAdministratorCustomTitle', {
382 chat_id: chatId,
383 user_id: userId,
384 custom_title: title,
385 });
386 }
387 /**
388 * 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.
389 * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
390 */
391 exportChatInviteLink(chatId) {
392 return this.callApi('exportChatInviteLink', { chat_id: chatId });
393 }
394 createChatInviteLink(chatId, extra) {
395 return this.callApi('createChatInviteLink', {
396 chat_id: chatId,
397 ...extra,
398 });
399 }
400 editChatInviteLink(chatId, inviteLink, extra) {
401 return this.callApi('editChatInviteLink', {
402 chat_id: chatId,
403 invite_link: inviteLink,
404 ...extra,
405 });
406 }
407 revokeChatInviteLink(chatId, inviteLink) {
408 return this.callApi('revokeChatInviteLink', {
409 chat_id: chatId,
410 invite_link: inviteLink,
411 });
412 }
413 setChatPhoto(chatId, photo) {
414 return this.callApi('setChatPhoto', { chat_id: chatId, photo });
415 }
416 deleteChatPhoto(chatId) {
417 return this.callApi('deleteChatPhoto', { chat_id: chatId });
418 }
419 /**
420 * 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
421 * @param chatId Unique identifier for the target group or username of the target supergroup or channel (in the format `@channelusername`)
422 * @param title New chat title, 1-255 characters
423 */
424 setChatTitle(chatId, title) {
425 return this.callApi('setChatTitle', { chat_id: chatId, title });
426 }
427 setChatDescription(chatId, description) {
428 return this.callApi('setChatDescription', { chat_id: chatId, description });
429 }
430 /**
431 * 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.
432 * @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
433 */
434 pinChatMessage(chatId, messageId, extra) {
435 return this.callApi('pinChatMessage', {
436 chat_id: chatId,
437 message_id: messageId,
438 ...extra,
439 });
440 }
441 /**
442 * 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.
443 * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
444 */
445 unpinChatMessage(chatId, messageId) {
446 return this.callApi('unpinChatMessage', {
447 chat_id: chatId,
448 message_id: messageId,
449 });
450 }
451 /**
452 * Clear the list of pinned messages in a chat
453 * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
454 */
455 unpinAllChatMessages(chatId) {
456 return this.callApi('unpinAllChatMessages', { chat_id: chatId });
457 }
458 /**
459 * Use this method for your bot to leave a group, supergroup or channel
460 * @param chatId Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
461 */
462 leaveChat(chatId) {
463 return this.callApi('leaveChat', { chat_id: chatId });
464 }
465 /**
466 * 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
467 * @param chatId Unique identifier for the target group or username of the target supergroup or channel (in the format @username)
468 * @param userId Unique identifier of the target user
469 */
470 unbanChatMember(chatId, userId, extra) {
471 return this.callApi('unbanChatMember', {
472 chat_id: chatId,
473 user_id: userId,
474 ...extra,
475 });
476 }
477 answerCbQuery(callbackQueryId, text, extra) {
478 return this.callApi('answerCallbackQuery', {
479 text,
480 callback_query_id: callbackQueryId,
481 ...extra,
482 });
483 }
484 answerGameQuery(callbackQueryId, url) {
485 return this.callApi('answerCallbackQuery', {
486 url,
487 callback_query_id: callbackQueryId,
488 });
489 }
490 /**
491 * If you sent an invoice requesting a shipping address and the parameter is_flexible was specified,
492 * the Bot API will send an Update with a shipping_query field to the bot.
493 * Reply to shipping queries.
494 * @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)
495 * @param shippingOptions Required if ok is True. A JSON-serialized array of available shipping options.
496 * @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.
497 */
498 answerShippingQuery(shippingQueryId, ok, shippingOptions, errorMessage) {
499 return this.callApi('answerShippingQuery', {
500 ok,
501 shipping_query_id: shippingQueryId,
502 shipping_options: shippingOptions,
503 error_message: errorMessage,
504 });
505 }
506 /**
507 * 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.
508 * Respond to such pre-checkout queries. On success, True is returned.
509 * Note: The Bot API must receive an answer within 10 seconds after the pre-checkout query was sent.
510 * @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.
511 * @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.
512 */
513 answerPreCheckoutQuery(preCheckoutQueryId, ok, errorMessage) {
514 return this.callApi('answerPreCheckoutQuery', {
515 ok,
516 pre_checkout_query_id: preCheckoutQueryId,
517 error_message: errorMessage,
518 });
519 }
520 /**
521 * Edit text and game messages sent by the bot or via the bot (for inline bots).
522 * On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned.
523 * @param chatId Required if inlineMessageId is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
524 * @param messageId Required if inlineMessageId is not specified. Identifier of the sent message
525 * @param inlineMessageId Required if chatId and messageId are not specified. Identifier of the inline message
526 * @param text New text of the message
527 */
528 editMessageText(chatId, messageId, inlineMessageId, text, extra) {
529 return this.callApi('editMessageText', {
530 text,
531 chat_id: chatId,
532 message_id: messageId,
533 inline_message_id: inlineMessageId,
534 ...extra,
535 });
536 }
537 /**
538 * Edit captions of messages sent by the bot or via the bot (for inline bots).
539 * On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned.
540 * @param chatId Required if inlineMessageId is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
541 * @param messageId Required if inlineMessageId is not specified. Identifier of the sent message
542 * @param inlineMessageId Required if chatId and messageId are not specified. Identifier of the inline message
543 * @param caption New caption of the message
544 * @param markup A JSON-serialized object for an inline keyboard.
545 */
546 editMessageCaption(chatId, messageId, inlineMessageId, caption, extra) {
547 return this.callApi('editMessageCaption', {
548 caption,
549 chat_id: chatId,
550 message_id: messageId,
551 inline_message_id: inlineMessageId,
552 ...extra,
553 });
554 }
555 /**
556 * Edit animation, audio, document, photo, or video messages.
557 * If a message is a part of a message album, then it can be edited only to a photo or a video.
558 * Otherwise, message type can be changed arbitrarily.
559 * When inline message is edited, new file can't be uploaded.
560 * Use previously uploaded file via its file_id or specify a URL.
561 * @param chatId Required if inlineMessageId is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
562 * @param messageId Required if inlineMessageId is not specified. Identifier of the sent message
563 * @param inlineMessageId Required if chatId and messageId are not specified. Identifier of the inline message
564 * @param media New media of message
565 * @param markup Markup of inline keyboard
566 */
567 editMessageMedia(chatId, messageId, inlineMessageId, media, extra) {
568 return this.callApi('editMessageMedia', {
569 chat_id: chatId,
570 message_id: messageId,
571 inline_message_id: inlineMessageId,
572 media,
573 ...extra,
574 });
575 }
576 /**
577 * Edit only the reply markup of messages sent by the bot or via the bot (for inline bots).
578 * @param chatId Required if inlineMessageId is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
579 * @param messageId Required if inlineMessageId is not specified. Identifier of the sent message
580 * @param inlineMessageId Required if chatId and messageId are not specified. Identifier of the inline message
581 * @param markup A JSON-serialized object for an inline keyboard.
582 * @returns If edited message is sent by the bot, the edited Message is returned, otherwise True is returned.
583 */
584 editMessageReplyMarkup(chatId, messageId, inlineMessageId, markup) {
585 return this.callApi('editMessageReplyMarkup', {
586 chat_id: chatId,
587 message_id: messageId,
588 inline_message_id: inlineMessageId,
589 reply_markup: markup,
590 });
591 }
592 editMessageLiveLocation(chatId, messageId, inlineMessageId, latitude, longitude, extra) {
593 return this.callApi('editMessageLiveLocation', {
594 latitude,
595 longitude,
596 chat_id: chatId,
597 message_id: messageId,
598 inline_message_id: inlineMessageId,
599 ...extra,
600 });
601 }
602 stopMessageLiveLocation(chatId, messageId, inlineMessageId, markup) {
603 return this.callApi('stopMessageLiveLocation', {
604 chat_id: chatId,
605 message_id: messageId,
606 inline_message_id: inlineMessageId,
607 reply_markup: markup,
608 });
609 }
610 /**
611 * Delete a message, including service messages, with the following limitations:
612 * - A message can only be deleted if it was sent less than 48 hours ago.
613 * - Bots can delete outgoing messages in groups and supergroups.
614 * - Bots granted can_post_messages permissions can delete outgoing messages in channels.
615 * - If the bot is an administrator of a group, it can delete any message there.
616 * - If the bot has can_delete_messages permission in a supergroup or a channel, it can delete any message there.
617 * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
618 */
619 deleteMessage(chatId, messageId) {
620 return this.callApi('deleteMessage', {
621 chat_id: chatId,
622 message_id: messageId,
623 });
624 }
625 setChatStickerSet(chatId, setName) {
626 return this.callApi('setChatStickerSet', {
627 chat_id: chatId,
628 sticker_set_name: setName,
629 });
630 }
631 deleteChatStickerSet(chatId) {
632 return this.callApi('deleteChatStickerSet', { chat_id: chatId });
633 }
634 getStickerSet(name) {
635 return this.callApi('getStickerSet', { name });
636 }
637 /**
638 * Upload a .png file with a sticker for later use in createNewStickerSet and addStickerToSet methods (can be used multiple times)
639 * https://core.telegram.org/bots/api#sending-files
640 * @param ownerId User identifier of sticker file owner
641 * @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.
642 */
643 uploadStickerFile(ownerId, stickerFile) {
644 return this.callApi('uploadStickerFile', {
645 user_id: ownerId,
646 png_sticker: stickerFile,
647 });
648 }
649 /**
650 * Create new sticker set owned by a user. The bot will be able to edit the created sticker set
651 * @param ownerId User identifier of created sticker set owner
652 * @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.
653 * @param title Sticker set title, 1-64 characters
654 */
655 createNewStickerSet(ownerId, name, title, stickerData) {
656 return this.callApi('createNewStickerSet', {
657 name,
658 title,
659 user_id: ownerId,
660 ...stickerData,
661 });
662 }
663 /**
664 * Add a new sticker to a set created by the bot
665 * @param ownerId User identifier of sticker set owner
666 * @param name Sticker set name
667 */
668 addStickerToSet(ownerId, name, stickerData) {
669 return this.callApi('addStickerToSet', {
670 name,
671 user_id: ownerId,
672 ...stickerData,
673 });
674 }
675 /**
676 * Move a sticker in a set created by the bot to a specific position
677 * @param sticker File identifier of the sticker
678 * @param position New sticker position in the set, zero-based
679 */
680 setStickerPositionInSet(sticker, position) {
681 return this.callApi('setStickerPositionInSet', {
682 sticker,
683 position,
684 });
685 }
686 setStickerSetThumb(name, userId, thumb) {
687 return this.callApi('setStickerSetThumb', { name, user_id: userId, thumb });
688 }
689 /**
690 * Delete a sticker from a set created by the bot.
691 * @param sticker File identifier of the sticker
692 */
693 deleteStickerFromSet(sticker) {
694 return this.callApi('deleteStickerFromSet', { sticker });
695 }
696 /**
697 * Get the current list of the bot's commands.
698 */
699 getMyCommands(extra = {}) {
700 return this.callApi('getMyCommands', extra);
701 }
702 /**
703 * Change the list of the bot's commands.
704 * @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.
705 */
706 setMyCommands(commands, extra) {
707 return this.callApi('setMyCommands', { commands, ...extra });
708 }
709 deleteMyCommands(extra = {}) {
710 return this.callApi('deleteMyCommands', extra);
711 }
712 setPassportDataErrors(userId, errors) {
713 return this.callApi('setPassportDataErrors', {
714 user_id: userId,
715 errors: errors,
716 });
717 }
718 /**
719 * Send copy of existing message.
720 * @deprecated use `copyMessage` instead
721 * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
722 * @param message Received message object
723 */
724 sendCopy(chatId, message, extra) {
725 return this.copyMessage(chatId, message.chat.id, message.message_id, extra);
726 }
727 /**
728 * Send copy of existing message
729 * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
730 * @param fromChatId Unique identifier for the chat where the original message was sent (or channel username in the format @channelusername)
731 * @param messageId Message identifier in the chat specified in from_chat_id
732 */
733 copyMessage(chatId, fromChatId, messageId, extra) {
734 return this.callApi('copyMessage', {
735 chat_id: chatId,
736 from_chat_id: fromChatId,
737 message_id: messageId,
738 ...extra,
739 });
740 }
741 /**
742 * Log out from the cloud Bot API server before launching the bot locally
743 */
744 logOut() {
745 return this.callApi('logOut', {});
746 }
747 /**
748 * Close the bot instance before moving it from one local server to another
749 */
750 close() {
751 return this.callApi('close', {});
752 }
753}
754exports.Telegram = Telegram;
755exports.default = Telegram;