abeya-tg-api 0.0.1-security → 1.0.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.

Potentially problematic release.


This version of abeya-tg-api might be problematic. Click here for more details.

@@ -0,0 +1,4741 @@
1
+ 'use strict';
2
+
3
+ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
4
+
5
+ var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
6
+
7
+ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
8
+
9
+ var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
10
+
11
+ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
12
+
13
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
14
+
15
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
16
+
17
+ function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
18
+
19
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
20
+
21
+ // shims
22
+ require('array.prototype.findindex').shim(); // for Node.js v0.x
23
+
24
+ var errors = require('./errors');
25
+ var TelegramBotWebHook = require('./telegramWebHook');
26
+ var TelegramBotPolling = require('./telegramPolling');
27
+ var debug = require('debug')('node-telegram-bot-api');
28
+ var EventEmitter = require('eventemitter3');
29
+ var fileType = require('file-type');
30
+ var request = require('@cypress/request-promise');
31
+ var streamedRequest = require('@cypress/request');
32
+ var qs = require('querystring');
33
+ var stream = require('stream');
34
+ var mime = require('mime');
35
+ var path = require('path');
36
+ var URL = require('url');
37
+ var fs = require('fs');
38
+ var pump = require('pump');
39
+ var deprecate = require('./utils').deprecate;
40
+
41
+ var _messageTypes = ['text', 'animation', 'audio', 'channel_chat_created', 'contact', 'delete_chat_photo', 'dice', 'document', 'game', 'group_chat_created', 'invoice', 'left_chat_member', 'location', 'migrate_from_chat_id', 'migrate_to_chat_id', 'new_chat_members', 'new_chat_photo', 'new_chat_title', 'passport_data', 'photo', 'pinned_message', 'poll', 'sticker', 'successful_payment', 'supergroup_chat_created', 'video', 'video_note', 'voice', 'video_chat_started', 'video_chat_ended', 'video_chat_participants_invited', 'video_chat_scheduled', 'message_auto_delete_timer_changed', 'chat_invite_link', 'chat_member_updated', 'web_app_data', 'message_reaction'];
42
+
43
+ var _deprecatedMessageTypes = ['new_chat_participant', 'left_chat_participant'];
44
+
45
+ /**
46
+ * JSON-serialize data. If the provided data is already a String,
47
+ * return it as is.
48
+ * @private
49
+ * @param {*} data
50
+ * @return {String}
51
+ */
52
+ function stringify(data) {
53
+ if (typeof data === 'string') {
54
+ return data;
55
+ }
56
+ return JSON.stringify(data);
57
+ }
58
+
59
+ var TelegramBot = function (_EventEmitter) {
60
+ _inherits(TelegramBot, _EventEmitter);
61
+
62
+ _createClass(TelegramBot, [{
63
+ key: 'on',
64
+
65
+
66
+ /**
67
+ * Add listener for the specified [event](https://github.com/yagop/node-telegram-bot-api/blob/master/doc/usage.md#events).
68
+ * This is the usual `emitter.on()` method.
69
+ * @param {String} event
70
+ * @param {Function} listener
71
+ * @see {@link https://github.com/yagop/node-telegram-bot-api/blob/master/doc/usage.md#events|Available events}
72
+ * @see https://nodejs.org/api/events.html#events_emitter_on_eventname_listener
73
+ */
74
+ value: function on(event, listener) {
75
+ if (_deprecatedMessageTypes.indexOf(event) !== -1) {
76
+ var url = 'https://github.com/yagop/node-telegram-bot-api/blob/master/doc/usage.md#events';
77
+ deprecate('Events ' + _deprecatedMessageTypes.join(',') + ' are deprecated. See the updated list of events: ' + url);
78
+ }
79
+ _get(TelegramBot.prototype.__proto__ || Object.getPrototypeOf(TelegramBot.prototype), 'on', this).call(this, event, listener);
80
+ }
81
+
82
+ /**
83
+ * Both request method to obtain messages are implemented. To use standard polling, set `polling: true`
84
+ * on `options`. Notice that [webHook](https://core.telegram.org/bots/api#setwebhook) will need a SSL certificate.
85
+ * Emits `message` when a message arrives.
86
+ *
87
+ * @class TelegramBot
88
+ * @constructor
89
+ * @param {String} token Bot Token
90
+ * @param {Object} [options]
91
+ * @param {Boolean|Object} [options.polling=false] Set true to enable polling or set options.
92
+ * If a WebHook has been set, it will be deleted automatically.
93
+ * @param {String|Number} [options.polling.timeout=10] *Deprecated. Use `options.polling.params` instead*.
94
+ * Timeout in seconds for long polling.
95
+ * @param {Boolean} [options.testEnvironment=false] Set true to work with test enviroment.
96
+ * When working with the test environment, you may use HTTP links without TLS to test your Web App.
97
+ * @param {String|Number} [options.polling.interval=300] Interval between requests in miliseconds
98
+ * @param {Boolean} [options.polling.autoStart=true] Start polling immediately
99
+ * @param {Object} [options.polling.params] Parameters to be used in polling API requests.
100
+ * See https://core.telegram.org/bots/api#getupdates for more information.
101
+ * @param {Number} [options.polling.params.timeout=10] Timeout in seconds for long polling.
102
+ * @param {Boolean|Object} [options.webHook=false] Set true to enable WebHook or set options
103
+ * @param {String} [options.webHook.host="0.0.0.0"] Host to bind to
104
+ * @param {Number} [options.webHook.port=8443] Port to bind to
105
+ * @param {String} [options.webHook.key] Path to file with PEM private key for webHook server.
106
+ * The file is read **synchronously**!
107
+ * @param {String} [options.webHook.cert] Path to file with PEM certificate (public) for webHook server.
108
+ * The file is read **synchronously**!
109
+ * @param {String} [options.webHook.pfx] Path to file with PFX private key and certificate chain for webHook server.
110
+ * The file is read **synchronously**!
111
+ * @param {Boolean} [options.webHook.autoOpen=true] Open webHook immediately
112
+ * @param {Object} [options.webHook.https] Options to be passed to `https.createServer()`.
113
+ * Note that `options.webHook.key`, `options.webHook.cert` and `options.webHook.pfx`, if provided, will be
114
+ * used to override `key`, `cert` and `pfx` in this object, respectively.
115
+ * See https://nodejs.org/api/https.html#https_https_createserver_options_requestlistener for more information.
116
+ * @param {String} [options.webHook.healthEndpoint="/healthz"] An endpoint for health checks that always responds with 200 OK
117
+ * @param {Boolean} [options.onlyFirstMatch=false] Set to true to stop after first match. Otherwise, all regexps are executed
118
+ * @param {Object} [options.request] Options which will be added for all requests to telegram api.
119
+ * See https://github.com/request/request#requestoptions-callback for more information.
120
+ * @param {String} [options.baseApiUrl="https://api.telegram.org"] API Base URl; useful for proxying and testing
121
+ * @param {Boolean} [options.filepath=true] Allow passing file-paths as arguments when sending files,
122
+ * such as photos using `TelegramBot#sendPhoto()`. See [usage information][usage-sending-files-performance]
123
+ * for more information on this option and its consequences.
124
+ * @param {Boolean} [options.badRejection=false] Set to `true`
125
+ * **if and only if** the Node.js version you're using terminates the
126
+ * process on unhandled rejections. This option is only for
127
+ * *forward-compatibility purposes*.
128
+ * @see https://core.telegram.org/bots/api
129
+ */
130
+
131
+ }], [{
132
+ key: 'errors',
133
+
134
+ /**
135
+ * The different errors the library uses.
136
+ * @type {Object}
137
+ */
138
+ get: function get() {
139
+ return errors;
140
+ }
141
+
142
+ /**
143
+ * The types of message updates the library handles.
144
+ * @type {String[]}
145
+ */
146
+
147
+ }, {
148
+ key: 'messageTypes',
149
+ get: function get() {
150
+ return _messageTypes;
151
+ }
152
+ }]);
153
+
154
+ function TelegramBot(token) {
155
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
156
+
157
+ _classCallCheck(this, TelegramBot);
158
+
159
+ var _this = _possibleConstructorReturn(this, (TelegramBot.__proto__ || Object.getPrototypeOf(TelegramBot)).call(this));
160
+
161
+ _this.token = token;
162
+ _this.options = options;
163
+ _this.options.polling = typeof options.polling === 'undefined' ? false : options.polling;
164
+ _this.options.webHook = typeof options.webHook === 'undefined' ? false : options.webHook;
165
+ _this.options.baseApiUrl = options.baseApiUrl || 'https://api.telegram.org';
166
+ _this.options.filepath = typeof options.filepath === 'undefined' ? true : options.filepath;
167
+ _this.options.badRejection = typeof options.badRejection === 'undefined' ? false : options.badRejection;
168
+ _this._textRegexpCallbacks = [];
169
+ _this._replyListenerId = 0;
170
+ _this._replyListeners = [];
171
+ _this._polling = null;
172
+ _this._webHook = null;
173
+
174
+ if (options.polling) {
175
+ var autoStart = options.polling.autoStart;
176
+ if (typeof autoStart === 'undefined' || autoStart === true) {
177
+ _this.startPolling();
178
+ }
179
+ }
180
+
181
+ if (options.webHook) {
182
+ var autoOpen = options.webHook.autoOpen;
183
+ if (typeof autoOpen === 'undefined' || autoOpen === true) {
184
+ _this.openWebHook();
185
+ }
186
+ }
187
+ return _this;
188
+ }
189
+
190
+ /**
191
+ * Generates url with bot token and provided path/method you want to be got/executed by bot
192
+ * @param {String} path
193
+ * @return {String} url
194
+ * @private
195
+ * @see https://core.telegram.org/bots/api#making-requests
196
+ */
197
+
198
+
199
+ _createClass(TelegramBot, [{
200
+ key: '_buildURL',
201
+ value: function _buildURL(_path) {
202
+ return this.options.baseApiUrl + '/bot' + this.token + (this.options.testEnvironment ? '/test' : '') + '/' + _path;
203
+ }
204
+
205
+ /**
206
+ * Fix 'reply_markup' parameter by making it JSON-serialized, as
207
+ * required by the Telegram Bot API
208
+ * @param {Object} obj Object; either 'form' or 'qs'
209
+ * @private
210
+ * @see https://core.telegram.org/bots/api#sendmessage
211
+ */
212
+
213
+ }, {
214
+ key: '_fixReplyMarkup',
215
+ value: function _fixReplyMarkup(obj) {
216
+ var replyMarkup = obj.reply_markup;
217
+ if (replyMarkup && typeof replyMarkup !== 'string') {
218
+ obj.reply_markup = stringify(replyMarkup);
219
+ }
220
+ }
221
+
222
+ /**
223
+ * Fix 'entities' or 'caption_entities' or 'explanation_entities' parameter by making it JSON-serialized, as
224
+ * required by the Telegram Bot API
225
+ * @param {Object} obj Object;
226
+ * @private
227
+ * @see https://core.telegram.org/bots/api#sendmessage
228
+ * @see https://core.telegram.org/bots/api#copymessage
229
+ * @see https://core.telegram.org/bots/api#sendpoll
230
+ */
231
+
232
+ }, {
233
+ key: '_fixEntitiesField',
234
+ value: function _fixEntitiesField(obj) {
235
+ var entities = obj.entities;
236
+ var captionEntities = obj.caption_entities;
237
+ var explanationEntities = obj.explanation_entities;
238
+ if (entities && typeof entities !== 'string') {
239
+ obj.entities = stringify(entities);
240
+ }
241
+
242
+ if (captionEntities && typeof captionEntities !== 'string') {
243
+ obj.caption_entities = stringify(captionEntities);
244
+ }
245
+
246
+ if (explanationEntities && typeof explanationEntities !== 'string') {
247
+ obj.explanation_entities = stringify(explanationEntities);
248
+ }
249
+ }
250
+ }, {
251
+ key: '_fixAddFileThumbnail',
252
+ value: function _fixAddFileThumbnail(options, opts) {
253
+ if (options.thumb) {
254
+ if (opts.formData === null) {
255
+ opts.formData = {};
256
+ }
257
+
258
+ var attachName = 'photo';
259
+
260
+ var _formatSendData2 = this._formatSendData(attachName, options.thumb.replace('attach://', '')),
261
+ _formatSendData3 = _slicedToArray(_formatSendData2, 1),
262
+ formData = _formatSendData3[0];
263
+
264
+ if (formData) {
265
+ opts.formData[attachName] = formData[attachName];
266
+ opts.qs.thumbnail = 'attach://' + attachName;
267
+ }
268
+ }
269
+ }
270
+
271
+ /**
272
+ * Fix 'reply_parameters' parameter by making it JSON-serialized, as
273
+ * required by the Telegram Bot API
274
+ * @param {Object} obj Object; either 'form' or 'qs'
275
+ * @private
276
+ * @see https://core.telegram.org/bots/api#sendmessage
277
+ */
278
+
279
+ }, {
280
+ key: '_fixReplyParameters',
281
+ value: function _fixReplyParameters(obj) {
282
+ if (obj.hasOwnProperty('reply_parameters') && typeof obj.reply_parameters !== 'string') {
283
+ obj.reply_parameters = stringify(obj.reply_parameters);
284
+ }
285
+ }
286
+
287
+ /**
288
+ * Make request against the API
289
+ * @param {String} _path API endpoint
290
+ * @param {Object} [options]
291
+ * @private
292
+ * @return {Promise}
293
+ */
294
+
295
+ }, {
296
+ key: '_request',
297
+ value: function _request(_path) {
298
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
299
+
300
+ if (!this.token) {
301
+ return Promise.reject(new errors.FatalError('Telegram Bot Token not provided!'));
302
+ }
303
+
304
+ if (this.options.request) {
305
+ Object.assign(options, this.options.request);
306
+ }
307
+
308
+ if (options.form) {
309
+ this._fixReplyMarkup(options.form);
310
+ this._fixEntitiesField(options.form);
311
+ this._fixReplyParameters(options.form);
312
+ }
313
+ if (options.qs) {
314
+ this._fixReplyMarkup(options.qs);
315
+ this._fixReplyParameters(options.qs);
316
+ }
317
+
318
+ options.method = 'POST';
319
+ options.url = this._buildURL(_path);
320
+ options.simple = false;
321
+ options.resolveWithFullResponse = true;
322
+ options.forever = true;
323
+ debug('HTTP request: %j', options);
324
+ return request(options).then(function (resp) {
325
+ var data = void 0;
326
+ try {
327
+ data = resp.body = JSON.parse(resp.body);
328
+ } catch (err) {
329
+ throw new errors.ParseError('Error parsing response: ' + resp.body, resp);
330
+ }
331
+
332
+ if (data.ok) {
333
+ return data.result;
334
+ }
335
+
336
+ throw new errors.TelegramError(data.error_code + ' ' + data.description, resp);
337
+ }).catch(function (error) {
338
+ // TODO: why can't we do `error instanceof errors.BaseError`?
339
+ if (error.response) throw error;
340
+ throw new errors.FatalError(error);
341
+ });
342
+ }
343
+
344
+ /**
345
+ * Format data to be uploaded; handles file paths, streams and buffers
346
+ * @param {String} type
347
+ * @param {String|stream.Stream|Buffer} data
348
+ * @param {Object} fileOptions File options
349
+ * @param {String} [fileOptions.filename] File name
350
+ * @param {String} [fileOptions.contentType] Content type (i.e. MIME)
351
+ * @return {Array} formatted
352
+ * @return {Object} formatted[0] formData
353
+ * @return {String} formatted[1] fileId
354
+ * @throws Error if Buffer file type is not supported.
355
+ * @see https://npmjs.com/package/file-type
356
+ * @private
357
+ */
358
+
359
+ }, {
360
+ key: '_formatSendData',
361
+ value: function _formatSendData(type, data) {
362
+ var fileOptions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
363
+
364
+ var deprecationMessage = 'See https://github.com/yagop/node-telegram-bot-api/blob/master/doc/usage.md#sending-files' + ' for more information on how sending files has been improved and' + ' on how to disable this deprecation message altogether.';
365
+ var filedata = data;
366
+ var filename = fileOptions.filename;
367
+ var contentType = fileOptions.contentType;
368
+
369
+ if (data instanceof stream.Stream) {
370
+ if (!filename && data.path) {
371
+ // Will be 'null' if could not be parsed.
372
+ // For example, 'data.path' === '/?id=123' from 'request("https://example.com/?id=123")'
373
+ var url = URL.parse(path.basename(data.path.toString()));
374
+ if (url.pathname) {
375
+ filename = qs.unescape(url.pathname);
376
+ }
377
+ }
378
+ } else if (Buffer.isBuffer(data)) {
379
+ if (!filename && !process.env.NTBA_FIX_350) {
380
+ deprecate('Buffers will have their filenames default to "filename" instead of "data". ' + deprecationMessage);
381
+ filename = 'data';
382
+ }
383
+ if (!contentType) {
384
+ var filetype = fileType(data);
385
+ if (filetype) {
386
+ contentType = filetype.mime;
387
+ var ext = filetype.ext;
388
+ if (ext && !process.env.NTBA_FIX_350) {
389
+ filename = filename + '.' + ext;
390
+ }
391
+ } else if (!process.env.NTBA_FIX_350) {
392
+ deprecate('An error will no longer be thrown if file-type of buffer could not be detected. ' + deprecationMessage);
393
+ throw new errors.FatalError('Unsupported Buffer file-type');
394
+ }
395
+ }
396
+ } else if (data) {
397
+ if (this.options.filepath && fs.existsSync(data)) {
398
+ filedata = fs.createReadStream(data);
399
+ if (!filename) {
400
+ filename = path.basename(data);
401
+ }
402
+ } else {
403
+ return [null, data];
404
+ }
405
+ } else {
406
+ return [null, data];
407
+ }
408
+
409
+ filename = filename || 'filename';
410
+ contentType = contentType || mime.lookup(filename);
411
+ if (process.env.NTBA_FIX_350) {
412
+ contentType = contentType || 'application/octet-stream';
413
+ } else {
414
+ deprecate('In the future, content-type of files you send will default to "application/octet-stream". ' + deprecationMessage);
415
+ }
416
+
417
+ // TODO: Add missing file extension.
418
+
419
+ return [_defineProperty({}, type, {
420
+ value: filedata,
421
+ options: {
422
+ filename: filename,
423
+ contentType: contentType
424
+ }
425
+ }), null];
426
+ }
427
+
428
+ /**
429
+ * Format multiple files to be uploaded; handles file paths, streams, and buffers
430
+ * @param {String} type
431
+ * @param {Array} files Array of file data objects
432
+ * @param {Object} fileOptions File options
433
+ * @param {String} [fileOptions.filename] File name
434
+ * @param {String} [fileOptions.contentType] Content type (i.e. MIME)
435
+ * @return {Object} formatted
436
+ * @return {Object} formatted.formData Form data object with all files
437
+ * @return {Array} formatted.fileIds Array of fileIds for non-file data
438
+ * @throws Error if Buffer file type is not supported.
439
+ * @see https://npmjs.com/package/file-type
440
+ * @private
441
+ */
442
+
443
+ }, {
444
+ key: '_formatSendMultipleData',
445
+ value: function _formatSendMultipleData(type, files) {
446
+ var fileOptions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
447
+
448
+ var formData = {};
449
+ var fileIds = {};
450
+
451
+ files.forEach(function (file, index) {
452
+ var filedata = file.media || file.data || file[type];
453
+ var filename = file.filename || fileOptions.filename;
454
+ var contentType = file.contentType || fileOptions.contentType;
455
+
456
+ if (filedata instanceof stream.Stream) {
457
+ if (!filename && filedata.path) {
458
+ var url = URL.parse(path.basename(filedata.path.toString()), true);
459
+ if (url.pathname) {
460
+ filename = qs.unescape(url.pathname);
461
+ }
462
+ }
463
+ } else if (Buffer.isBuffer(filedata)) {
464
+ filename = 'filename_' + index;
465
+
466
+ if (!contentType) {
467
+ var filetype = fileType(filedata);
468
+
469
+ if (filetype) {
470
+ contentType = filetype.mime;
471
+ var ext = filetype.ext;
472
+
473
+ if (ext) {
474
+ filename = filename + '.' + ext;
475
+ }
476
+ } else {
477
+ throw new errors.FatalError('Unsupported Buffer file-type');
478
+ }
479
+ }
480
+ } else if (fs.existsSync(filedata)) {
481
+ filedata = fs.createReadStream(filedata);
482
+
483
+ if (!filename) {
484
+ filename = path.basename(filedata.path);
485
+ }
486
+ } else {
487
+ fileIds[index] = filedata;
488
+ return;
489
+ }
490
+
491
+ filename = filename || 'filename_' + index;
492
+ contentType = contentType || 'application/octet-stream';
493
+
494
+ formData[type + '_' + index] = {
495
+ value: filedata,
496
+ options: {
497
+ filename: filename,
498
+ contentType: contentType
499
+ }
500
+ };
501
+ });
502
+
503
+ return { formData: formData, fileIds: fileIds };
504
+ }
505
+ /**
506
+ * Start polling.
507
+ * Rejects returned promise if a WebHook is being used by this instance.
508
+ * @param {Object} [options]
509
+ * @param {Boolean} [options.restart=true] Consecutive calls to this method causes polling to be restarted
510
+ * @return {Promise}
511
+ */
512
+
513
+ }, {
514
+ key: 'startPolling',
515
+ value: function startPolling() {
516
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
517
+
518
+ if (this.hasOpenWebHook()) {
519
+ return Promise.reject(new errors.FatalError('Polling and WebHook are mutually exclusive'));
520
+ }
521
+ options.restart = typeof options.restart === 'undefined' ? true : options.restart;
522
+ if (!this._polling) {
523
+ this._polling = new TelegramBotPolling(this);
524
+ }
525
+ return this._polling.start(options);
526
+ }
527
+
528
+ /**
529
+ * Alias of `TelegramBot#startPolling()`. This is **deprecated**.
530
+ * @param {Object} [options]
531
+ * @return {Promise}
532
+ * @deprecated
533
+ */
534
+
535
+ }, {
536
+ key: 'initPolling',
537
+ value: function initPolling() {
538
+ deprecate('TelegramBot#initPolling() is deprecated. Use TelegramBot#startPolling() instead.');
539
+ return this.startPolling();
540
+ }
541
+
542
+ /**
543
+ * Stops polling after the last polling request resolves.
544
+ * Multiple invocations do nothing if polling is already stopped.
545
+ * Returning the promise of the last polling request is **deprecated**.
546
+ * @param {Object} [options] Options
547
+ * @param {Boolean} [options.cancel] Cancel current request
548
+ * @param {String} [options.reason] Reason for stopping polling
549
+ * @return {Promise}
550
+ */
551
+
552
+ }, {
553
+ key: 'stopPolling',
554
+ value: function stopPolling(options) {
555
+ if (!this._polling) {
556
+ return Promise.resolve();
557
+ }
558
+ return this._polling.stop(options);
559
+ }
560
+
561
+ /**
562
+ * Get link for file.
563
+ * Use this method to get link for file for subsequent use.
564
+ * Attention: link will be valid for 1 hour.
565
+ *
566
+ * This method is a sugar extension of the (getFile)[#getfilefileid] method,
567
+ * which returns just path to file on remote server (you will have to manually build full uri after that).
568
+ *
569
+ * @param {String} fileId File identifier to get info about
570
+ * @param {Object} [options] Additional Telegram query options
571
+ * @return {Promise} Promise which will have *fileURI* in resolve callback
572
+ * @see https://core.telegram.org/bots/api#getfile
573
+ */
574
+
575
+ }, {
576
+ key: 'getFileLink',
577
+ value: function getFileLink(fileId) {
578
+ var _this2 = this;
579
+
580
+ var form = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
581
+
582
+ return this.getFile(fileId, form).then(function (resp) {
583
+ return _this2.options.baseApiUrl + '/file/bot' + _this2.token + '/' + resp.file_path;
584
+ });
585
+ }
586
+
587
+ /**
588
+ * Return a readable stream for file.
589
+ *
590
+ * `fileStream.path` is the specified file ID i.e. `fileId`.
591
+ * `fileStream` emits event `info` passing a single argument i.e.
592
+ * `info` with the interface `{ uri }` where `uri` is the URI of the
593
+ * file on Telegram servers.
594
+ *
595
+ * This method is a sugar extension of the [getFileLink](#TelegramBot+getFileLink) method,
596
+ * which returns the full URI to the file on remote server.
597
+ *
598
+ * @param {String} fileId File identifier to get info about
599
+ * @param {Object} [options] Additional Telegram query options
600
+ * @return {stream.Readable} fileStream
601
+ */
602
+
603
+ }, {
604
+ key: 'getFileStream',
605
+ value: function getFileStream(fileId) {
606
+ var _this3 = this;
607
+
608
+ var form = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
609
+
610
+ var fileStream = new stream.PassThrough();
611
+ fileStream.path = fileId;
612
+ this.getFileLink(fileId, form).then(function (fileURI) {
613
+ fileStream.emit('info', {
614
+ uri: fileURI
615
+ });
616
+ pump(streamedRequest(Object.assign({ uri: fileURI }, _this3.options.request)), fileStream);
617
+ }).catch(function (error) {
618
+ fileStream.emit('error', error);
619
+ });
620
+ return fileStream;
621
+ }
622
+
623
+ /**
624
+ * Downloads file in the specified folder.
625
+ *
626
+ * This method is a sugar extension of the [getFileStream](#TelegramBot+getFileStream) method,
627
+ * which returns a readable file stream.
628
+ *
629
+ * @param {String} fileId File identifier to get info about
630
+ * @param {String} downloadDir Absolute path to the folder in which file will be saved
631
+ * @param {Object} [options] Additional Telegram query options
632
+ * @return {Promise} Promise, which will have *filePath* of downloaded file in resolve callback
633
+ */
634
+
635
+ }, {
636
+ key: 'downloadFile',
637
+ value: function downloadFile(fileId, downloadDir) {
638
+ var form = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
639
+
640
+ var resolve = void 0;
641
+ var reject = void 0;
642
+ var promise = new Promise(function (a, b) {
643
+ resolve = a;
644
+ reject = b;
645
+ });
646
+ var fileStream = this.getFileStream(fileId, form);
647
+ fileStream.on('info', function (info) {
648
+ var fileName = info.uri.slice(info.uri.lastIndexOf('/') + 1);
649
+ // TODO: Ensure fileName doesn't contains slashes
650
+ var filePath = path.join(downloadDir, fileName);
651
+ pump(fileStream, fs.createWriteStream(filePath), function (error) {
652
+ if (error) {
653
+ return reject(error);
654
+ }
655
+ return resolve(filePath);
656
+ });
657
+ });
658
+ fileStream.on('error', function (err) {
659
+ reject(err);
660
+ });
661
+ return promise;
662
+ }
663
+
664
+ /**
665
+ * Register a RegExp to test against an incomming text message.
666
+ * @param {RegExp} regexpRexecuted with `exec`.
667
+ * @param {Function} callback Callback will be called with 2 parameters,
668
+ * the `msg` and the result of executing `regexp.exec` on message text.
669
+ */
670
+
671
+ }, {
672
+ key: 'onText',
673
+ value: function onText(regexp, callback) {
674
+ this._textRegexpCallbacks.push({ regexp: regexp, callback: callback });
675
+ }
676
+
677
+ /**
678
+ * Remove a listener registered with `onText()`.
679
+ * @param {RegExp} regexp RegExp used previously in `onText()`
680
+ * @return {Object} deletedListener The removed reply listener if
681
+ * found. This object has `regexp` and `callback`
682
+ * properties. If not found, returns `null`.
683
+ */
684
+
685
+ }, {
686
+ key: 'removeTextListener',
687
+ value: function removeTextListener(regexp) {
688
+ var index = this._textRegexpCallbacks.findIndex(function (textListener) {
689
+ return String(textListener.regexp) === String(regexp);
690
+ });
691
+ if (index === -1) {
692
+ return null;
693
+ }
694
+ return this._textRegexpCallbacks.splice(index, 1)[0];
695
+ }
696
+
697
+ /**
698
+ * Remove all listeners registered with `onText()`.
699
+ */
700
+
701
+ }, {
702
+ key: 'clearTextListeners',
703
+ value: function clearTextListeners() {
704
+ this._textRegexpCallbacks = [];
705
+ }
706
+
707
+ /**
708
+ * Register a reply to wait for a message response.
709
+ *
710
+ * @param {Number|String} chatId The chat id where the message cames from.
711
+ * @param {Number|String} messageId The message id to be replied.
712
+ * @param {Function} callback Callback will be called with the reply
713
+ * message.
714
+ * @return {Number} id The ID of the inserted reply listener.
715
+ */
716
+
717
+ }, {
718
+ key: 'onReplyToMessage',
719
+ value: function onReplyToMessage(chatId, messageId, callback) {
720
+ var id = ++this._replyListenerId;
721
+ this._replyListeners.push({
722
+ id: id,
723
+ chatId: chatId,
724
+ messageId: messageId,
725
+ callback: callback
726
+ });
727
+ return id;
728
+ }
729
+
730
+ /**
731
+ * Removes a reply that has been prev. registered for a message response.
732
+ * @param {Number} replyListenerId The ID of the reply listener.
733
+ * @return {Object} deletedListener The removed reply listener if
734
+ * found. This object has `id`, `chatId`, `messageId` and `callback`
735
+ * properties. If not found, returns `null`.
736
+ */
737
+
738
+ }, {
739
+ key: 'removeReplyListener',
740
+ value: function removeReplyListener(replyListenerId) {
741
+ var index = this._replyListeners.findIndex(function (replyListener) {
742
+ return replyListener.id === replyListenerId;
743
+ });
744
+ if (index === -1) {
745
+ return null;
746
+ }
747
+ return this._replyListeners.splice(index, 1)[0];
748
+ }
749
+
750
+ /**
751
+ * Removes all replies that have been prev. registered for a message response.
752
+ *
753
+ * @return {Array} deletedListeners An array of removed listeners.
754
+ */
755
+
756
+ }, {
757
+ key: 'clearReplyListeners',
758
+ value: function clearReplyListeners() {
759
+ this._replyListeners = [];
760
+ }
761
+
762
+ /**
763
+ * Return true if polling. Otherwise, false.
764
+ *
765
+ * @return {Boolean}
766
+ */
767
+
768
+ }, {
769
+ key: 'isPolling',
770
+ value: function isPolling() {
771
+ return this._polling ? this._polling.isPolling() : false;
772
+ }
773
+
774
+ /**
775
+ * Open webhook.
776
+ * Multiple invocations do nothing if webhook is already open.
777
+ * Rejects returned promise if Polling is being used by this instance.
778
+ *
779
+ * @return {Promise}
780
+ */
781
+
782
+ }, {
783
+ key: 'openWebHook',
784
+ value: function openWebHook() {
785
+ if (this.isPolling()) {
786
+ return Promise.reject(new errors.FatalError('WebHook and Polling are mutually exclusive'));
787
+ }
788
+ if (!this._webHook) {
789
+ this._webHook = new TelegramBotWebHook(this);
790
+ }
791
+ return this._webHook.open();
792
+ }
793
+
794
+ /**
795
+ * Close webhook after closing all current connections.
796
+ * Multiple invocations do nothing if webhook is already closed.
797
+ *
798
+ * @return {Promise} Promise
799
+ */
800
+
801
+ }, {
802
+ key: 'closeWebHook',
803
+ value: function closeWebHook() {
804
+ if (!this._webHook) {
805
+ return Promise.resolve();
806
+ }
807
+ return this._webHook.close();
808
+ }
809
+
810
+ /**
811
+ * Return true if using webhook and it is open i.e. accepts connections.
812
+ * Otherwise, false.
813
+ *
814
+ * @return {Boolean}
815
+ */
816
+
817
+ }, {
818
+ key: 'hasOpenWebHook',
819
+ value: function hasOpenWebHook() {
820
+ return this._webHook ? this._webHook.isOpen() : false;
821
+ }
822
+
823
+ /**
824
+ * Process an update; emitting the proper events and executing regexp
825
+ * callbacks. This method is useful should you be using a different
826
+ * way to fetch updates, other than those provided by TelegramBot.
827
+ *
828
+ * @param {Object} update
829
+ * @see https://core.telegram.org/bots/api#update
830
+ */
831
+
832
+ }, {
833
+ key: 'processUpdate',
834
+ value: function processUpdate(update) {
835
+ var _this4 = this;
836
+
837
+ debug('Process Update %j', update);
838
+ var message = update.message;
839
+ var editedMessage = update.edited_message;
840
+ var channelPost = update.channel_post;
841
+ var editedChannelPost = update.edited_channel_post;
842
+ var businessConnection = update.business_connection;
843
+ var businesssMessage = update.business_message;
844
+ var editedBusinessMessage = update.edited_business_message;
845
+ var deletedBusinessMessage = update.deleted_business_messages;
846
+ var messageReaction = update.message_reaction;
847
+ var messageReactionCount = update.message_reaction_count;
848
+ var inlineQuery = update.inline_query;
849
+ var chosenInlineResult = update.chosen_inline_result;
850
+ var callbackQuery = update.callback_query;
851
+ var shippingQuery = update.shipping_query;
852
+ var preCheckoutQuery = update.pre_checkout_query;
853
+ var purchasedPaidMedia = update.purchased_paid_media;
854
+ var poll = update.poll;
855
+ var pollAnswer = update.poll_answer;
856
+ var myChatMember = update.my_chat_member;
857
+ var chatMember = update.chat_member;
858
+ var chatJoinRequest = update.chat_join_request;
859
+ var chatBoost = update.chat_boost;
860
+ var removedChatBoost = update.removed_chat_boost;
861
+
862
+ if (message) {
863
+ debug('Process Update message %j', message);
864
+ var metadata = {};
865
+ metadata.type = TelegramBot.messageTypes.find(function (messageType) {
866
+ return message[messageType];
867
+ });
868
+ this.emit('message', message, metadata);
869
+ if (metadata.type) {
870
+ debug('Emitting %s: %j', metadata.type, message);
871
+ this.emit(metadata.type, message, metadata);
872
+ }
873
+ if (message.text) {
874
+ debug('Text message');
875
+ this._textRegexpCallbacks.some(function (reg) {
876
+ debug('Matching %s with %s', message.text, reg.regexp);
877
+
878
+ if (!(reg.regexp instanceof RegExp)) {
879
+ reg.regexp = new RegExp(reg.regexp);
880
+ }
881
+
882
+ var result = reg.regexp.exec(message.text);
883
+ if (!result) {
884
+ return false;
885
+ }
886
+ // reset index so we start at the beginning of the regex each time
887
+ reg.regexp.lastIndex = 0;
888
+ debug('Matches %s', reg.regexp);
889
+ reg.callback(message, result);
890
+ // returning truthy value exits .some
891
+ return _this4.options.onlyFirstMatch;
892
+ });
893
+ }
894
+ if (message.reply_to_message) {
895
+ // Only callbacks waiting for this message
896
+ this._replyListeners.forEach(function (reply) {
897
+ // Message from the same chat
898
+ if (reply.chatId === message.chat.id) {
899
+ // Responding to that message
900
+ if (reply.messageId === message.reply_to_message.message_id) {
901
+ // Resolve the promise
902
+ reply.callback(message);
903
+ }
904
+ }
905
+ });
906
+ }
907
+ } else if (editedMessage) {
908
+ debug('Process Update edited_message %j', editedMessage);
909
+ this.emit('edited_message', editedMessage);
910
+ if (editedMessage.text) {
911
+ this.emit('edited_message_text', editedMessage);
912
+ }
913
+ if (editedMessage.caption) {
914
+ this.emit('edited_message_caption', editedMessage);
915
+ }
916
+ } else if (channelPost) {
917
+ debug('Process Update channel_post %j', channelPost);
918
+ this.emit('channel_post', channelPost);
919
+ } else if (editedChannelPost) {
920
+ debug('Process Update edited_channel_post %j', editedChannelPost);
921
+ this.emit('edited_channel_post', editedChannelPost);
922
+ if (editedChannelPost.text) {
923
+ this.emit('edited_channel_post_text', editedChannelPost);
924
+ }
925
+ if (editedChannelPost.caption) {
926
+ this.emit('edited_channel_post_caption', editedChannelPost);
927
+ }
928
+ } else if (businessConnection) {
929
+ debug('Process Update business_connection %j', businessConnection);
930
+ this.emit('business_connection', businessConnection);
931
+ } else if (businesssMessage) {
932
+ debug('Process Update business_message %j', businesssMessage);
933
+ this.emit('business_message', businesssMessage);
934
+ } else if (editedBusinessMessage) {
935
+ debug('Process Update edited_business_message %j', editedBusinessMessage);
936
+ this.emit('edited_business_message', editedBusinessMessage);
937
+ } else if (deletedBusinessMessage) {
938
+ debug('Process Update deleted_business_messages %j', deletedBusinessMessage);
939
+ this.emit('deleted_business_messages', deletedBusinessMessage);
940
+ } else if (messageReaction) {
941
+ debug('Process Update message_reaction %j', messageReaction);
942
+ this.emit('message_reaction', messageReaction);
943
+ } else if (messageReactionCount) {
944
+ debug('Process Update message_reaction_count %j', messageReactionCount);
945
+ this.emit('message_reaction_count', messageReactionCount);
946
+ } else if (inlineQuery) {
947
+ debug('Process Update inline_query %j', inlineQuery);
948
+ this.emit('inline_query', inlineQuery);
949
+ } else if (chosenInlineResult) {
950
+ debug('Process Update chosen_inline_result %j', chosenInlineResult);
951
+ this.emit('chosen_inline_result', chosenInlineResult);
952
+ } else if (callbackQuery) {
953
+ debug('Process Update callback_query %j', callbackQuery);
954
+ this.emit('callback_query', callbackQuery);
955
+ } else if (shippingQuery) {
956
+ debug('Process Update shipping_query %j', shippingQuery);
957
+ this.emit('shipping_query', shippingQuery);
958
+ } else if (preCheckoutQuery) {
959
+ debug('Process Update pre_checkout_query %j', preCheckoutQuery);
960
+ this.emit('pre_checkout_query', preCheckoutQuery);
961
+ } else if (purchasedPaidMedia) {
962
+ debug('Process Update purchased_paid_media %j', purchasedPaidMedia);
963
+ this.emit('purchased_paid_media', purchasedPaidMedia);
964
+ } else if (poll) {
965
+ debug('Process Update poll %j', poll);
966
+ this.emit('poll', poll);
967
+ } else if (pollAnswer) {
968
+ debug('Process Update poll_answer %j', pollAnswer);
969
+ this.emit('poll_answer', pollAnswer);
970
+ } else if (chatMember) {
971
+ debug('Process Update chat_member %j', chatMember);
972
+ this.emit('chat_member', chatMember);
973
+ } else if (myChatMember) {
974
+ debug('Process Update my_chat_member %j', myChatMember);
975
+ this.emit('my_chat_member', myChatMember);
976
+ } else if (chatJoinRequest) {
977
+ debug('Process Update my_chat_member %j', chatJoinRequest);
978
+ this.emit('chat_join_request', chatJoinRequest);
979
+ } else if (chatBoost) {
980
+ debug('Process Update chat_boost %j', chatBoost);
981
+ this.emit('chat_boost', chatBoost);
982
+ } else if (removedChatBoost) {
983
+ debug('Process Update removed_chat_boost %j', removedChatBoost);
984
+ this.emit('removed_chat_boost', removedChatBoost);
985
+ }
986
+ }
987
+
988
+ /** Start Telegram Bot API methods */
989
+
990
+ /**
991
+ * Use this method to receive incoming updates using long polling.
992
+ * This method has an [older, compatible signature][getUpdates-v0.25.0]
993
+ * that is being deprecated.
994
+ *
995
+ * @param {Object} [options] Additional Telegram query options
996
+ * @return {Promise}
997
+ * @see https://core.telegram.org/bots/api#getupdates
998
+ */
999
+
1000
+ }, {
1001
+ key: 'getUpdates',
1002
+ value: function getUpdates() {
1003
+ var form = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1004
+
1005
+ /* The older method signature was getUpdates(timeout, limit, offset).
1006
+ * We need to ensure backwards-compatibility while maintaining
1007
+ * consistency of the method signatures throughout the library */
1008
+ if ((typeof form === 'undefined' ? 'undefined' : _typeof(form)) !== 'object') {
1009
+ /* eslint-disable no-param-reassign, prefer-rest-params */
1010
+ deprecate('The method signature getUpdates(timeout, limit, offset) has been deprecated since v0.25.0');
1011
+ form = {
1012
+ timeout: arguments[0],
1013
+ limit: arguments[1],
1014
+ offset: arguments[2]
1015
+ };
1016
+ /* eslint-enable no-param-reassign, prefer-rest-params */
1017
+ }
1018
+
1019
+ return this._request('getUpdates', { form: form });
1020
+ }
1021
+
1022
+ /**
1023
+ * Specify an url to receive incoming updates via an outgoing webHook.
1024
+ * This method has an [older, compatible signature][setWebHook-v0.25.0]
1025
+ * that is being deprecated.
1026
+ *
1027
+ * @param {String} url URL where Telegram will make HTTP Post. Leave empty to
1028
+ * delete webHook.
1029
+ * @param {Object} [options] Additional Telegram query options
1030
+ * @param {String|stream.Stream} [options.certificate] PEM certificate key (public).
1031
+ * @param {String} [options.secret_token] Optional secret token to be sent in a header `X-Telegram-Bot-Api-Secret-Token` in every webhook request.
1032
+ * @param {Object} [fileOptions] Optional file related meta-data
1033
+ * @return {Promise}
1034
+ * @see https://core.telegram.org/bots/api#setwebhook
1035
+ * @see https://github.com/yagop/node-telegram-bot-api/blob/master/doc/usage.md#sending-files
1036
+ */
1037
+
1038
+ }, {
1039
+ key: 'setWebHook',
1040
+ value: function setWebHook(url) {
1041
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1042
+ var fileOptions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1043
+
1044
+ /* The older method signature was setWebHook(url, cert).
1045
+ * We need to ensure backwards-compatibility while maintaining
1046
+ * consistency of the method signatures throughout the library */
1047
+ var cert = void 0;
1048
+ // Note: 'options' could be an object, if a stream was provided (in place of 'cert')
1049
+ if ((typeof options === 'undefined' ? 'undefined' : _typeof(options)) !== 'object' || options instanceof stream.Stream) {
1050
+ deprecate('The method signature setWebHook(url, cert) has been deprecated since v0.25.0');
1051
+ cert = options;
1052
+ options = {}; // eslint-disable-line no-param-reassign
1053
+ } else {
1054
+ cert = options.certificate;
1055
+ }
1056
+
1057
+ var opts = {
1058
+ qs: options
1059
+ };
1060
+ opts.qs.url = url;
1061
+
1062
+ if (cert) {
1063
+ try {
1064
+ var sendData = this._formatSendData('certificate', cert, fileOptions);
1065
+ opts.formData = sendData[0];
1066
+ opts.qs.certificate = sendData[1];
1067
+ } catch (ex) {
1068
+ return Promise.reject(ex);
1069
+ }
1070
+ }
1071
+
1072
+ return this._request('setWebHook', opts);
1073
+ }
1074
+
1075
+ /**
1076
+ * Use this method to remove webhook integration if you decide to
1077
+ * switch back to getUpdates. Returns True on success.
1078
+ * @param {Object} [options] Additional Telegram query options
1079
+ * @return {Promise}
1080
+ * @see https://core.telegram.org/bots/api#deletewebhook
1081
+ */
1082
+
1083
+ }, {
1084
+ key: 'deleteWebHook',
1085
+ value: function deleteWebHook() {
1086
+ var form = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1087
+
1088
+ return this._request('deleteWebhook', { form: form });
1089
+ }
1090
+
1091
+ /**
1092
+ * Use this method to get current webhook status.
1093
+ * On success, returns a [WebhookInfo](https://core.telegram.org/bots/api#webhookinfo) object.
1094
+ * If the bot is using getUpdates, will return an object with the
1095
+ * url field empty.
1096
+ * @param {Object} [options] Additional Telegram query options
1097
+ * @return {Promise}
1098
+ * @see https://core.telegram.org/bots/api#getwebhookinfo
1099
+ */
1100
+
1101
+ }, {
1102
+ key: 'getWebHookInfo',
1103
+ value: function getWebHookInfo() {
1104
+ var form = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1105
+
1106
+ return this._request('getWebhookInfo', { form: form });
1107
+ }
1108
+
1109
+ /**
1110
+ * A simple method for testing your bot's authentication token. Requires no parameters.
1111
+ *
1112
+ * @param {Object} [options] Additional Telegram query options
1113
+ * @return {Promise} basic information about the bot in form of a [User](https://core.telegram.org/bots/api#user) object.
1114
+ * @see https://core.telegram.org/bots/api#getme
1115
+ */
1116
+
1117
+ }, {
1118
+ key: 'getMe',
1119
+ value: function getMe() {
1120
+ var form = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1121
+
1122
+ return this._request('getMe', { form: form });
1123
+ }
1124
+
1125
+ /**
1126
+ * This method log out your bot from the cloud Bot API server before launching the bot locally.
1127
+ * You must log out the bot before running it locally, otherwise there is no guarantee that the bot will receive updates.
1128
+ * After a successful call, you will not be able to log in again using the same token for 10 minutes.
1129
+ *
1130
+ * @param {Object} [options] Additional Telegram query options
1131
+ * @return {Promise} True on success
1132
+ * @see https://core.telegram.org/bots/api#logout
1133
+ */
1134
+
1135
+ }, {
1136
+ key: 'logOut',
1137
+ value: function logOut() {
1138
+ var form = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1139
+
1140
+ return this._request('logOut', { form: form });
1141
+ }
1142
+
1143
+ /**
1144
+ * This method close the bot instance before moving it from one local server to another.
1145
+ * This method will return error 429 in the first 10 minutes after the bot is launched.
1146
+ *
1147
+ * @param {Object} [options] Additional Telegram query options
1148
+ * @return {Promise} True on success
1149
+ * @see https://core.telegram.org/bots/api#close
1150
+ */
1151
+
1152
+ }, {
1153
+ key: 'close',
1154
+ value: function close() {
1155
+ var form = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1156
+
1157
+ return this._request('close', { form: form });
1158
+ }
1159
+
1160
+ /**
1161
+ * Send text message.
1162
+ * @param {Number|String} chatId Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
1163
+ * @param {String} text Text of the message to be sent
1164
+ * @param {Object} [options] Additional Telegram query options
1165
+ * @return {Promise} On success, the sent [Message](https://core.telegram.org/bots/api#message) object is returned
1166
+ * @see https://core.telegram.org/bots/api#sendmessage
1167
+ */
1168
+
1169
+ }, {
1170
+ key: 'sendMessage',
1171
+ value: function sendMessage(chatId, text) {
1172
+ var form = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1173
+
1174
+ form.chat_id = chatId;
1175
+ form.text = text;
1176
+ return this._request('sendMessage', { form: form });
1177
+ }
1178
+
1179
+ /**
1180
+ * Forward messages of any kind.
1181
+ * @param {Number|String} chatId Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
1182
+ * or username of the target channel (in the format `@channelusername`)
1183
+ * @param {Number|String} fromChatId Unique identifier for the chat where the
1184
+ * original message was sent (or channel username in the format `@channelusername`)
1185
+ * @param {Number|String} messageId Unique message identifier in the chat specified in fromChatId
1186
+ * @param {Object} [options] Additional Telegram query options
1187
+ * @return {Promise}
1188
+ * @see https://core.telegram.org/bots/api#forwardmessage
1189
+ */
1190
+
1191
+ }, {
1192
+ key: 'forwardMessage',
1193
+ value: function forwardMessage(chatId, fromChatId, messageId) {
1194
+ var form = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
1195
+
1196
+ form.chat_id = chatId;
1197
+ form.from_chat_id = fromChatId;
1198
+ form.message_id = messageId;
1199
+ return this._request('forwardMessage', { form: form });
1200
+ }
1201
+
1202
+ /**
1203
+ * Use this method to forward multiple messages of any kind.
1204
+ * If some of the specified messages can't be found or forwarded, they are skipped.
1205
+ *
1206
+ * @param {Number|String} chatId Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
1207
+ * or username of the target channel (in the format `@channelusername`)
1208
+ * @param {Number|String} fromChatId Unique identifier for the chat where the
1209
+ * original message was sent (or channel username in the format `@channelusername`)
1210
+ * @param {Array<Number|String>} messageIds Identifiers of 1-100 messages in the chat from_chat_id to forward.
1211
+ * The identifiers must be specified in a strictly increasing order.
1212
+ * @param {Object} [options] Additional Telegram query options
1213
+ * @return {Promise} An array of MessageId of the sent messages on success
1214
+ * @see https://core.telegram.org/bots/api#forwardmessages
1215
+ */
1216
+
1217
+ }, {
1218
+ key: 'forwardMessages',
1219
+ value: function forwardMessages(chatId, fromChatId, messageIds) {
1220
+ var form = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
1221
+
1222
+ form.chat_id = chatId;
1223
+ form.from_chat_id = fromChatId;
1224
+ form.message_ids = messageIds;
1225
+ return this._request('forwardMessages', { form: form });
1226
+ }
1227
+
1228
+ /**
1229
+ * Copy messages of any kind. **Service messages and invoice messages can't be copied.**
1230
+ * The method is analogous to the method forwardMessages, but the copied message doesn't
1231
+ * have a link to the original message.
1232
+ * Returns the MessageId of the sent message on success.
1233
+ * @param {Number|String} chatId Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
1234
+ * @param {Number|String} fromChatId Unique identifier for the chat where the
1235
+ * original message was sent
1236
+ * @param {Number|String} messageId Unique message identifier
1237
+ * @param {Object} [options] Additional Telegram query options
1238
+ * @return {Promise} The [MessageId](https://core.telegram.org/bots/api#messageid) of the sent message on success
1239
+ * @see https://core.telegram.org/bots/api#copymessage
1240
+ */
1241
+
1242
+ }, {
1243
+ key: 'copyMessage',
1244
+ value: function copyMessage(chatId, fromChatId, messageId) {
1245
+ var form = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
1246
+
1247
+ form.chat_id = chatId;
1248
+ form.from_chat_id = fromChatId;
1249
+ form.message_id = messageId;
1250
+ return this._request('copyMessage', { form: form });
1251
+ }
1252
+
1253
+ /**
1254
+ * Use this method to copy messages of any kind. If some of the specified messages can't be found or copied, they are skipped.
1255
+ * Service messages, giveaway messages, giveaway winners messages, and invoice messages can't be copied.
1256
+ * Returns the MessageId of the sent message on success.
1257
+ * @param {Number|String} chatId Unique identifier for the target chat
1258
+ * @param {Number|String} fromChatId Unique identifier for the chat where the
1259
+ * original message was sent
1260
+ * @param {Array} messageIds Identifiers of 1-100 messages in the chat from_chat_id to copy.
1261
+ * The identifiers must be specified in a strictly increasing order.
1262
+ * @param {Object} [options] Additional Telegram query options
1263
+ * @return {Promise} An array of MessageId of the sent messages
1264
+ * @see https://core.telegram.org/bots/api#copymessages
1265
+ */
1266
+
1267
+ }, {
1268
+ key: 'copyMessages',
1269
+ value: function copyMessages(chatId, fromChatId, messageIds) {
1270
+ var form = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
1271
+
1272
+ form.chat_id = chatId;
1273
+ form.from_chat_id = fromChatId;
1274
+ form.message_ids = stringify(messageIds);
1275
+ return this._request('copyMessages', { form: form });
1276
+ }
1277
+
1278
+ /**
1279
+ * Send photo
1280
+ * @param {Number|String} chatId Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
1281
+ * @param {String|stream.Stream|Buffer} photo A file path or a Stream. Can
1282
+ * also be a `file_id` previously uploaded
1283
+ * @param {Object} [options] Additional Telegram query options
1284
+ * @param {Object} [fileOptions] Optional file related meta-data
1285
+ * @return {Promise} On success, the sent [Message](https://core.telegram.org/bots/api#message) object is returned
1286
+ * @see https://core.telegram.org/bots/api#sendphoto
1287
+ * @see https://github.com/yagop/node-telegram-bot-api/blob/master/doc/usage.md#sending-files
1288
+ */
1289
+
1290
+ }, {
1291
+ key: 'sendPhoto',
1292
+ value: function sendPhoto(chatId, photo) {
1293
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1294
+ var fileOptions = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
1295
+
1296
+ var opts = {
1297
+ qs: options
1298
+ };
1299
+ opts.qs.chat_id = chatId;
1300
+ try {
1301
+ var sendData = this._formatSendData('photo', photo, fileOptions);
1302
+ opts.formData = sendData[0];
1303
+ opts.qs.photo = sendData[1];
1304
+ } catch (ex) {
1305
+ return Promise.reject(ex);
1306
+ }
1307
+ return this._request('sendPhoto', opts);
1308
+ }
1309
+
1310
+ /**
1311
+ * Send audio
1312
+ *
1313
+ * **Your audio must be in the .MP3 or .M4A format.**
1314
+ *
1315
+ * @param {Number|String} chatId Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
1316
+ * @param {String|stream.Stream|Buffer} audio A file path, Stream or Buffer.
1317
+ * Can also be a `file_id` previously uploaded.
1318
+ * @param {Object} [options] Additional Telegram query options
1319
+ * @param {Object} [fileOptions] Optional file related meta-data
1320
+ * @return {Promise} On success, the sent [Message](https://core.telegram.org/bots/api#message) object is returned
1321
+ * @see https://core.telegram.org/bots/api#sendaudio
1322
+ * @see https://github.com/yagop/node-telegram-bot-api/blob/master/doc/usage.md#sending-files
1323
+ */
1324
+
1325
+ }, {
1326
+ key: 'sendAudio',
1327
+ value: function sendAudio(chatId, audio) {
1328
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1329
+ var fileOptions = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
1330
+
1331
+ var opts = {
1332
+ qs: options
1333
+ };
1334
+
1335
+ opts.qs.chat_id = chatId;
1336
+
1337
+ try {
1338
+ var sendData = this._formatSendData('audio', audio, fileOptions);
1339
+ opts.formData = sendData[0];
1340
+ opts.qs.audio = sendData[1];
1341
+ this._fixAddFileThumbnail(options, opts);
1342
+ } catch (ex) {
1343
+ return Promise.reject(ex);
1344
+ }
1345
+
1346
+ return this._request('sendAudio', opts);
1347
+ }
1348
+
1349
+ /**
1350
+ * Send Document
1351
+ * @param {Number|String} chatId Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
1352
+ * @param {String|stream.Stream|Buffer} doc A file path, Stream or Buffer.
1353
+ * Can also be a `file_id` previously uploaded.
1354
+ * @param {Object} [options] Additional Telegram query options
1355
+ * @param {Object} [fileOptions] Optional file related meta-data
1356
+ * @return {Promise} On success, the sent [Message](https://core.telegram.org/bots/api#message) object is returned
1357
+ * @see https://core.telegram.org/bots/api#sendDocument
1358
+ * @see https://github.com/yagop/node-telegram-bot-api/blob/master/doc/usage.md#sending-files
1359
+ */
1360
+
1361
+ }, {
1362
+ key: 'sendDocument',
1363
+ value: function sendDocument(chatId, doc) {
1364
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1365
+ var fileOptions = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
1366
+
1367
+ var opts = {
1368
+ qs: options
1369
+ };
1370
+ opts.qs.chat_id = chatId;
1371
+ try {
1372
+ var sendData = this._formatSendData('document', doc, fileOptions);
1373
+ opts.formData = sendData[0];
1374
+ opts.qs.document = sendData[1];
1375
+ this._fixAddFileThumbnail(options, opts);
1376
+ } catch (ex) {
1377
+ return Promise.reject(ex);
1378
+ }
1379
+
1380
+ return this._request('sendDocument', opts);
1381
+ }
1382
+
1383
+ /**
1384
+ * Use this method to send video files, **Telegram clients support mp4 videos** (other formats may be sent as Document).
1385
+ *
1386
+ * @param {Number|String} chatId Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
1387
+ * @param {String|stream.Stream|Buffer} video A file path or Stream.
1388
+ * Can also be a `file_id` previously uploaded.
1389
+ * @param {Object} [options] Additional Telegram query options
1390
+ * @param {Object} [fileOptions] Optional file related meta-data
1391
+ * @return {Promise} On success, the sent [Message](https://core.telegram.org/bots/api#message) object is returned
1392
+ * @see https://core.telegram.org/bots/api#sendvideo
1393
+ * @see https://github.com/yagop/node-telegram-bot-api/blob/master/doc/usage.md#sending-files
1394
+ */
1395
+
1396
+ }, {
1397
+ key: 'sendVideo',
1398
+ value: function sendVideo(chatId, video) {
1399
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1400
+ var fileOptions = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
1401
+
1402
+ var opts = {
1403
+ qs: options
1404
+ };
1405
+ opts.qs.chat_id = chatId;
1406
+ try {
1407
+ var sendData = this._formatSendData('video', video, fileOptions);
1408
+ opts.formData = sendData[0];
1409
+ opts.qs.video = sendData[1];
1410
+ this._fixAddFileThumbnail(options, opts);
1411
+ } catch (ex) {
1412
+ return Promise.reject(ex);
1413
+ }
1414
+ return this._request('sendVideo', opts);
1415
+ }
1416
+
1417
+ /**
1418
+ * Use this method to send animation files (GIF or H.264/MPEG-4 AVC video without sound).
1419
+ * @param {Number|String} chatId Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
1420
+ * @param {String|stream.Stream|Buffer} animation A file path, Stream or Buffer.
1421
+ * Can also be a `file_id` previously uploaded.
1422
+ * @param {Object} [options] Additional Telegram query options
1423
+ * @param {Object} [fileOptions] Optional file related meta-data
1424
+ * @return {Promise} On success, the sent [Message](https://core.telegram.org/bots/api#message) object is returned
1425
+ * @see https://core.telegram.org/bots/api#sendanimation
1426
+ * @see https://github.com/yagop/node-telegram-bot-api/blob/master/doc/usage.md#sending-files
1427
+ */
1428
+
1429
+ }, {
1430
+ key: 'sendAnimation',
1431
+ value: function sendAnimation(chatId, animation) {
1432
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1433
+ var fileOptions = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
1434
+
1435
+ var opts = {
1436
+ qs: options
1437
+ };
1438
+ opts.qs.chat_id = chatId;
1439
+ try {
1440
+ var sendData = this._formatSendData('animation', animation, fileOptions);
1441
+ opts.formData = sendData[0];
1442
+ opts.qs.animation = sendData[1];
1443
+ } catch (ex) {
1444
+ return Promise.reject(ex);
1445
+ }
1446
+ return this._request('sendAnimation', opts);
1447
+ }
1448
+
1449
+ /**
1450
+ * Send voice
1451
+ *
1452
+ * **Your audio must be in an .OGG file encoded with OPUS**, or in .MP3 format, or in .M4A format (other formats may be sent as Audio or Document)
1453
+ * @param {Number|String} chatId Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
1454
+ * @param {String|stream.Stream|Buffer} voice A file path, Stream or Buffer.
1455
+ * Can also be a `file_id` previously uploaded.
1456
+ * @param {Object} [options] Additional Telegram query options
1457
+ * @param {Object} [fileOptions] Optional file related meta-data
1458
+ * @return {Promise} On success, the sent [Message](https://core.telegram.org/bots/api#message) object is returned
1459
+ * @see https://core.telegram.org/bots/api#sendvoice
1460
+ * @see https://github.com/yagop/node-telegram-bot-api/blob/master/doc/usage.md#sending-files
1461
+ */
1462
+
1463
+ }, {
1464
+ key: 'sendVoice',
1465
+ value: function sendVoice(chatId, voice) {
1466
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1467
+ var fileOptions = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
1468
+
1469
+ var opts = {
1470
+ qs: options
1471
+ };
1472
+ opts.qs.chat_id = chatId;
1473
+ try {
1474
+ var sendData = this._formatSendData('voice', voice, fileOptions);
1475
+ opts.formData = sendData[0];
1476
+ opts.qs.voice = sendData[1];
1477
+ } catch (ex) {
1478
+ return Promise.reject(ex);
1479
+ }
1480
+ return this._request('sendVoice', opts);
1481
+ }
1482
+
1483
+ /**
1484
+ * Use this method to send video messages
1485
+ * Telegram clients support **rounded square MPEG4 videos** of up to 1 minute long.
1486
+ * @param {Number|String} chatId Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
1487
+ * @param {String|stream.Stream|Buffer} videoNote A file path or Stream.
1488
+ * Can also be a `file_id` previously uploaded.
1489
+ * @param {Object} [options] Additional Telegram query options
1490
+ * @param {Object} [fileOptions] Optional file related meta-data
1491
+ * @return {Promise} On success, the sent [Message](https://core.telegram.org/bots/api#message) object is returned
1492
+ * @info The length parameter is actually optional. However, the API (at time of writing) requires you to always provide it until it is fixed.
1493
+ * @see https://core.telegram.org/bots/api#sendvideonote
1494
+ * @see https://github.com/yagop/node-telegram-bot-api/blob/master/doc/usage.md#sending-files
1495
+ */
1496
+
1497
+ }, {
1498
+ key: 'sendVideoNote',
1499
+ value: function sendVideoNote(chatId, videoNote) {
1500
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1501
+ var fileOptions = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
1502
+
1503
+ var opts = {
1504
+ qs: options
1505
+ };
1506
+ opts.qs.chat_id = chatId;
1507
+ try {
1508
+ var sendData = this._formatSendData('video_note', videoNote, fileOptions);
1509
+ opts.formData = sendData[0];
1510
+ opts.qs.video_note = sendData[1];
1511
+ this._fixAddFileThumbnail(options, opts);
1512
+ } catch (ex) {
1513
+ return Promise.reject(ex);
1514
+ }
1515
+ return this._request('sendVideoNote', opts);
1516
+ }
1517
+
1518
+ /**
1519
+ * Use this method to send paid media.
1520
+ * @param {Number|String} chatId Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
1521
+ * @param {Number} starCount The number of Telegram Stars that must be paid to buy access to the media; 1-10000
1522
+ * @param {Array} media Array of [InputPaidMedia](https://core.telegram.org/bots/api#inputpaidmedia). The media property can bea String, Stream or Buffer.
1523
+ * @param {Object} [options] Additional Telegram query options
1524
+ * @return {Promise} On success, the sent [Message](https://core.telegram.org/bots/api#message) object is returned
1525
+ * @see https://core.telegram.org/bots/api#sendpaidmedia
1526
+ */
1527
+
1528
+ }, {
1529
+ key: 'sendPaidMedia',
1530
+ value: function sendPaidMedia(chatId, starCount, media) {
1531
+ var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
1532
+
1533
+ var opts = {
1534
+ qs: options
1535
+ };
1536
+
1537
+ opts.qs.chat_id = chatId;
1538
+ opts.qs.star_count = starCount;
1539
+
1540
+ try {
1541
+ var inputPaidMedia = [];
1542
+ opts.formData = {};
1543
+
1544
+ var _formatSendMultipleDa = this._formatSendMultipleData('media', media),
1545
+ formData = _formatSendMultipleDa.formData,
1546
+ fileIds = _formatSendMultipleDa.fileIds;
1547
+
1548
+ opts.formData = formData;
1549
+
1550
+ inputPaidMedia.push.apply(inputPaidMedia, _toConsumableArray(media.map(function (item, index) {
1551
+ if (fileIds[index]) {
1552
+ item.media = fileIds[index];
1553
+ } else {
1554
+ item.media = 'attach://media_' + index;
1555
+ }
1556
+ return item;
1557
+ })));
1558
+
1559
+ opts.qs.media = stringify(inputPaidMedia);
1560
+ } catch (ex) {
1561
+ return Promise.reject(ex);
1562
+ }
1563
+
1564
+ return this._request('sendPaidMedia', opts);
1565
+ }
1566
+
1567
+ /**
1568
+ * Use this method to send a group of photos or videos as an album.
1569
+ *
1570
+ * **Documents and audio files can be only grouped in an album with messages of the same type**
1571
+ *
1572
+ * If you wish to [specify file options](https://github.com/yagop/node-telegram-bot-api/blob/master/doc/usage.md#sending-files),
1573
+ * add a `fileOptions` property to the target input in `media`.
1574
+ *
1575
+ * @param {String} chatId Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
1576
+ * @param {Array} media A JSON-serialized array describing photos and videos to be sent, must include 2–10 items
1577
+ * @param {Object} [options] Additional Telegram query options
1578
+ * @return {Promise} On success, an array of the sent [Messages](https://core.telegram.org/bots/api#message)
1579
+ * is returned.
1580
+ * @see https://core.telegram.org/bots/api#sendmediagroup
1581
+ * @see https://github.com/yagop/node-telegram-bot-api/blob/master/doc/usage.md#sending-files
1582
+ */
1583
+
1584
+ }, {
1585
+ key: 'sendMediaGroup',
1586
+ value: function sendMediaGroup(chatId, media) {
1587
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1588
+
1589
+ var opts = {
1590
+ qs: options
1591
+ };
1592
+ opts.qs.chat_id = chatId;
1593
+
1594
+ opts.formData = {};
1595
+ var inputMedia = [];
1596
+ var index = 0;
1597
+ var _iteratorNormalCompletion = true;
1598
+ var _didIteratorError = false;
1599
+ var _iteratorError = undefined;
1600
+
1601
+ try {
1602
+ for (var _iterator = media[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
1603
+ var input = _step.value;
1604
+
1605
+ var payload = Object.assign({}, input);
1606
+ delete payload.media;
1607
+ delete payload.fileOptions;
1608
+ try {
1609
+ var attachName = String(index);
1610
+
1611
+ var _formatSendData4 = this._formatSendData(attachName, input.media, input.fileOptions),
1612
+ _formatSendData5 = _slicedToArray(_formatSendData4, 2),
1613
+ formData = _formatSendData5[0],
1614
+ fileId = _formatSendData5[1];
1615
+
1616
+ if (formData) {
1617
+ opts.formData[attachName] = formData[attachName];
1618
+ payload.media = 'attach://' + attachName;
1619
+ } else {
1620
+ payload.media = fileId;
1621
+ }
1622
+ } catch (ex) {
1623
+ return Promise.reject(ex);
1624
+ }
1625
+ inputMedia.push(payload);
1626
+ index++;
1627
+ }
1628
+ } catch (err) {
1629
+ _didIteratorError = true;
1630
+ _iteratorError = err;
1631
+ } finally {
1632
+ try {
1633
+ if (!_iteratorNormalCompletion && _iterator.return) {
1634
+ _iterator.return();
1635
+ }
1636
+ } finally {
1637
+ if (_didIteratorError) {
1638
+ throw _iteratorError;
1639
+ }
1640
+ }
1641
+ }
1642
+
1643
+ opts.qs.media = stringify(inputMedia);
1644
+
1645
+ return this._request('sendMediaGroup', opts);
1646
+ }
1647
+
1648
+ /**
1649
+ * Send location.
1650
+ * Use this method to send point on the map.
1651
+ *
1652
+ * @param {Number|String} chatId Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
1653
+ * @param {Float} latitude Latitude of location
1654
+ * @param {Float} longitude Longitude of location
1655
+ * @param {Object} [options] Additional Telegram query options
1656
+ * @return {Promise} On success, the sent [Message](https://core.telegram.org/bots/api#message) object is returned
1657
+ * @see https://core.telegram.org/bots/api#sendlocation
1658
+ */
1659
+
1660
+ }, {
1661
+ key: 'sendLocation',
1662
+ value: function sendLocation(chatId, latitude, longitude) {
1663
+ var form = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
1664
+
1665
+ form.chat_id = chatId;
1666
+ form.latitude = latitude;
1667
+ form.longitude = longitude;
1668
+ return this._request('sendLocation', { form: form });
1669
+ }
1670
+
1671
+ /**
1672
+ * Use this method to edit live location messages sent by
1673
+ * the bot or via the bot (for inline bots).
1674
+ *
1675
+ * A location **can be edited until its live_period expires or editing is explicitly disabled by a call to [stopMessageLiveLocation](https://core.telegram.org/bots/api#stopmessagelivelocation)**
1676
+ *
1677
+ * Note that you must provide one of chat_id, message_id, or
1678
+ * inline_message_id in your request.
1679
+ *
1680
+ * @param {Float} latitude Latitude of location
1681
+ * @param {Float} longitude Longitude of location
1682
+ * @param {Object} [options] Additional Telegram query options (provide either one of chat_id, message_id, or inline_message_id here)
1683
+ * @return {Promise} On success, if the edited message is not an inline message, the edited [Message](https://core.telegram.org/bots/api#message) is returned, otherwise True is returned.
1684
+ * @see https://core.telegram.org/bots/api#editmessagelivelocation
1685
+ */
1686
+
1687
+ }, {
1688
+ key: 'editMessageLiveLocation',
1689
+ value: function editMessageLiveLocation(latitude, longitude) {
1690
+ var form = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1691
+
1692
+ form.latitude = latitude;
1693
+ form.longitude = longitude;
1694
+ return this._request('editMessageLiveLocation', { form: form });
1695
+ }
1696
+
1697
+ /**
1698
+ * Use this method to stop updating a live location message sent by
1699
+ * the bot or via the bot (for inline bots) before live_period expires.
1700
+ *
1701
+ * Note that you must provide one of chat_id, message_id, or
1702
+ * inline_message_id in your request.
1703
+ *
1704
+ * @param {Object} [options] Additional Telegram query options (provide either one of chat_id, message_id, or inline_message_id here)
1705
+ * @return {Promise} On success, if the edited message is not an inline message, the edited [Message](https://core.telegram.org/bots/api#message) is returned, otherwise True is returned.
1706
+ * @see https://core.telegram.org/bots/api#stopmessagelivelocation
1707
+ */
1708
+
1709
+ }, {
1710
+ key: 'stopMessageLiveLocation',
1711
+ value: function stopMessageLiveLocation() {
1712
+ var form = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1713
+
1714
+ return this._request('stopMessageLiveLocation', { form: form });
1715
+ }
1716
+
1717
+ /**
1718
+ * Send venue.
1719
+ * Use this method to send information about a venue.
1720
+ *
1721
+ * @param {Number|String} chatId Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
1722
+ * @param {Float} latitude Latitude of location
1723
+ * @param {Float} longitude Longitude of location
1724
+ * @param {String} title Name of the venue
1725
+ * @param {String} address Address of the venue
1726
+ * @param {Object} [options] Additional Telegram query options
1727
+ * @return {Promise} On success, the sent [Message](https://core.telegram.org/bots/api#message) object is returned.
1728
+ * @see https://core.telegram.org/bots/api#sendvenue
1729
+ */
1730
+
1731
+ }, {
1732
+ key: 'sendVenue',
1733
+ value: function sendVenue(chatId, latitude, longitude, title, address) {
1734
+ var form = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
1735
+
1736
+ form.chat_id = chatId;
1737
+ form.latitude = latitude;
1738
+ form.longitude = longitude;
1739
+ form.title = title;
1740
+ form.address = address;
1741
+ return this._request('sendVenue', { form: form });
1742
+ }
1743
+
1744
+ /**
1745
+ * Send contact.
1746
+ * Use this method to send phone contacts.
1747
+ *
1748
+ * @param {Number|String} chatId Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
1749
+ * @param {String} phoneNumber Contact's phone number
1750
+ * @param {String} firstName Contact's first name
1751
+ * @param {Object} [options] Additional Telegram query options
1752
+ * @return {Promise} On success, the sent [Message](https://core.telegram.org/bots/api#message) object is returned
1753
+ * @see https://core.telegram.org/bots/api#sendcontact
1754
+ */
1755
+
1756
+ }, {
1757
+ key: 'sendContact',
1758
+ value: function sendContact(chatId, phoneNumber, firstName) {
1759
+ var form = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
1760
+
1761
+ form.chat_id = chatId;
1762
+ form.phone_number = phoneNumber;
1763
+ form.first_name = firstName;
1764
+ return this._request('sendContact', { form: form });
1765
+ }
1766
+
1767
+ /**
1768
+ * Send poll.
1769
+ * Use this method to send a native poll.
1770
+ *
1771
+ * @param {Number|String} chatId Unique identifier for the group/channel
1772
+ * @param {String} question Poll question, 1-300 characters
1773
+ * @param {Array} pollOptions Poll options, between 2-10 options (only 1-100 characters each)
1774
+ * @param {Object} [options] Additional Telegram query options
1775
+ * @return {Promise} On success, the sent [Message](https://core.telegram.org/bots/api#message) object is returned
1776
+ * @see https://core.telegram.org/bots/api#sendpoll
1777
+ */
1778
+
1779
+ }, {
1780
+ key: 'sendPoll',
1781
+ value: function sendPoll(chatId, question, pollOptions) {
1782
+ var form = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
1783
+
1784
+ form.chat_id = chatId;
1785
+ form.question = question;
1786
+ form.options = stringify(pollOptions);
1787
+ return this._request('sendPoll', { form: form });
1788
+ }
1789
+
1790
+ /**
1791
+ * Send sendChecklist.
1792
+ * Use this method to send a checklist on behalf of a connected business account.
1793
+ *
1794
+ * @param {Number|String} businessConnectionId Unique identifier for the business connection
1795
+ * @param {Number|String} chatId Unique identifier for the group/channel
1796
+ * @param {Object} checklist A JSON-serialized object for the checklist to send
1797
+ * @param {Object} [options] Additional Telegram query options
1798
+ * @return {Promise} On success, the sent [Message](https://core.telegram.org/bots/api#message) object is returned
1799
+ * @see https://core.telegram.org/bots/api#sendchecklist
1800
+ */
1801
+
1802
+ }, {
1803
+ key: 'sendChecklist',
1804
+ value: function sendChecklist(businessConnectionId, chatId, checklist) {
1805
+ var form = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
1806
+
1807
+ form.business_connection_id = businessConnectionId;
1808
+ form.chat_id = chatId;
1809
+ form.checklist = stringify(checklist);
1810
+ return this._request('sendChecklist', { form: form });
1811
+ }
1812
+
1813
+ /**
1814
+ * Send Dice
1815
+ * Use this method to send an animated emoji that will display a random value.
1816
+ * @param {Number|String} chatId Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
1817
+ * @param {Object} [options] Additional Telegram query options
1818
+ * @return {Promise} On success, the sent [Message](https://core.telegram.org/bots/api#message) object is returned
1819
+ * @see https://core.telegram.org/bots/api#senddice
1820
+ */
1821
+
1822
+ }, {
1823
+ key: 'sendDice',
1824
+ value: function sendDice(chatId) {
1825
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1826
+
1827
+ var opts = {
1828
+ qs: options
1829
+ };
1830
+ opts.qs.chat_id = chatId;
1831
+ try {
1832
+ var sendData = this._formatSendData('dice');
1833
+ opts.formData = sendData[0];
1834
+ } catch (ex) {
1835
+ return Promise.reject(ex);
1836
+ }
1837
+ return this._request('sendDice', opts);
1838
+ }
1839
+
1840
+ /**
1841
+ * Send chat action.
1842
+ *
1843
+ * Use this method when you need to tell the user that something is happening on the bot's side.
1844
+ * **The status is set for 5 seconds or less** (when a message arrives from your bot, Telegram clients clear its typing status).
1845
+ *
1846
+ * Action `typing` for [text messages](https://core.telegram.org/bots/api#sendmessage),
1847
+ * `upload_photo` for [photos](https://core.telegram.org/bots/api#sendphoto), `record_video` or `upload_video` for [videos](https://core.telegram.org/bots/api#sendvideo),
1848
+ * `record_voice` or `upload_voice` for [voice notes](https://core.telegram.org/bots/api#sendvoice), `upload_document` for [general files](https://core.telegram.org/bots/api#senddocument),
1849
+ * `choose_sticker` for [stickers](https://core.telegram.org/bots/api#sendsticker), `find_location` for [location data](https://core.telegram.org/bots/api#sendlocation),
1850
+ * `record_video_note` or `upload_video_note` for [video notes](https://core.telegram.org/bots/api#sendvideonote).
1851
+ *
1852
+ *
1853
+ * @param {Number|String} chatId Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
1854
+ * @param {String} action Type of action to broadcast.
1855
+ * @param {Object} [options] Additional Telegram query options
1856
+ * @return {Promise} True on success
1857
+ * @see https://core.telegram.org/bots/api#sendchataction
1858
+ */
1859
+
1860
+ }, {
1861
+ key: 'sendChatAction',
1862
+ value: function sendChatAction(chatId, action) {
1863
+ var form = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1864
+
1865
+ form.chat_id = chatId;
1866
+ form.action = action;
1867
+ return this._request('sendChatAction', { form: form });
1868
+ }
1869
+
1870
+ /**
1871
+ * Use this method to change the chosen reactions on a message.
1872
+ * - Service messages can't be reacted to.
1873
+ * - Automatically forwarded messages from a channel to its discussion group have the same available reactions as messages in the channel.
1874
+ * - In albums, bots must react to the first message.
1875
+ *
1876
+ * @param {Number|String} chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
1877
+ * @param {Number} messageId Unique identifier of the target message
1878
+ * @param {Object} [options] Additional Telegram query options
1879
+ * @return {Promise<Boolean>} True on success
1880
+ * @see https://core.telegram.org/bots/api#setmessagereaction
1881
+ */
1882
+
1883
+ }, {
1884
+ key: 'setMessageReaction',
1885
+ value: function setMessageReaction(chatId, messageId) {
1886
+ var form = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1887
+
1888
+ form.chat_id = chatId;
1889
+ form.message_id = messageId;
1890
+ if (form.reaction) {
1891
+ form.reaction = stringify(form.reaction);
1892
+ }
1893
+ return this._request('setMessageReaction', { form: form });
1894
+ }
1895
+
1896
+ /**
1897
+ * Use this method to get a list of profile pictures for a user.
1898
+ * Returns a [UserProfilePhotos](https://core.telegram.org/bots/api#userprofilephotos) object.
1899
+ * This method has an [older, compatible signature][getUserProfilePhotos-v0.25.0]
1900
+ * that is being deprecated.
1901
+ *
1902
+ * @param {Number} userId Unique identifier of the target user
1903
+ * @param {Object} [options] Additional Telegram query options
1904
+ * @return {Promise} Returns a [UserProfilePhotos](https://core.telegram.org/bots/api#userprofilephotos) object
1905
+ * @see https://core.telegram.org/bots/api#getuserprofilephotos
1906
+ */
1907
+
1908
+ }, {
1909
+ key: 'getUserProfilePhotos',
1910
+ value: function getUserProfilePhotos(userId) {
1911
+ var form = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1912
+
1913
+ /* The older method signature was getUserProfilePhotos(userId, offset, limit).
1914
+ * We need to ensure backwards-compatibility while maintaining
1915
+ * consistency of the method signatures throughout the library */
1916
+ if ((typeof form === 'undefined' ? 'undefined' : _typeof(form)) !== 'object') {
1917
+ /* eslint-disable no-param-reassign, prefer-rest-params */
1918
+ deprecate('The method signature getUserProfilePhotos(userId, offset, limit) has been deprecated since v0.25.0');
1919
+ form = {
1920
+ offset: arguments[1],
1921
+ limit: arguments[2]
1922
+ };
1923
+ /* eslint-enable no-param-reassign, prefer-rest-params */
1924
+ }
1925
+ form.user_id = userId;
1926
+ return this._request('getUserProfilePhotos', { form: form });
1927
+ }
1928
+
1929
+ /**
1930
+ * Changes the emoji status for a given user that previously allowed the bot to manage their emoji status
1931
+ * via the Mini App method [requestEmojiStatusAccess](https://core.telegram.org/bots/webapps#initializing-mini-apps).
1932
+ *
1933
+ * @param {Number} userId Unique identifier of the target user
1934
+ * @param {Object} [options] Additional Telegram query options
1935
+ * @return {Promise} True on success
1936
+ * @see https://core.telegram.org/bots/api#setuseremojistatus
1937
+ */
1938
+
1939
+ }, {
1940
+ key: 'setUserEmojiStatus',
1941
+ value: function setUserEmojiStatus(userId) {
1942
+ var form = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1943
+
1944
+ form.user_id = userId;
1945
+ return this._request('setUserEmojiStatus', { form: form });
1946
+ }
1947
+
1948
+ /**
1949
+ * Get file.
1950
+ * Use this method to get basic info about a file and prepare it for downloading.
1951
+ *
1952
+ * Attention: **link will be valid for 1 hour.**
1953
+ *
1954
+ * @param {String} fileId File identifier to get info about
1955
+ * @param {Object} [options] Additional Telegram query options
1956
+ * @return {Promise} On success, a [File](https://core.telegram.org/bots/api#file) object is returned
1957
+ * @see https://core.telegram.org/bots/api#getfile
1958
+ */
1959
+
1960
+ }, {
1961
+ key: 'getFile',
1962
+ value: function getFile(fileId) {
1963
+ var form = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1964
+
1965
+ form.file_id = fileId;
1966
+ return this._request('getFile', { form: form });
1967
+ }
1968
+
1969
+ /**
1970
+ * Use this method to ban a user in a group, a supergroup or a channel.
1971
+ * In the case of supergroups and channels, the user will not be able to
1972
+ * return to the chat on their own using invite links, etc., unless unbanned first..
1973
+ *
1974
+ * The **bot must be an administrator in the group, supergroup or a channel** for this to work.
1975
+ *
1976
+ *
1977
+ * @param {Number|String} chatId Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
1978
+ * @param {Number} userId Unique identifier of the target user
1979
+ * @param {Object} [options] Additional Telegram query options
1980
+ * @return {Promise} True on success.
1981
+ * @see https://core.telegram.org/bots/api#banchatmember
1982
+ */
1983
+
1984
+ }, {
1985
+ key: 'banChatMember',
1986
+ value: function banChatMember(chatId, userId) {
1987
+ var form = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1988
+
1989
+ form.chat_id = chatId;
1990
+ form.user_id = userId;
1991
+ return this._request('banChatMember', { form: form });
1992
+ }
1993
+
1994
+ /**
1995
+ * Use this method to unban a previously kicked user in a supergroup.
1996
+ * The user will not return to the group automatically, but will be
1997
+ * able to join via link, etc.
1998
+ *
1999
+ * The **bot must be an administrator** in the supergroup or channel for this to work.
2000
+ *
2001
+ * **By default**, this method guarantees that after the call the user is not a member of the chat, but will be able to join it.
2002
+ * So **if the user is a member of the chat they will also be removed from the chat**. If you don't want this, use the parameter *only_if_banned*
2003
+ *
2004
+ * @param {Number|String} chatId Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
2005
+ * @param {Number} userId Unique identifier of the target user
2006
+ * @param {Object} [options] Additional Telegram query options
2007
+ * @return {Promise} True on success
2008
+ * @see https://core.telegram.org/bots/api#unbanchatmember
2009
+ */
2010
+
2011
+ }, {
2012
+ key: 'unbanChatMember',
2013
+ value: function unbanChatMember(chatId, userId) {
2014
+ var form = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2015
+
2016
+ form.chat_id = chatId;
2017
+ form.user_id = userId;
2018
+ return this._request('unbanChatMember', { form: form });
2019
+ }
2020
+
2021
+ /**
2022
+ * Use this method to restrict a user in a supergroup.
2023
+ * The bot **must be an administrator in the supergroup** for this to work
2024
+ * and must have the appropriate admin rights. Pass True for all boolean parameters
2025
+ * to lift restrictions from a user. Returns True on success.
2026
+ *
2027
+ * @param {Number|String} chatId Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
2028
+ * @param {Number} userId Unique identifier of the target user
2029
+ * @param {Object} [options] Additional Telegram query options
2030
+ * @return {Promise} True on success
2031
+ * @see https://core.telegram.org/bots/api#restrictchatmember
2032
+ */
2033
+
2034
+ }, {
2035
+ key: 'restrictChatMember',
2036
+ value: function restrictChatMember(chatId, userId) {
2037
+ var form = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2038
+
2039
+ form.chat_id = chatId;
2040
+ form.user_id = userId;
2041
+ return this._request('restrictChatMember', { form: form });
2042
+ }
2043
+
2044
+ /**
2045
+ * Use this method to promote or demote a user in a supergroup or a channel.
2046
+ * The bot **must be an administrator** in the chat for this to work
2047
+ * and must have the appropriate admin rights. Pass False for all boolean parameters to demote a user.
2048
+ *
2049
+ * @param {Number|String} chatId Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
2050
+ * @param {Number} userId
2051
+ * @param {Object} [options] Additional Telegram query options
2052
+ * @return {Promise} True on success.
2053
+ * @see https://core.telegram.org/bots/api#promotechatmember
2054
+ */
2055
+
2056
+ }, {
2057
+ key: 'promoteChatMember',
2058
+ value: function promoteChatMember(chatId, userId) {
2059
+ var form = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2060
+
2061
+ form.chat_id = chatId;
2062
+ form.user_id = userId;
2063
+ return this._request('promoteChatMember', { form: form });
2064
+ }
2065
+
2066
+ /**
2067
+ * Use this method to set a custom title for an administrator in a supergroup promoted by the bot.
2068
+ *
2069
+ * @param {Number|String} chatId Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
2070
+ * @param {Number} userId Unique identifier of the target user
2071
+ * @param {String} customTitle New custom title for the administrator; 0-16 characters, emoji are not allowed
2072
+ * @param {Object} [options] Additional Telegram query options
2073
+ * @return {Promise} True on success
2074
+ * @see https://core.telegram.org/bots/api#setchatadministratorcustomtitle
2075
+ */
2076
+
2077
+ }, {
2078
+ key: 'setChatAdministratorCustomTitle',
2079
+ value: function setChatAdministratorCustomTitle(chatId, userId, customTitle) {
2080
+ var form = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
2081
+
2082
+ form.chat_id = chatId;
2083
+ form.user_id = userId;
2084
+ form.custom_title = customTitle;
2085
+ return this._request('setChatAdministratorCustomTitle', { form: form });
2086
+ }
2087
+
2088
+ /**
2089
+ * Use this method to ban a channel chat in a supergroup or a channel.
2090
+ *
2091
+ * Until the chat is [unbanned](https://core.telegram.org/bots/api#unbanchatsenderchat), the owner of the banned chat won't be able to send messages on behalf of any of their channels.
2092
+ * The bot **must be an administrator in the supergroup or channel** for this to work and must have the appropriate administrator rights
2093
+ *
2094
+ * @param {Number|String} chatId Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
2095
+ * @param {Number} senderChatId Unique identifier of the target user
2096
+ * @param {Object} [options] Additional Telegram query options
2097
+ * @return {Promise} True on success.
2098
+ * @see https://core.telegram.org/bots/api#banchatsenderchat
2099
+ */
2100
+
2101
+ }, {
2102
+ key: 'banChatSenderChat',
2103
+ value: function banChatSenderChat(chatId, senderChatId) {
2104
+ var form = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2105
+
2106
+ form.chat_id = chatId;
2107
+ form.sender_chat_id = senderChatId;
2108
+ return this._request('banChatSenderChat', { form: form });
2109
+ }
2110
+
2111
+ /**
2112
+ * Use this method to unban a previously banned channel chat in a supergroup or channel.
2113
+ *
2114
+ * The bot **must be an administrator** for this to work and must have the appropriate administrator rights.
2115
+ *
2116
+ * @param {Number|String} chatId Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
2117
+ * @param {Number} senderChatId Unique identifier of the target user
2118
+ * @param {Object} [options] Additional Telegram query options
2119
+ * @return {Promise} True on success
2120
+ * @see https://core.telegram.org/bots/api#unbanchatsenderchat
2121
+ */
2122
+
2123
+ }, {
2124
+ key: 'unbanChatSenderChat',
2125
+ value: function unbanChatSenderChat(chatId, senderChatId) {
2126
+ var form = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2127
+
2128
+ form.chat_id = chatId;
2129
+ form.sender_chat_id = senderChatId;
2130
+ return this._request('unbanChatSenderChat', { form: form });
2131
+ }
2132
+
2133
+ /**
2134
+ * Use this method to set default chat permissions for all members.
2135
+ *
2136
+ * The bot **must be an administrator in the group or a supergroup** for this to
2137
+ * work and **must have the `can_restrict_members` admin rights.**
2138
+ *
2139
+ * @param {Number|String} chatId Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
2140
+ * @param {Array} chatPermissions New default chat permissions
2141
+ * @param {Object} [options] Additional Telegram query options
2142
+ * @return {Promise} True on success
2143
+ * @see https://core.telegram.org/bots/api#setchatpermissions
2144
+ */
2145
+
2146
+ }, {
2147
+ key: 'setChatPermissions',
2148
+ value: function setChatPermissions(chatId, chatPermissions) {
2149
+ var form = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2150
+
2151
+ form.chat_id = chatId;
2152
+ form.permissions = stringify(chatPermissions);
2153
+ return this._request('setChatPermissions', { form: form });
2154
+ }
2155
+
2156
+ /**
2157
+ * Use this method to generate a new primary invite link for a chat. **Any previously generated primary link is revoked**.
2158
+ *
2159
+ * The bot **must be an administrator in the chat** for this to work and must have the appropriate administrator rights.
2160
+ *
2161
+ * @param {Number|String} chatId Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
2162
+ * @param {Object} [options] Additional Telegram query options
2163
+ * @return {Promise} Exported invite link as String on success.
2164
+ * @see https://core.telegram.org/bots/api#exportchatinvitelink
2165
+ */
2166
+
2167
+ }, {
2168
+ key: 'exportChatInviteLink',
2169
+ value: function exportChatInviteLink(chatId) {
2170
+ var form = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2171
+
2172
+ form.chat_id = chatId;
2173
+ return this._request('exportChatInviteLink', { form: form });
2174
+ }
2175
+
2176
+ /**
2177
+ * Use this method to create an additional invite link for a chat.
2178
+ *
2179
+ * The bot **must be an administrator in the chat** for this to work and must have the appropriate admin rights.
2180
+ *
2181
+ * The link generated with this method can be revoked using the method [revokeChatInviteLink](https://core.telegram.org/bots/api#revokechatinvitelink)
2182
+ *
2183
+ * @param {Number|String} chatId Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
2184
+ * @param {Object} [options] Additional Telegram query options
2185
+ * @return {Object} The new invite link as [ChatInviteLink](https://core.telegram.org/bots/api#chatinvitelink) object
2186
+ * @see https://core.telegram.org/bots/api#createchatinvitelink
2187
+ */
2188
+
2189
+ }, {
2190
+ key: 'createChatInviteLink',
2191
+ value: function createChatInviteLink(chatId) {
2192
+ var form = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2193
+
2194
+ form.chat_id = chatId;
2195
+ return this._request('createChatInviteLink', { form: form });
2196
+ }
2197
+
2198
+ /**
2199
+ * Use this method to edit a non-primary invite link created by the bot.
2200
+ *
2201
+ * The bot **must be an administrator in the chat** for this to work and must have the appropriate admin rights.
2202
+ *
2203
+ * @param {Number|String} chatId Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
2204
+ * @param {String} inviteLink Text with the invite link to edit
2205
+ * @param {Object} [options] Additional Telegram query options
2206
+ * @return {Promise} The edited invite link as a [ChatInviteLink](https://core.telegram.org/bots/api#chatinvitelink) object
2207
+ * @see https://core.telegram.org/bots/api#editchatinvitelink
2208
+ */
2209
+
2210
+ }, {
2211
+ key: 'editChatInviteLink',
2212
+ value: function editChatInviteLink(chatId, inviteLink) {
2213
+ var form = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2214
+
2215
+ form.chat_id = chatId;
2216
+ form.invite_link = inviteLink;
2217
+ return this._request('editChatInviteLink', { form: form });
2218
+ }
2219
+
2220
+ /**
2221
+ * Use this method to create a subscription invite link for a channel chat.
2222
+ *
2223
+ * The bot must have the can_invite_users administrator rights
2224
+ *
2225
+ * @param {Number|String} chatId Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
2226
+ * @param {Number} subscriptionPeriod The number of seconds the subscription will be active for before the next payment. Currently, it must always be 2592000 (30 days)
2227
+ * @param {Number} subscriptionPrice The amount of Telegram Stars a user must pay initially and after each subsequent subscription period to be a member of the chat (1-2500)
2228
+ * @param {Object} [options] Additional Telegram query options
2229
+ * @return {Promise} The new invite link as a [ChatInviteLink](https://core.telegram.org/bots/api#chatinvitelink) object
2230
+ * @see https://core.telegram.org/bots/api#createchatsubscriptioninvitelink
2231
+ */
2232
+
2233
+ }, {
2234
+ key: 'createChatSubscriptionInviteLink',
2235
+ value: function createChatSubscriptionInviteLink(chatId, subscriptionPeriod, subscriptionPrice) {
2236
+ var form = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
2237
+
2238
+ form.chat_id = chatId;
2239
+ form.subscription_period = subscriptionPeriod;
2240
+ form.subscription_price = subscriptionPrice;
2241
+ return this._request('createChatSubscriptionInviteLink', { form: form });
2242
+ }
2243
+
2244
+ /**
2245
+ * Use this method to edit a subscription invite link created by the bot.
2246
+ *
2247
+ * The bot must have the can_invite_users administrator rights
2248
+ *
2249
+ * @param {Number|String} chatId Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
2250
+ * @param {String} inviteLink The invite link to edit
2251
+ * @param {Object} [options] Additional Telegram query options
2252
+ * @return {Promise} The new invite link as a [ChatInviteLink](https://core.telegram.org/bots/api#chatinvitelink) object
2253
+ * @see https://core.telegram.org/bots/api#editchatsubscriptioninvitelink
2254
+ */
2255
+
2256
+ }, {
2257
+ key: 'editChatSubscriptionInviteLink',
2258
+ value: function editChatSubscriptionInviteLink(chatId, inviteLink) {
2259
+ var form = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2260
+
2261
+ form.chat_id = chatId;
2262
+ form.invite_link = inviteLink;
2263
+ return this._request('editChatSubscriptionInviteLink', { form: form });
2264
+ }
2265
+
2266
+ /**
2267
+ * Use this method to revoke an invite link created by the bot.
2268
+ * Note: If the primary link is revoked, a new link is automatically generated
2269
+ *
2270
+ * The bot **must be an administrator in the chat** for this to work and must have the appropriate admin rights.
2271
+ *
2272
+ * @param {Number|String} chatId Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
2273
+ * @param {String} inviteLink The invite link to revoke
2274
+ * @param {Object} [options] Additional Telegram query options
2275
+ * @return {Promise} The revoked invite link as [ChatInviteLink](https://core.telegram.org/bots/api#chatinvitelink) object
2276
+ * @see https://core.telegram.org/bots/api#revokechatinvitelink
2277
+ */
2278
+
2279
+ }, {
2280
+ key: 'revokeChatInviteLink',
2281
+ value: function revokeChatInviteLink(chatId, inviteLink) {
2282
+ var form = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2283
+
2284
+ form.chat_id = chatId;
2285
+ form.invite_link = inviteLink;
2286
+ return this._request('revokeChatInviteLink', { form: form });
2287
+ }
2288
+
2289
+ /**
2290
+ * Use this method to approve a chat join request.
2291
+ *
2292
+ * The bot **must be an administrator in the chat** for this to work and **must have the `can_invite_users` administrator right.**
2293
+ *
2294
+ * @param {Number|String} chatId Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
2295
+ * @param {Number} userId Unique identifier of the target user
2296
+ * @param {Object} [options] Additional Telegram query options
2297
+ * @return {Promise} True on success
2298
+ * @see https://core.telegram.org/bots/api#approvechatjoinrequest
2299
+ */
2300
+
2301
+ }, {
2302
+ key: 'approveChatJoinRequest',
2303
+ value: function approveChatJoinRequest(chatId, userId) {
2304
+ var form = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2305
+
2306
+ form.chat_id = chatId;
2307
+ form.user_id = userId;
2308
+ return this._request('approveChatJoinRequest', { form: form });
2309
+ }
2310
+
2311
+ /**
2312
+ * Use this method to decline a chat join request.
2313
+ *
2314
+ * The bot **must be an administrator in the chat** for this to work and **must have the `can_invite_users` administrator right**.
2315
+ *
2316
+ * @param {Number|String} chatId Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
2317
+ * @param {Number} userId Unique identifier of the target user
2318
+ * @param {Object} [options] Additional Telegram query options
2319
+ * @return {Promise} True on success
2320
+ * @see https://core.telegram.org/bots/api#declinechatjoinrequest
2321
+ */
2322
+
2323
+ }, {
2324
+ key: 'declineChatJoinRequest',
2325
+ value: function declineChatJoinRequest(chatId, userId) {
2326
+ var form = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2327
+
2328
+ form.chat_id = chatId;
2329
+ form.user_id = userId;
2330
+ return this._request('declineChatJoinRequest', { form: form });
2331
+ }
2332
+
2333
+ /**
2334
+ * Use this method to set a new profile photo for the chat. **Photos can't be changed for private chats**.
2335
+ *
2336
+ * The bot **must be an administrator in the chat** for this to work and must have the appropriate admin rights.
2337
+ *
2338
+ * @param {Number|String} chatId Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
2339
+ * @param {stream.Stream|Buffer} photo A file path or a Stream.
2340
+ * @param {Object} [options] Additional Telegram query options
2341
+ * @param {Object} [fileOptions] Optional file related meta-data
2342
+ * @return {Promise} True on success
2343
+ * @see https://core.telegram.org/bots/api#setchatphoto
2344
+ */
2345
+
2346
+ }, {
2347
+ key: 'setChatPhoto',
2348
+ value: function setChatPhoto(chatId, photo) {
2349
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2350
+ var fileOptions = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
2351
+
2352
+ var opts = {
2353
+ qs: options
2354
+ };
2355
+ opts.qs.chat_id = chatId;
2356
+ try {
2357
+ var sendData = this._formatSendData('photo', photo, fileOptions);
2358
+ opts.formData = sendData[0];
2359
+ opts.qs.photo = sendData[1];
2360
+ } catch (ex) {
2361
+ return Promise.reject(ex);
2362
+ }
2363
+ return this._request('setChatPhoto', opts);
2364
+ }
2365
+
2366
+ /**
2367
+ * Use this method to delete a chat photo. **Photos can't be changed for private chats**.
2368
+ *
2369
+ * The bot **must be an administrator in the chat** for this to work and must have the appropriate admin rights.
2370
+ *
2371
+ * @param {Number|String} chatId Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
2372
+ * @param {Object} [options] Additional Telegram query options
2373
+ * @return {Promise} True on success
2374
+ * @see https://core.telegram.org/bots/api#deletechatphoto
2375
+ */
2376
+
2377
+ }, {
2378
+ key: 'deleteChatPhoto',
2379
+ value: function deleteChatPhoto(chatId) {
2380
+ var form = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2381
+
2382
+ form.chat_id = chatId;
2383
+ return this._request('deleteChatPhoto', { form: form });
2384
+ }
2385
+
2386
+ /**
2387
+ * Use this method to change the title of a chat. **Titles can't be changed for private chats**.
2388
+ *
2389
+ * The bot **must be an administrator in the chat** for this to work and must have the appropriate admin rights.
2390
+ *
2391
+ * @param {Number|String} chatId Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
2392
+ * @param {String} title New chat title, 1-255 characters
2393
+ * @param {Object} [options] Additional Telegram query options
2394
+ * @return {Promise} True on success
2395
+ * @see https://core.telegram.org/bots/api#setchattitle
2396
+ */
2397
+
2398
+ }, {
2399
+ key: 'setChatTitle',
2400
+ value: function setChatTitle(chatId, title) {
2401
+ var form = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2402
+
2403
+ form.chat_id = chatId;
2404
+ form.title = title;
2405
+ return this._request('setChatTitle', { form: form });
2406
+ }
2407
+
2408
+ /**
2409
+ * Use this method to change the description of a group, a supergroup or a channel.
2410
+ *
2411
+ * The bot **must be an administrator in the chat** for this to work and must have the appropriate admin rights.
2412
+ *
2413
+ * @param {Number|String} chatId Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
2414
+ * @param {String} description New chat title, 0-255 characters
2415
+ * @param {Object} [options] Additional Telegram query options
2416
+ * @return {Promise} True on success
2417
+ * @see https://core.telegram.org/bots/api#setchatdescription
2418
+ */
2419
+
2420
+ }, {
2421
+ key: 'setChatDescription',
2422
+ value: function setChatDescription(chatId, description) {
2423
+ var form = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2424
+
2425
+ form.chat_id = chatId;
2426
+ form.description = description;
2427
+ return this._request('setChatDescription', { form: form });
2428
+ }
2429
+
2430
+ /**
2431
+ * Use this method to pin a message in a supergroup.
2432
+ *
2433
+ * If the chat is not a private chat, the **bot must be an administrator in the chat** for this to work and must have the `can_pin_messages` administrator
2434
+ * right in a supergroup or `can_edit_messages` administrator right in a channel.
2435
+ *
2436
+ * @param {Number|String} chatId Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
2437
+ * @param {Number} messageId Identifier of a message to pin
2438
+ * @param {Object} [options] Additional Telegram query options
2439
+ * @return {Promise} True on success
2440
+ * @see https://core.telegram.org/bots/api#pinchatmessage
2441
+ */
2442
+
2443
+ }, {
2444
+ key: 'pinChatMessage',
2445
+ value: function pinChatMessage(chatId, messageId) {
2446
+ var form = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2447
+
2448
+ form.chat_id = chatId;
2449
+ form.message_id = messageId;
2450
+ return this._request('pinChatMessage', { form: form });
2451
+ }
2452
+
2453
+ /**
2454
+ * Use this method to remove a message from the list of pinned messages in a chat
2455
+ *
2456
+ * If the chat is not a private chat, the **bot must be an administrator in the chat** for this to work and must have the `can_pin_messages` administrator
2457
+ * right in a supergroup or `can_edit_messages` administrator right in a channel.
2458
+ *
2459
+ * @param {Number|String} chatId Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
2460
+ * @param {Object} [options] Additional Telegram query options
2461
+ * @return {Promise} True on success
2462
+ * @see https://core.telegram.org/bots/api#unpinchatmessage
2463
+ */
2464
+
2465
+ }, {
2466
+ key: 'unpinChatMessage',
2467
+ value: function unpinChatMessage(chatId) {
2468
+ var form = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2469
+
2470
+ form.chat_id = chatId;
2471
+ return this._request('unpinChatMessage', { form: form });
2472
+ }
2473
+
2474
+ /**
2475
+ * Use this method to clear the list of pinned messages in a chat.
2476
+ *
2477
+ * If the chat is not a private chat, the **bot must be an administrator in the chat** for this to work and must have the `can_pin_messages` administrator
2478
+ * right in a supergroup or `can_edit_messages` administrator right in a channel.
2479
+ *
2480
+ * @param {Number|String} chatId Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
2481
+ * @param {Object} [options] Additional Telegram query options
2482
+ * @return {Promise} True on success
2483
+ * @see https://core.telegram.org/bots/api#unpinallchatmessages
2484
+ */
2485
+
2486
+ }, {
2487
+ key: 'unpinAllChatMessages',
2488
+ value: function unpinAllChatMessages(chatId) {
2489
+ var form = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2490
+
2491
+ form.chat_id = chatId;
2492
+ return this._request('unpinAllChatMessages', { form: form });
2493
+ }
2494
+
2495
+ /**
2496
+ * Use this method for your bot to leave a group, supergroup or channel
2497
+ *
2498
+ * @param {Number|String} chatId Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
2499
+ * @param {Object} [options] Additional Telegram query options
2500
+ * @return {Promise} True on success
2501
+ * @see https://core.telegram.org/bots/api#leavechat
2502
+ */
2503
+
2504
+ }, {
2505
+ key: 'leaveChat',
2506
+ value: function leaveChat(chatId) {
2507
+ var form = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2508
+
2509
+ form.chat_id = chatId;
2510
+ return this._request('leaveChat', { form: form });
2511
+ }
2512
+
2513
+ /**
2514
+ * Use this method to get up to date information about the chat
2515
+ * (current name of the user for one-on-one conversations, current
2516
+ * username of a user, group or channel, etc.).
2517
+ * @param {Number|String} chatId Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) or channel
2518
+ * @param {Object} [options] Additional Telegram query options
2519
+ * @return {Promise} [ChatFullInfo](https://core.telegram.org/bots/api#chatfullinfo) object on success
2520
+ * @see https://core.telegram.org/bots/api#getchat
2521
+ */
2522
+
2523
+ }, {
2524
+ key: 'getChat',
2525
+ value: function getChat(chatId) {
2526
+ var form = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2527
+
2528
+ form.chat_id = chatId;
2529
+ return this._request('getChat', { form: form });
2530
+ }
2531
+
2532
+ /**
2533
+ * Use this method to get a list of administrators in a chat
2534
+ *
2535
+ * @param {Number|String} chatId Unique identifier for the target group or username of the target supergroup
2536
+ * @param {Object} [options] Additional Telegram query options
2537
+ * @return {Promise} On success, returns an Array of [ChatMember](https://core.telegram.org/bots/api#chatmember) objects that contains information about all chat administrators except other bots.
2538
+ * If the chat is a group or a supergroup and no administrators were appointed, only the creator will be returned
2539
+ * @see https://core.telegram.org/bots/api#getchatadministrators
2540
+ */
2541
+
2542
+ }, {
2543
+ key: 'getChatAdministrators',
2544
+ value: function getChatAdministrators(chatId) {
2545
+ var form = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2546
+
2547
+ form.chat_id = chatId;
2548
+ return this._request('getChatAdministrators', { form: form });
2549
+ }
2550
+
2551
+ /**
2552
+ * Use this method to get the number of members in a chat.
2553
+ *
2554
+ * @param {Number|String} chatId Unique identifier for the target group or username of the target supergroup
2555
+ * @param {Object} [options] Additional Telegram query options
2556
+ * @return {Promise} Int on success
2557
+ * @see https://core.telegram.org/bots/api#getchatmembercount
2558
+ */
2559
+
2560
+ }, {
2561
+ key: 'getChatMemberCount',
2562
+ value: function getChatMemberCount(chatId) {
2563
+ var form = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2564
+
2565
+ form.chat_id = chatId;
2566
+ return this._request('getChatMemberCount', { form: form });
2567
+ }
2568
+
2569
+ /**
2570
+ * Use this method to get information about a member of a chat.
2571
+ *
2572
+ * @param {Number|String} chatId Unique identifier for the target group or username of the target supergroup
2573
+ * @param {Number} userId Unique identifier of the target user
2574
+ * @param {Object} [options] Additional Telegram query options
2575
+ * @return {Promise} [ChatMember](https://core.telegram.org/bots/api#chatmember) object on success
2576
+ * @see https://core.telegram.org/bots/api#getchatmember
2577
+ */
2578
+
2579
+ }, {
2580
+ key: 'getChatMember',
2581
+ value: function getChatMember(chatId, userId) {
2582
+ var form = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2583
+
2584
+ form.chat_id = chatId;
2585
+ form.user_id = userId;
2586
+ return this._request('getChatMember', { form: form });
2587
+ }
2588
+
2589
+ /**
2590
+ * Use this method to set a new group sticker set for a supergroup.
2591
+ *
2592
+ * The bot **must be an administrator in the chat** for this to work and must have the appropriate administrator rights.
2593
+ *
2594
+ * **Note:** Use the field `can_set_sticker_set` optionally returned in [getChat](https://core.telegram.org/bots/api#getchat) requests to check if the bot can use this method.
2595
+ *
2596
+ * @param {Number|String} chatId Unique identifier for the target group or username of the target supergroup (in the format @supergroupusername)
2597
+ * @param {String} stickerSetName Name of the sticker set to be set as the group sticker set
2598
+ * @param {Object} [options] Additional Telegram query options
2599
+ * @return {Promise} True on success
2600
+ * @see https://core.telegram.org/bots/api#setchatstickerset
2601
+ */
2602
+
2603
+ }, {
2604
+ key: 'setChatStickerSet',
2605
+ value: function setChatStickerSet(chatId, stickerSetName) {
2606
+ var form = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2607
+
2608
+ form.chat_id = chatId;
2609
+ form.sticker_set_name = stickerSetName;
2610
+ return this._request('setChatStickerSet', { form: form });
2611
+ }
2612
+
2613
+ /**
2614
+ * Use this method to delete a group sticker set from a supergroup.
2615
+ *
2616
+ * Use the field `can_set_sticker_set` optionally returned in [getChat](https://core.telegram.org/bots/api#getchat) requests to check if the bot can use this method.
2617
+ *
2618
+ * @param {Number|String} chatId Unique identifier for the target group or username of the target supergroup (in the format @supergroupusername)
2619
+ * @param {Object} [options] Additional Telegram query options
2620
+ * @return {Promise} True on success
2621
+ * @see https://core.telegram.org/bots/api#deletechatstickerset
2622
+ */
2623
+
2624
+ }, {
2625
+ key: 'deleteChatStickerSet',
2626
+ value: function deleteChatStickerSet(chatId) {
2627
+ var form = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2628
+
2629
+ form.chat_id = chatId;
2630
+ return this._request('deleteChatStickerSet', { form: form });
2631
+ }
2632
+
2633
+ /**
2634
+ * Use this method to get custom emoji stickers, which can be used as a forum topic icon by any user.
2635
+ *
2636
+ * @param {Number|String} chatId Unique identifier for the target group or username of the target supergroup (in the format @supergroupusername)
2637
+ * @param {Object} [options] Additional Telegram query options
2638
+ * @return {Promise} Array of [Sticker](https://core.telegram.org/bots/api#sticker) objects
2639
+ * @see https://core.telegram.org/bots/api#getforumtopiciconstickers
2640
+ */
2641
+
2642
+ }, {
2643
+ key: 'getForumTopicIconStickers',
2644
+ value: function getForumTopicIconStickers(chatId) {
2645
+ var form = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2646
+
2647
+ form.chat_id = chatId;
2648
+ return this._request('getForumTopicIconStickers', { form: form });
2649
+ }
2650
+
2651
+ /**
2652
+ * Use this method to create a topic in a forum supergroup chat.
2653
+ * The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights.
2654
+ *
2655
+ * Returns information about the created topic as a [ForumTopic](https://core.telegram.org/bots/api#forumtopic) object.
2656
+ *
2657
+ * @param {Number|String} chatId Unique identifier for the target group or username of the target supergroup (in the format @supergroupusername)
2658
+ * @param {String} name Topic name, 1-128 characters
2659
+ * @param {Object} [options] Additional Telegram query options
2660
+ * @see https://core.telegram.org/bots/api#createforumtopic
2661
+ */
2662
+
2663
+ }, {
2664
+ key: 'createForumTopic',
2665
+ value: function createForumTopic(chatId, name) {
2666
+ var form = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2667
+
2668
+ form.chat_id = chatId;
2669
+ form.name = name;
2670
+ return this._request('createForumTopic', { form: form });
2671
+ }
2672
+
2673
+ /**
2674
+ * Use this method to edit name and icon of a topic in a forum supergroup chat.
2675
+ * The bot must be an administrator in the chat for this to work and must have can_manage_topics administrator rights, unless it is the creator of the topic.
2676
+ *
2677
+ * @param {Number|String} chatId Unique identifier for the target group or username of the target supergroup (in the format @supergroupusername)
2678
+ * @param {Number} messageThreadId Unique identifier for the target message thread of the forum topic
2679
+ * @param {Object} [options] Additional Telegram query options
2680
+ * @return {Promise} True on success
2681
+ * @see https://core.telegram.org/bots/api#editforumtopic
2682
+ */
2683
+
2684
+ }, {
2685
+ key: 'editForumTopic',
2686
+ value: function editForumTopic(chatId, messageThreadId) {
2687
+ var form = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2688
+
2689
+ form.chat_id = chatId;
2690
+ form.message_thread_id = messageThreadId;
2691
+ return this._request('editForumTopic', { form: form });
2692
+ }
2693
+
2694
+ /**
2695
+ * Use this method to close an open topic in a forum supergroup chat.
2696
+ * The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights, unless it is the creator of the topic.
2697
+ *
2698
+ * @param {Number|String} chatId Unique identifier for the target group or username of the target supergroup (in the format @supergroupusername)
2699
+ * @param {Number} messageThreadId Unique identifier for the target message thread of the forum topic
2700
+ * @param {Object} [options] Additional Telegram query options
2701
+ * @return {Promise} True on success
2702
+ * @see https://core.telegram.org/bots/api#closeforumtopic
2703
+ */
2704
+
2705
+ }, {
2706
+ key: 'closeForumTopic',
2707
+ value: function closeForumTopic(chatId, messageThreadId) {
2708
+ var form = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2709
+
2710
+ form.chat_id = chatId;
2711
+ form.message_thread_id = messageThreadId;
2712
+ return this._request('closeForumTopic', { form: form });
2713
+ }
2714
+
2715
+ /**
2716
+ * Use this method to reopen a closed topic in a forum supergroup chat.
2717
+ * The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights, unless it is the creator of the topic.
2718
+ *
2719
+ * @param {Number|String} chatId Unique identifier for the target group or username of the target supergroup (in the format @supergroupusername)
2720
+ * @param {Number} messageThreadId Unique identifier for the target message thread of the forum topic
2721
+ * @param {Object} [options] Additional Telegram query options
2722
+ * @return {Promise} True on success
2723
+ * @see https://core.telegram.org/bots/api#reopenforumtopic
2724
+ */
2725
+
2726
+ }, {
2727
+ key: 'reopenForumTopic',
2728
+ value: function reopenForumTopic(chatId, messageThreadId) {
2729
+ var form = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2730
+
2731
+ form.chat_id = chatId;
2732
+ form.message_thread_id = messageThreadId;
2733
+ return this._request('reopenForumTopic', { form: form });
2734
+ }
2735
+
2736
+ /**
2737
+ * Use this method to delete a forum topic along with all its messages in a forum supergroup chat.
2738
+ * The bot must be an administrator in the chat for this to work and must have the can_delete_messages administrator rights.
2739
+ *
2740
+ * @param {Number|String} chatId Unique identifier for the target group or username of the target supergroup (in the format @supergroupusername)
2741
+ * @param {Number} messageThreadId Unique identifier for the target message thread of the forum topic
2742
+ * @param {Object} [options] Additional Telegram query options
2743
+ * @return {Promise} True on success
2744
+ * @see https://core.telegram.org/bots/api#deleteforumtopic
2745
+ */
2746
+
2747
+ }, {
2748
+ key: 'deleteForumTopic',
2749
+ value: function deleteForumTopic(chatId, messageThreadId) {
2750
+ var form = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2751
+
2752
+ form.chat_id = chatId;
2753
+ form.message_thread_id = messageThreadId;
2754
+ return this._request('deleteForumTopic', { form: form });
2755
+ }
2756
+
2757
+ /**
2758
+ * Use this method to clear the list of pinned messages in a forum topic.
2759
+ * The bot must be an administrator in the chat for this to work and must have the can_pin_messages administrator right in the supergroup.
2760
+ *
2761
+ * @param {Number|String} chatId Unique identifier for the target group or username of the target supergroup (in the format @supergroupusername)
2762
+ * @param {Number} messageThreadId Unique identifier for the target message thread of the forum topic
2763
+ * @param {Object} [options] Additional Telegram query options
2764
+ * @return {Promise} True on success
2765
+ * @see https://core.telegram.org/bots/api#unpinallforumtopicmessages
2766
+ */
2767
+
2768
+ }, {
2769
+ key: 'unpinAllForumTopicMessages',
2770
+ value: function unpinAllForumTopicMessages(chatId, messageThreadId) {
2771
+ var form = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2772
+
2773
+ form.chat_id = chatId;
2774
+ form.message_thread_id = messageThreadId;
2775
+ return this._request('unpinAllForumTopicMessages', { form: form });
2776
+ }
2777
+
2778
+ /**
2779
+ * Use this method to edit the name of the 'General' topic in a forum supergroup chat.
2780
+ * The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights.
2781
+ * The topic will be automatically unhidden if it was hidden.
2782
+ *
2783
+ * @param {Number|String} chatId Unique identifier for the target group or username of the target supergroup (in the format @supergroupusername)
2784
+ * @param {String} name New topic name, 1-128 characters
2785
+ * @param {Object} [options] Additional Telegram query options
2786
+ * @return {Promise} True on success
2787
+ * @see https://core.telegram.org/bots/api#editgeneralforumtopic
2788
+ */
2789
+
2790
+ }, {
2791
+ key: 'editGeneralForumTopic',
2792
+ value: function editGeneralForumTopic(chatId, name) {
2793
+ var form = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2794
+
2795
+ form.chat_id = chatId;
2796
+ form.name = name;
2797
+ return this._request('editGeneralForumTopic', { form: form });
2798
+ }
2799
+
2800
+ /**
2801
+ * Use this method to close an open 'General' topic in a forum supergroup chat.
2802
+ * The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights.
2803
+ * The topic will be automatically unhidden if it was hidden.
2804
+ *
2805
+ * @param {Number|String} chatId Unique identifier for the target group or username of the target supergroup (in the format @supergroupusername)
2806
+ * @param {Object} [options] Additional Telegram query options
2807
+ * @return {Promise} True on success
2808
+ * @see https://core.telegram.org/bots/api#closegeneralforumtopic
2809
+ */
2810
+
2811
+ }, {
2812
+ key: 'closeGeneralForumTopic',
2813
+ value: function closeGeneralForumTopic(chatId) {
2814
+ var form = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2815
+
2816
+ form.chat_id = chatId;
2817
+ return this._request('closeGeneralForumTopic', { form: form });
2818
+ }
2819
+
2820
+ /**
2821
+ * Use this method to reopen a closed 'General' topic in a forum supergroup chat.
2822
+ * The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights.
2823
+ * The topic will be automatically unhidden if it was hidden.
2824
+ *
2825
+ * @param {Number|String} chatId Unique identifier for the target group or username of the target supergroup (in the format @supergroupusername)
2826
+ * @param {Object} [options] Additional Telegram query options
2827
+ * @return {Promise} True on success
2828
+ * @see https://core.telegram.org/bots/api#reopengeneralforumtopic
2829
+ */
2830
+
2831
+ }, {
2832
+ key: 'reopenGeneralForumTopic',
2833
+ value: function reopenGeneralForumTopic(chatId) {
2834
+ var form = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2835
+
2836
+ form.chat_id = chatId;
2837
+ return this._request('reopenGeneralForumTopic', { form: form });
2838
+ }
2839
+
2840
+ /**
2841
+ * Use this method to hide the 'General' topic in a forum supergroup chat.
2842
+ * The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights.
2843
+ * The topic will be automatically closed if it was open.
2844
+ *
2845
+ * @param {Number|String} chatId Unique identifier for the target group or username of the target supergroup (in the format @supergroupusername)
2846
+ * @param {Object} [options] Additional Telegram query options
2847
+ * @return {Promise} True on success
2848
+ * @see https://core.telegram.org/bots/api#hidegeneralforumtopic
2849
+ */
2850
+
2851
+ }, {
2852
+ key: 'hideGeneralForumTopic',
2853
+ value: function hideGeneralForumTopic(chatId) {
2854
+ var form = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2855
+
2856
+ form.chat_id = chatId;
2857
+ return this._request('hideGeneralForumTopic', { form: form });
2858
+ }
2859
+
2860
+ /**
2861
+ * Use this method to unhide the 'General' topic in a forum supergroup chat.
2862
+ * The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights
2863
+ *
2864
+ * @param {Number|String} chatId Unique identifier for the target group or username of the target supergroup (in the format @supergroupusername)
2865
+ * @param {Object} [options] Additional Telegram query options
2866
+ * @return {Promise} True on success
2867
+ * @see https://core.telegram.org/bots/api#unhidegeneralforumtopic
2868
+ */
2869
+
2870
+ }, {
2871
+ key: 'unhideGeneralForumTopic',
2872
+ value: function unhideGeneralForumTopic(chatId) {
2873
+ var form = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2874
+
2875
+ form.chat_id = chatId;
2876
+ return this._request('unhideGeneralForumTopic', { form: form });
2877
+ }
2878
+
2879
+ /**
2880
+ * Use this method to clear the list of pinned messages in a General forum topic.
2881
+ * The bot must be an administrator in the chat for this to work and must have the can_pin_messages administrator right in the supergroup.
2882
+ *
2883
+ * @param {Number|String} chatId Unique identifier for the target group or username of the target supergroup (in the format @supergroupusername)
2884
+ * @param {Object} [options] Additional Telegram query options
2885
+ * @return {Promise} True on success
2886
+ * @see https://core.telegram.org/bots/api#unpinallgeneralforumtopicmessages
2887
+ */
2888
+
2889
+ }, {
2890
+ key: 'unpinAllGeneralForumTopicMessages',
2891
+ value: function unpinAllGeneralForumTopicMessages(chatId) {
2892
+ var form = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2893
+
2894
+ form.chat_id = chatId;
2895
+ return this._request('unhideGeneralForumTopic', { form: form });
2896
+ }
2897
+
2898
+ /**
2899
+ * Use this method to send answers to callback queries sent from
2900
+ * [inline keyboards](https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating).
2901
+ *
2902
+ * The answer will be displayed to the user as a notification at the top of the chat screen or as an alert.
2903
+ *
2904
+ * This method has **older, compatible signatures ([1][answerCallbackQuery-v0.27.1])([2][answerCallbackQuery-v0.29.0])**
2905
+ * that are being deprecated.
2906
+ *
2907
+ * @param {String} callbackQueryId Unique identifier for the query to be answered
2908
+ * @param {Object} [options] Additional Telegram query options
2909
+ * @return {Promise} True on success
2910
+ * @see https://core.telegram.org/bots/api#answercallbackquery
2911
+ */
2912
+
2913
+ }, {
2914
+ key: 'answerCallbackQuery',
2915
+ value: function answerCallbackQuery(callbackQueryId) {
2916
+ var form = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2917
+
2918
+ /* The older method signature (in/before v0.27.1) was answerCallbackQuery(callbackQueryId, text, showAlert).
2919
+ * We need to ensure backwards-compatibility while maintaining
2920
+ * consistency of the method signatures throughout the library */
2921
+ if ((typeof form === 'undefined' ? 'undefined' : _typeof(form)) !== 'object') {
2922
+ /* eslint-disable no-param-reassign, prefer-rest-params */
2923
+ deprecate('The method signature answerCallbackQuery(callbackQueryId, text, showAlert) has been deprecated since v0.27.1');
2924
+ form = {
2925
+ callback_query_id: arguments[0],
2926
+ text: arguments[1],
2927
+ show_alert: arguments[2]
2928
+ };
2929
+ /* eslint-enable no-param-reassign, prefer-rest-params */
2930
+ }
2931
+ /* The older method signature (in/before v0.29.0) was answerCallbackQuery([options]).
2932
+ * We need to ensure backwards-compatibility while maintaining
2933
+ * consistency of the method signatures throughout the library. */
2934
+ if ((typeof callbackQueryId === 'undefined' ? 'undefined' : _typeof(callbackQueryId)) === 'object') {
2935
+ /* eslint-disable no-param-reassign, prefer-rest-params */
2936
+ deprecate('The method signature answerCallbackQuery([options]) has been deprecated since v0.29.0');
2937
+ form = callbackQueryId;
2938
+ /* eslint-enable no-param-reassign, prefer-rest-params */
2939
+ } else {
2940
+ form.callback_query_id = callbackQueryId;
2941
+ }
2942
+ return this._request('answerCallbackQuery', { form: form });
2943
+ }
2944
+
2945
+ /**
2946
+ * Use this method to stores a message that can be sent by a user of a Mini App.
2947
+ *
2948
+ * @param {Number} userId Unique identifier of the target user
2949
+ * @param {InlineQueryResult} result object that represents one result of an inline query
2950
+ * @param {Object} [options] Optional form data to include in the request
2951
+ * @return {Promise} On success, returns a [PreparedInlineMessage](https://core.telegram.org/bots/api#preparedinlinemessage) object.
2952
+ * @see https://core.telegram.org/bots/api#savepreparedinlinemessage
2953
+ */
2954
+
2955
+ }, {
2956
+ key: 'savePreparedInlineMessage',
2957
+ value: function savePreparedInlineMessage(userId, result) {
2958
+ var form = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2959
+
2960
+ form.user_id = userId;
2961
+ form.result = stringify(result);
2962
+ return this._request('savePreparedInlineMessage', { form: form });
2963
+ }
2964
+
2965
+ /**
2966
+ * Use this method to get the list of boosts added to a chat by a use.
2967
+ * Requires administrator rights in the chat
2968
+ *
2969
+ * @param {Number|String} chatId Unique identifier for the group/channel
2970
+ * @param {Number} userId Unique identifier of the target user
2971
+ * @param {Object} [options] Additional Telegram query options
2972
+ * @return {Promise} On success, returns a [UserChatBoosts](https://core.telegram.org/bots/api#userchatboosts) object
2973
+ * @see https://core.telegram.org/bots/api#getuserchatboosts
2974
+ */
2975
+
2976
+ }, {
2977
+ key: 'getUserChatBoosts',
2978
+ value: function getUserChatBoosts(chatId, userId) {
2979
+ var form = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2980
+
2981
+ form.chat_id = chatId;
2982
+ form.user_id = userId;
2983
+ return this._request('getUserChatBoosts', { form: form });
2984
+ }
2985
+
2986
+ /**
2987
+ * Use this method to get information about the connection of the bot with a business account
2988
+ *
2989
+ * @param {Number|String} businessConnectionId Unique identifier for the group/channel
2990
+ * @param {Object} [options] Additional Telegram query options
2991
+ * @return {Promise} On success, returns [BusinessConnection](https://core.telegram.org/bots/api#businessconnection) object
2992
+ * @see https://core.telegram.org/bots/api#getbusinessconnection
2993
+ */
2994
+
2995
+ }, {
2996
+ key: 'getBusinessConnection',
2997
+ value: function getBusinessConnection(businessConnectionId) {
2998
+ var form = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2999
+
3000
+ form.business_connection_id = businessConnectionId;
3001
+ return this._request('getBusinessConnection', { form: form });
3002
+ }
3003
+
3004
+ /**
3005
+ * Use this method to change the list of the bot's commands.
3006
+ *
3007
+ * See https://core.telegram.org/bots#commands for more details about bot commands
3008
+ *
3009
+ * @param {Array} commands List of bot commands to be set as the list of the [bot's commands](https://core.telegram.org/bots/api#botcommand). At most 100 commands can be specified.
3010
+ * @param {Object} [options] Additional Telegram query options
3011
+ * @return {Promise} True on success
3012
+ * @see https://core.telegram.org/bots/api#setmycommands
3013
+ */
3014
+
3015
+ }, {
3016
+ key: 'setMyCommands',
3017
+ value: function setMyCommands(commands) {
3018
+ var form = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3019
+
3020
+ form.commands = stringify(commands);
3021
+
3022
+ if (form.scope) {
3023
+ form.scope = stringify(form.scope);
3024
+ }
3025
+
3026
+ return this._request('setMyCommands', { form: form });
3027
+ }
3028
+
3029
+ /**
3030
+ * Use this method to delete the list of the bot's commands for the given scope and user language.
3031
+ *
3032
+ * After deletion, [higher level commands](https://core.telegram.org/bots/api#determining-list-of-commands) will be shown to affected users.
3033
+ *
3034
+ * @param {Object} [options] Additional Telegram query options
3035
+ * @return {Promise} True on success
3036
+ * @see https://core.telegram.org/bots/api#deletemycommands
3037
+ */
3038
+
3039
+ }, {
3040
+ key: 'deleteMyCommands',
3041
+ value: function deleteMyCommands() {
3042
+ var form = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3043
+
3044
+ return this._request('deleteMyCommands', { form: form });
3045
+ }
3046
+
3047
+ /**
3048
+ * Use this method to get the current list of the bot's commands for the given scope and user language.
3049
+ *
3050
+ * @param {Object} [options] Additional Telegram query options
3051
+ * @return {Promise} Array of [BotCommand](https://core.telegram.org/bots/api#botcommand) on success. If commands aren't set, an empty list is returned.
3052
+ * @see https://core.telegram.org/bots/api#getmycommands
3053
+ */
3054
+
3055
+ }, {
3056
+ key: 'getMyCommands',
3057
+ value: function getMyCommands() {
3058
+ var form = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3059
+
3060
+ if (form.scope) {
3061
+ form.scope = stringify(form.scope);
3062
+ }
3063
+ return this._request('getMyCommands', { form: form });
3064
+ }
3065
+
3066
+ /**
3067
+ * Use this method to change the bot's name.
3068
+ *
3069
+ * @param {Object} [options] Additional Telegram query options
3070
+ * @return {Promise} True on success
3071
+ * @see https://core.telegram.org/bots/api#setmyname
3072
+ */
3073
+
3074
+ }, {
3075
+ key: 'setMyName',
3076
+ value: function setMyName() {
3077
+ var form = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3078
+
3079
+ return this._request('setMyName', { form: form });
3080
+ }
3081
+
3082
+ /**
3083
+ * Use this method to get the current bot name for the given user language.
3084
+ *
3085
+ * @param {Object} [options] Additional Telegram query options
3086
+ * @return {Promise} [BotName](https://core.telegram.org/bots/api#botname) on success
3087
+ * @see https://core.telegram.org/bots/api#getmyname
3088
+ */
3089
+
3090
+ }, {
3091
+ key: 'getMyName',
3092
+ value: function getMyName() {
3093
+ var form = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3094
+
3095
+ return this._request('getMyName', { form: form });
3096
+ }
3097
+
3098
+ /**
3099
+ * Use this method to change the bot's description, which is shown in the chat with the bot if the chat is empty.
3100
+ *
3101
+ * Returns True on success.
3102
+ *
3103
+ * @param {Object} [options] Additional Telegram query options
3104
+ * @return {Promise} True on success
3105
+ * @see https://core.telegram.org/bots/api#setmydescription
3106
+ */
3107
+
3108
+ }, {
3109
+ key: 'setMyDescription',
3110
+ value: function setMyDescription() {
3111
+ var form = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3112
+
3113
+ return this._request('setMyDescription', { form: form });
3114
+ }
3115
+
3116
+ /**
3117
+ * Use this method to get the current bot description for the given user language.
3118
+ *
3119
+ * @param {Object} [options] Additional Telegram query options
3120
+ * @return {Promise} Returns [BotDescription](https://core.telegram.org/bots/api#botdescription) on success.
3121
+ * @see https://core.telegram.org/bots/api#getmydescription
3122
+ */
3123
+
3124
+ }, {
3125
+ key: 'getMyDescription',
3126
+ value: function getMyDescription() {
3127
+ var form = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3128
+
3129
+ return this._request('getMyDescription', { form: form });
3130
+ }
3131
+
3132
+ /**
3133
+ * Use this method to change the bot's short description, which is shown on the bot's profile page
3134
+ * and is sent together with the link when users share the bot.
3135
+ *
3136
+ * @param {Object} [options] Additional Telegram query options
3137
+ * @return {Promise} Returns True on success.
3138
+ * @see https://core.telegram.org/bots/api#setmyshortdescription
3139
+ */
3140
+
3141
+ }, {
3142
+ key: 'setMyShortDescription',
3143
+ value: function setMyShortDescription() {
3144
+ var form = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3145
+
3146
+ return this._request('setMyShortDescription', { form: form });
3147
+ }
3148
+
3149
+ /**
3150
+ * Use this method to get the current bot short description for the given user language.
3151
+ *
3152
+ * @param {Object} [options] Additional Telegram query options
3153
+ * @return {Promise} Returns [BotShortDescription](https://core.telegram.org/bots/api#botshortdescription) on success.
3154
+ * @see https://core.telegram.org/bots/api#getmyshortdescription
3155
+ */
3156
+
3157
+ }, {
3158
+ key: 'getMyShortDescription',
3159
+ value: function getMyShortDescription() {
3160
+ var form = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3161
+
3162
+ return this._request('getMyShortDescription', { form: form });
3163
+ }
3164
+
3165
+ /**
3166
+ * Use this method to change the bot's menu button in a private chat, or the default menu button.
3167
+ *
3168
+ * @param {Object} [options] Additional Telegram query options
3169
+ * @return {Promise} True on success
3170
+ * @see https://core.telegram.org/bots/api#setchatmenubutton
3171
+ */
3172
+
3173
+ }, {
3174
+ key: 'setChatMenuButton',
3175
+ value: function setChatMenuButton() {
3176
+ var form = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3177
+
3178
+ return this._request('setChatMenuButton', { form: form });
3179
+ }
3180
+
3181
+ /**
3182
+ * Use this method to get the current value of the bot's menu button in a private chat, or the default menu button.
3183
+ *
3184
+ * @param {Object} [options] Additional Telegram query options
3185
+ * @return {Promise} [MenuButton](https://core.telegram.org/bots/api#menubutton) on success
3186
+ * @see https://core.telegram.org/bots/api#getchatmenubutton
3187
+ */
3188
+
3189
+ }, {
3190
+ key: 'getChatMenuButton',
3191
+ value: function getChatMenuButton() {
3192
+ var form = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3193
+
3194
+ return this._request('getChatMenuButton', { form: form });
3195
+ }
3196
+
3197
+ /**
3198
+ * Use this method to change the default administrator rights requested by the bot when it's added as an administrator to groups or channels.
3199
+ *
3200
+ * These rights will be suggested to users, but they are are free to modify the list before adding the bot.
3201
+ *
3202
+ * @param {Object} [options] Additional Telegram query options
3203
+ * @return {Promise} True on success
3204
+ * @see https://core.telegram.org/bots/api#getchatmenubutton
3205
+ */
3206
+
3207
+ }, {
3208
+ key: 'setMyDefaultAdministratorRights',
3209
+ value: function setMyDefaultAdministratorRights() {
3210
+ var form = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3211
+
3212
+ return this._request('setMyDefaultAdministratorRights', { form: form });
3213
+ }
3214
+
3215
+ /**
3216
+ * Use this method to get the current default administrator rights of the bot.
3217
+ *
3218
+ * @param {Object} [options] Additional Telegram query options
3219
+ * @return {Promise} [ChatAdministratorRights](https://core.telegram.org/bots/api#chatadministratorrights) on success
3220
+ * @see https://core.telegram.org/bots/api#getmydefaultadministratorrights
3221
+ */
3222
+
3223
+ }, {
3224
+ key: 'getMyDefaultAdministratorRights',
3225
+ value: function getMyDefaultAdministratorRights() {
3226
+ var form = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3227
+
3228
+ return this._request('getMyDefaultAdministratorRights', { form: form });
3229
+ }
3230
+
3231
+ /**
3232
+ * Use this method to edit text or [game](https://core.telegram.org/bots/api#games) messages sent by the bot or via the bot (for inline bots).
3233
+ *
3234
+ * Note: that **you must provide one of chat_id, message_id, or inline_message_id** in your request.
3235
+ *
3236
+ * @param {String} text New text of the message
3237
+ * @param {Object} [options] Additional Telegram query options (provide either one of chat_id, message_id, or inline_message_id here)
3238
+ * @return {Promise} On success, if the edited message is not an inline message, the edited [Message](https://core.telegram.org/bots/api#message) is returned, otherwise True is returned
3239
+ * @see https://core.telegram.org/bots/api#editmessagetext
3240
+ */
3241
+
3242
+ }, {
3243
+ key: 'editMessageText',
3244
+ value: function editMessageText(text) {
3245
+ var form = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3246
+
3247
+ form.text = text;
3248
+ return this._request('editMessageText', { form: form });
3249
+ }
3250
+
3251
+ /**
3252
+ * Use this method to edit captions of messages sent by the bot or via the bot (for inline bots).
3253
+ *
3254
+ * Note: You **must provide one of chat_id, message_id, or inline_message_id** in your request.
3255
+ *
3256
+ * @param {String} caption New caption of the message
3257
+ * @param {Object} [options] Additional Telegram query options (provide either one of chat_id, message_id, or inline_message_id here)
3258
+ * @return {Promise} On success, if the edited message is not an inline message, the edited [Message](https://core.telegram.org/bots/api#message) is returned, otherwise True is returned
3259
+ * @see https://core.telegram.org/bots/api#editmessagecaption
3260
+ */
3261
+
3262
+ }, {
3263
+ key: 'editMessageCaption',
3264
+ value: function editMessageCaption(caption) {
3265
+ var form = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3266
+
3267
+ form.caption = caption;
3268
+ return this._request('editMessageCaption', { form: form });
3269
+ }
3270
+
3271
+ /**
3272
+ * Use this method to edit animation, audio, document, photo, or video messages.
3273
+ *
3274
+ * If a message is a part of a message album, then it can be edited only to a photo or a video.
3275
+ *
3276
+ * Otherwise, message type can be changed arbitrarily. When inline message is edited, new file can't be uploaded.
3277
+ * Use previously uploaded file via its file_id or specify a URL.
3278
+ *
3279
+ * Note: You **must provide one of chat_id, message_id, or inline_message_id** in your request.
3280
+ *
3281
+ * @param {Object} media A JSON-serialized object for a new media content of the message
3282
+ * @param {Object} [options] Additional Telegram query options (provide either one of chat_id, message_id, or inline_message_id here)
3283
+ * @return {Promise} On success, if the edited message is not an inline message, the edited [Message](https://core.telegram.org/bots/api#message) is returned, otherwise True is returned
3284
+ * @see https://core.telegram.org/bots/api#editmessagemedia
3285
+ */
3286
+
3287
+ }, {
3288
+ key: 'editMessageMedia',
3289
+ value: function editMessageMedia(media) {
3290
+ var form = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3291
+
3292
+ var regexAttach = /attach:\/\/.+/;
3293
+
3294
+ if (typeof media.media === 'string' && regexAttach.test(media.media)) {
3295
+ var opts = {
3296
+ qs: form
3297
+ };
3298
+
3299
+ opts.formData = {};
3300
+
3301
+ var payload = Object.assign({}, media);
3302
+ delete payload.media;
3303
+
3304
+ try {
3305
+ var attachName = String(0);
3306
+
3307
+ var _formatSendData6 = this._formatSendData(attachName, media.media.replace('attach://', ''), media.fileOptions),
3308
+ _formatSendData7 = _slicedToArray(_formatSendData6, 1),
3309
+ formData = _formatSendData7[0];
3310
+
3311
+ if (formData) {
3312
+ opts.formData[attachName] = formData[attachName];
3313
+ payload.media = 'attach://' + attachName;
3314
+ } else {
3315
+ throw new errors.FatalError('Failed to process the replacement action for your ' + media.type);
3316
+ }
3317
+ } catch (ex) {
3318
+ return Promise.reject(ex);
3319
+ }
3320
+
3321
+ opts.qs.media = stringify(payload);
3322
+
3323
+ return this._request('editMessageMedia', opts);
3324
+ }
3325
+
3326
+ form.media = stringify(media);
3327
+
3328
+ return this._request('editMessageMedia', { form: form });
3329
+ }
3330
+
3331
+ /**
3332
+ * Use this method to edit a checklist on behalf of a business connection.
3333
+ * @param {Number|String} businessConnectionId Unique identifier for the target business connection
3334
+ * @param {Number|String} chatId Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
3335
+ * @param {Number} messageId Unique identifier for the target message
3336
+ * @param {Object} checklist A JSON-serialized object for the new checklist
3337
+ * @param {Object} [options] Additional Telegram query options
3338
+ * @return {Promise} On success, the sent [Message](https://core.telegram.org/bots/api#message) object is returned.
3339
+ * @see https://core.telegram.org/bots/api#editmessagechecklist
3340
+ */
3341
+
3342
+ }, {
3343
+ key: 'editMessageChecklist',
3344
+ value: function editMessageChecklist(businessConnectionId, chatId, messageId, checklist) {
3345
+ var form = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
3346
+
3347
+ form.business_connection_id = businessConnectionId;
3348
+ form.chat_id = chatId;
3349
+ form.message_id = messageId;
3350
+ form.checklist = stringify(checklist);
3351
+ return this._request('editMessageChecklist', { form: form });
3352
+ }
3353
+
3354
+ /**
3355
+ * Use this method to edit only the reply markup of messages sent by the bot or via the bot (for inline bots).
3356
+ *
3357
+ * Note: You **must provide one of chat_id, message_id, or inline_message_id** in your request.
3358
+ *
3359
+ * @param {Object} replyMarkup A JSON-serialized object for an inline keyboard.
3360
+ * @param {Object} [options] Additional Telegram query options (provide either one of chat_id, message_id, or inline_message_id here)
3361
+ * @return {Promise} On success, if the edited message is not an inline message, the edited [Message](https://core.telegram.org/bots/api#message) is returned, otherwise True is returned
3362
+ * @see https://core.telegram.org/bots/api#editmessagetext
3363
+ */
3364
+
3365
+ }, {
3366
+ key: 'editMessageReplyMarkup',
3367
+ value: function editMessageReplyMarkup(replyMarkup) {
3368
+ var form = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3369
+
3370
+ form.reply_markup = replyMarkup;
3371
+ return this._request('editMessageReplyMarkup', { form: form });
3372
+ }
3373
+
3374
+ /**
3375
+ * Use this method to stop a poll which was sent by the bot.
3376
+ *
3377
+ * @param {Number|String} chatId Unique identifier for the group/channel
3378
+ * @param {Number} pollId Identifier of the original message with the poll
3379
+ * @param {Object} [options] Additional Telegram query options
3380
+ * @return {Promise} On success, the stopped [Poll](https://core.telegram.org/bots/api#poll) is returned
3381
+ * @see https://core.telegram.org/bots/api#stoppoll
3382
+ */
3383
+
3384
+ }, {
3385
+ key: 'stopPoll',
3386
+ value: function stopPoll(chatId, pollId) {
3387
+ var form = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
3388
+
3389
+ form.chat_id = chatId;
3390
+ form.message_id = pollId;
3391
+ return this._request('stopPoll', { form: form });
3392
+ }
3393
+
3394
+ /**
3395
+ * Use this method to send static .WEBP, [animated](https://telegram.org/blog/animated-stickers) .TGS,
3396
+ * or [video](https://telegram.org/blog/video-stickers-better-reactions) .WEBM stickers.
3397
+ * @param {Number|String} chatId Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
3398
+ * @param {String|stream.Stream|Buffer} sticker A file path, Stream or Buffer.
3399
+ * Can also be a `file_id` previously uploaded. Stickers are WebP format files.
3400
+ * @param {Object} [options] Additional Telegram query options
3401
+ * @param {Object} [fileOptions] Optional file related meta-data
3402
+ * @return {Promise} On success, the sent [Message](https://core.telegram.org/bots/api#message) is returned
3403
+ * @see https://core.telegram.org/bots/api#sendsticker
3404
+ */
3405
+
3406
+ }, {
3407
+ key: 'sendSticker',
3408
+ value: function sendSticker(chatId, sticker) {
3409
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
3410
+ var fileOptions = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
3411
+
3412
+ var opts = {
3413
+ qs: options
3414
+ };
3415
+ opts.qs.chat_id = chatId;
3416
+ try {
3417
+ var sendData = this._formatSendData('sticker', sticker, fileOptions);
3418
+ opts.formData = sendData[0];
3419
+ opts.qs.sticker = sendData[1];
3420
+ } catch (ex) {
3421
+ return Promise.reject(ex);
3422
+ }
3423
+ return this._request('sendSticker', opts);
3424
+ }
3425
+
3426
+ /**
3427
+ * Use this method to get a sticker set.
3428
+ *
3429
+ * @param {String} name Name of the sticker set
3430
+ * @param {Object} [options] Additional Telegram query options
3431
+ * @return {Promise} On success, a [StickerSet](https://core.telegram.org/bots/api#stickerset) object is returned
3432
+ * @see https://core.telegram.org/bots/api#getstickerset
3433
+ */
3434
+
3435
+ }, {
3436
+ key: 'getStickerSet',
3437
+ value: function getStickerSet(name) {
3438
+ var form = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3439
+
3440
+ form.name = name;
3441
+ return this._request('getStickerSet', { form: form });
3442
+ }
3443
+
3444
+ /**
3445
+ * Use this method to get information about custom emoji stickers by their identifiers.
3446
+ *
3447
+ * @param {Array} custom_emoji_ids List of custom emoji identifiers. At most 200 custom emoji identifiers can be specified.
3448
+ * @param {Object} [options] Additional Telegram query options
3449
+ * @return {Promise} Array of [Sticker](https://core.telegram.org/bots/api#sticker) objects.
3450
+ * @see https://core.telegram.org/bots/api#getcustomemojistickers
3451
+ */
3452
+
3453
+ }, {
3454
+ key: 'getCustomEmojiStickers',
3455
+ value: function getCustomEmojiStickers(customEmojiIds) {
3456
+ var form = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3457
+
3458
+ form.custom_emoji_ids = stringify(customEmojiIds);
3459
+ return this._request('getCustomEmojiStickers', { form: form });
3460
+ }
3461
+
3462
+ /**
3463
+ * Use this method to upload a file with a sticker for later use in *createNewStickerSet* and *addStickerToSet* methods (can be used multiple
3464
+ * times).
3465
+ *
3466
+ * @param {Number} userId User identifier of sticker file owner
3467
+ * @param {String|stream.Stream|Buffer} sticker A file path or a Stream with the sticker in .WEBP, .PNG, .TGS, or .WEBM format. Can also be a `file_id` previously uploaded.
3468
+ * @param {String} stickerFormat Allow values: `static`, `animated` or `video`
3469
+ * @param {Object} [options] Additional Telegram query options
3470
+ * @param {Object} [fileOptions] Optional file related meta-data
3471
+ * @return {Promise} On success, a [File](https://core.telegram.org/bots/api#file) object is returned
3472
+ * @see https://core.telegram.org/bots/api#uploadstickerfile
3473
+ */
3474
+
3475
+ }, {
3476
+ key: 'uploadStickerFile',
3477
+ value: function uploadStickerFile(userId, sticker) {
3478
+ var stickerFormat = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'static';
3479
+ var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
3480
+ var fileOptions = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
3481
+
3482
+ var opts = {
3483
+ qs: options
3484
+ };
3485
+ opts.qs.user_id = userId;
3486
+ opts.qs.sticker_format = stickerFormat;
3487
+
3488
+ try {
3489
+ var sendData = this._formatSendData('sticker', sticker, fileOptions);
3490
+ opts.formData = sendData[0];
3491
+ opts.qs.sticker = sendData[1];
3492
+ } catch (ex) {
3493
+ return Promise.reject(ex);
3494
+ }
3495
+ return this._request('uploadStickerFile', opts);
3496
+ }
3497
+
3498
+ /**
3499
+ * Use this method to create new sticker set owned by a user.
3500
+ *
3501
+ * The bot will be able to edit the created sticker set.
3502
+ *
3503
+ * You must use exactly one of the fields *png_sticker*, *tgs_sticker*, or *webm_sticker*
3504
+ *
3505
+ * @param {Number} userId User identifier of created sticker set owner
3506
+ * @param {String} 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.
3507
+ * 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.
3508
+ * @param {String} title Sticker set title, 1-64 characters
3509
+ * @param {String|stream.Stream|Buffer} pngSticker Png image with the sticker, must be up to 512 kilobytes in size,
3510
+ * dimensions must not exceed 512px, and either width or height must be exactly 512px.
3511
+ * @param {String} emojis One or more emoji corresponding to the sticker
3512
+ * @param {Object} [options] Additional Telegram query options
3513
+ * @param {Object} [fileOptions] Optional file related meta-data
3514
+ * @return {Promise} True on success
3515
+ * @see https://core.telegram.org/bots/api#createnewstickerset
3516
+ */
3517
+
3518
+ }, {
3519
+ key: 'createNewStickerSet',
3520
+ value: function createNewStickerSet(userId, name, title, pngSticker, emojis) {
3521
+ var options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
3522
+ var fileOptions = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : {};
3523
+
3524
+ var opts = {
3525
+ qs: options
3526
+ };
3527
+ opts.qs.user_id = userId;
3528
+ opts.qs.name = name;
3529
+ opts.qs.title = title;
3530
+ opts.qs.emojis = emojis;
3531
+ opts.qs.mask_position = stringify(options.mask_position);
3532
+ try {
3533
+ var sendData = this._formatSendData('png_sticker', pngSticker, fileOptions);
3534
+ opts.formData = sendData[0];
3535
+ opts.qs.png_sticker = sendData[1];
3536
+ } catch (ex) {
3537
+ return Promise.reject(ex);
3538
+ }
3539
+ return this._request('createNewStickerSet', opts);
3540
+ }
3541
+
3542
+ /**
3543
+ * Use this method to add a new sticker to a set created by the bot.
3544
+ *
3545
+ * You must use exactly one of the fields *png_sticker*, *tgs_sticker*, or *webm_sticker*
3546
+ *
3547
+ * Animated stickers can be added to animated sticker sets and only to them
3548
+ *
3549
+ * Note:
3550
+ * - Emoji sticker sets can have up to 200 sticker
3551
+ * - Static or Animated sticker sets can have up to 120 stickers
3552
+ *
3553
+ * @param {Number} userId User identifier of sticker set owner
3554
+ * @param {String} name Sticker set name
3555
+ * @param {String|stream.Stream|Buffer} sticker Png image with the sticker (must be up to 512 kilobytes in size,
3556
+ * dimensions must not exceed 512px, and either width or height must be exactly 512px, [TGS animation](https://core.telegram.org/stickers#animated-sticker-requirements)
3557
+ * with the sticker or [WEBM video](https://core.telegram.org/stickers#video-sticker-requirements) with the sticker.
3558
+ * @param {String} emojis One or more emoji corresponding to the sticker
3559
+ * @param {String} stickerType Allow values: `png_sticker`, `tgs_sticker`, or `webm_sticker`.
3560
+ * @param {Object} [options] Additional Telegram query options
3561
+ * @param {Object} [fileOptions] Optional file related meta-data
3562
+ * @return {Promise} True on success
3563
+ * @see https://core.telegram.org/bots/api#addstickertoset
3564
+ */
3565
+
3566
+ }, {
3567
+ key: 'addStickerToSet',
3568
+ value: function addStickerToSet(userId, name, sticker, emojis) {
3569
+ var stickerType = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 'png_sticker';
3570
+ var options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
3571
+ var fileOptions = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : {};
3572
+
3573
+ var opts = {
3574
+ qs: options
3575
+ };
3576
+ opts.qs.user_id = userId;
3577
+ opts.qs.name = name;
3578
+ opts.qs.emojis = emojis;
3579
+ opts.qs.mask_position = stringify(options.mask_position);
3580
+
3581
+ if (typeof stickerType !== 'string' || ['png_sticker', 'tgs_sticker', 'webm_sticker'].indexOf(stickerType) === -1) {
3582
+ return Promise.reject(new Error('stickerType must be a string and the allow types is: png_sticker, tgs_sticker, webm_sticker'));
3583
+ }
3584
+
3585
+ try {
3586
+ var sendData = this._formatSendData(stickerType, sticker, fileOptions);
3587
+ opts.formData = sendData[0];
3588
+ opts.qs[stickerType] = sendData[1];
3589
+ } catch (ex) {
3590
+ return Promise.reject(ex);
3591
+ }
3592
+ return this._request('addStickerToSet', opts);
3593
+ }
3594
+
3595
+ /**
3596
+ * Use this method to move a sticker in a set created by the bot to a specific position.
3597
+ *
3598
+ * @param {String} sticker File identifier of the sticker
3599
+ * @param {Number} position New sticker position in the set, zero-based
3600
+ * @param {Object} [options] Additional Telegram query options
3601
+ * @return {Promise} True on success
3602
+ * @see https://core.telegram.org/bots/api#setstickerpositioninset
3603
+ */
3604
+
3605
+ }, {
3606
+ key: 'setStickerPositionInSet',
3607
+ value: function setStickerPositionInSet(sticker, position) {
3608
+ var form = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
3609
+
3610
+ form.sticker = sticker;
3611
+ form.position = position;
3612
+ return this._request('setStickerPositionInSet', { form: form });
3613
+ }
3614
+
3615
+ /**
3616
+ * Use this method to delete a sticker from a set created by the bot.
3617
+ *
3618
+ * @param {String} sticker File identifier of the sticker
3619
+ * @param {Object} [options] Additional Telegram query options
3620
+ * @return {Promise} True on success
3621
+ * @see https://core.telegram.org/bots/api#deletestickerfromset
3622
+ * @todo Add tests for this method!
3623
+ */
3624
+
3625
+ }, {
3626
+ key: 'deleteStickerFromSet',
3627
+ value: function deleteStickerFromSet(sticker) {
3628
+ var form = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3629
+
3630
+ form.sticker = sticker;
3631
+ return this._request('deleteStickerFromSet', { form: form });
3632
+ }
3633
+
3634
+ /**
3635
+ * Use this method to replace an existing sticker in a sticker set with a new one
3636
+ *
3637
+ * @param {Number} user_id User identifier of the sticker set owner
3638
+ * @param {String} name Sticker set name
3639
+ * @param {String} sticker File identifier of the sticker
3640
+ * @param {Object} [options] Additional Telegram query options
3641
+ * @return {Promise} True on success
3642
+ * @see https://core.telegram.org/bots/api#replacestickerinset
3643
+ * @todo Add tests for this method!
3644
+ */
3645
+
3646
+ }, {
3647
+ key: 'replaceStickerInSet',
3648
+ value: function replaceStickerInSet(userId, name, oldSticker) {
3649
+ var form = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
3650
+
3651
+ form.user_id = userId;
3652
+ form.name = name;
3653
+ form.old_sticker = oldSticker;
3654
+ return this._request('deleteStickerFromSet', { form: form });
3655
+ }
3656
+
3657
+ /**
3658
+ * Use this method to change the list of emoji assigned to a regular or custom emoji sticker.
3659
+ *
3660
+ * The sticker must belong to a sticker set created by the bot.
3661
+ *
3662
+ * @param {String} sticker File identifier of the sticker
3663
+ * @param { Array } emojiList A JSON-serialized list of 1-20 emoji associated with the sticker
3664
+ * @param {Object} [options] Additional Telegram query options
3665
+ * @return {Promise} True on success
3666
+ * @see https://core.telegram.org/bots/api#setstickeremojilist
3667
+ */
3668
+
3669
+ }, {
3670
+ key: 'setStickerEmojiList',
3671
+ value: function setStickerEmojiList(sticker, emojiList) {
3672
+ var form = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
3673
+
3674
+ form.sticker = sticker;
3675
+ form.emoji_list = stringify(emojiList);
3676
+ return this._request('setStickerEmojiList', { form: form });
3677
+ }
3678
+
3679
+ /**
3680
+ * Use this method to change the list of emoji assigned to a `regular` or `custom emoji` sticker.
3681
+ *
3682
+ * The sticker must belong to a sticker set created by the bot.
3683
+ *
3684
+ * @param {String} sticker File identifier of the sticker
3685
+ * @param {Object} [options] Additional Telegram query options
3686
+ * @return {Promise} True on success
3687
+ * @see https://core.telegram.org/bots/api#setstickerkeywords
3688
+ */
3689
+
3690
+ }, {
3691
+ key: 'setStickerKeywords',
3692
+ value: function setStickerKeywords(sticker) {
3693
+ var form = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3694
+
3695
+ form.sticker = sticker;
3696
+ if (form.keywords) {
3697
+ form.keywords = stringify(form.keywords);
3698
+ }
3699
+ return this._request('setStickerKeywords', { form: form });
3700
+ }
3701
+
3702
+ /**
3703
+ * Use this method to change the [mask position](https://core.telegram.org/bots/api#maskposition) of a mask sticker.
3704
+ *
3705
+ * The sticker must belong to a sticker set created by the bot.
3706
+ *
3707
+ * @param {String} sticker File identifier of the sticker
3708
+ * @param {Object} [options] Additional Telegram query options
3709
+ * @return {Promise} True on success
3710
+ * @see https://core.telegram.org/bots/api#setstickermaskposition
3711
+ */
3712
+
3713
+ }, {
3714
+ key: 'setStickerMaskPosition',
3715
+ value: function setStickerMaskPosition(sticker) {
3716
+ var form = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3717
+
3718
+ form.sticker = sticker;
3719
+ if (form.mask_position) {
3720
+ form.mask_position = stringify(form.mask_position);
3721
+ }
3722
+ return this._request('setStickerMaskPosition', { form: form });
3723
+ }
3724
+
3725
+ /**
3726
+ * Use this method to set the title of a created sticker set.
3727
+ *
3728
+ * The sticker must belong to a sticker set created by the bot.
3729
+ *
3730
+ * @param {String} name Sticker set name
3731
+ * @param {String} title Sticker set title, 1-64 characters
3732
+ * @param {Object} [options] Additional Telegram query options
3733
+ * @return {Promise} True on success
3734
+ * @see https://core.telegram.org/bots/api#setstickersettitle
3735
+ */
3736
+
3737
+ }, {
3738
+ key: 'setStickerSetTitle',
3739
+ value: function setStickerSetTitle(name, title) {
3740
+ var form = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
3741
+
3742
+ form.name = name;
3743
+ form.title = title;
3744
+ return this._request('setStickerSetTitle', { form: form });
3745
+ }
3746
+
3747
+ /**
3748
+ * Use this method to add a thumb to a set created by the bot.
3749
+ *
3750
+ * Animated thumbnails can be set for animated sticker sets only. Video thumbnails can be set only for video sticker sets only
3751
+ *
3752
+ * @param {Number} userId User identifier of sticker set owner
3753
+ * @param {String} name Sticker set name
3754
+ * @param {String|stream.Stream|Buffer} thumbnail A .WEBP or .PNG image with the thumbnail,
3755
+ * must be up to 128 kilobytes in size and have width and height exactly 100px,
3756
+ * a TGS animation with the thumbnail up to 32 kilobytes in size or a WEBM video with the thumbnail up to 32 kilobytes in size.
3757
+ *
3758
+ * Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram
3759
+ * to get a file from the Internet, or upload a new one. Animated sticker set thumbnails can't be uploaded via HTTP URL.
3760
+ * @param {Object} [options] Additional Telegram query options
3761
+ * @param {Object} [fileOptions] Optional file related meta-data
3762
+ * @return {Promise} True on success
3763
+ * @see https://core.telegram.org/bots/api#setstickersetthumbnail
3764
+ */
3765
+
3766
+ }, {
3767
+ key: 'setStickerSetThumbnail',
3768
+ value: function setStickerSetThumbnail(userId, name, thumbnail) {
3769
+ var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
3770
+ var fileOptions = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
3771
+
3772
+ var opts = {
3773
+ qs: options
3774
+ };
3775
+ opts.qs.user_id = userId;
3776
+ opts.qs.name = name;
3777
+ opts.qs.mask_position = stringify(options.mask_position);
3778
+ try {
3779
+ var sendData = this._formatSendData('thumbnail', thumbnail, fileOptions);
3780
+ opts.formData = sendData[0];
3781
+ opts.qs.thumbnail = sendData[1];
3782
+ } catch (ex) {
3783
+ return Promise.reject(ex);
3784
+ }
3785
+ return this._request('setStickerSetThumbnail', opts);
3786
+ }
3787
+
3788
+ /**
3789
+ * Use this method to set the thumbnail of a custom emoji sticker set.
3790
+ *
3791
+ * The sticker must belong to a sticker set created by the bot.
3792
+ *
3793
+ * @param {String} name Sticker set name
3794
+ * @param {Object} [options] Additional Telegram query options
3795
+ * @return {Promise} True on success
3796
+ * @see https://core.telegram.org/bots/api#setcustomemojistickersetthumbnail
3797
+ */
3798
+
3799
+ }, {
3800
+ key: 'setCustomEmojiStickerSetThumbnail',
3801
+ value: function setCustomEmojiStickerSetThumbnail(name) {
3802
+ var form = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3803
+
3804
+ form.name = name;
3805
+ return this._request('setCustomEmojiStickerSetThumbnail', { form: form });
3806
+ }
3807
+
3808
+ /**
3809
+ * Use this method to delete a sticker set that was created by the bot.
3810
+ *
3811
+ * The sticker must belong to a sticker set created by the bot.
3812
+ *
3813
+ * @param {String} name Sticker set name
3814
+ * @param {Object} [options] Additional Telegram query options
3815
+ * @return {Promise} True on success
3816
+ * @see https://core.telegram.org/bots/api#deletestickerset
3817
+ */
3818
+
3819
+ }, {
3820
+ key: 'deleteStickerSet',
3821
+ value: function deleteStickerSet(name) {
3822
+ var form = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3823
+
3824
+ form.name = name;
3825
+ return this._request('deleteStickerSet', { form: form });
3826
+ }
3827
+
3828
+ /**
3829
+ * Send answers to an inline query.
3830
+ *
3831
+ * Note: No more than 50 results per query are allowed.
3832
+ *
3833
+ * @param {String} inlineQueryId Unique identifier of the query
3834
+ * @param {InlineQueryResult[]} results An array of results for the inline query
3835
+ * @param {Object} [options] Additional Telegram query options
3836
+ * @return {Promise} On success, True is returned
3837
+ * @see https://core.telegram.org/bots/api#answerinlinequery
3838
+ */
3839
+
3840
+ }, {
3841
+ key: 'answerInlineQuery',
3842
+ value: function answerInlineQuery(inlineQueryId, results) {
3843
+ var form = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
3844
+
3845
+ form.inline_query_id = inlineQueryId;
3846
+ form.results = stringify(results);
3847
+ return this._request('answerInlineQuery', { form: form });
3848
+ }
3849
+
3850
+ /**
3851
+ * Use this method to set the result of an interaction with a [Web App](https://core.telegram.org/bots/webapps)
3852
+ * and send a corresponding message on behalf of the user to the chat from which the query originated.
3853
+ *
3854
+ * @param {String} webAppQueryId Unique identifier for the query to be answered
3855
+ * @param {InlineQueryResult} result object that represents one result of an inline query
3856
+ * @param {Object} [options] Additional Telegram query options
3857
+ * @return {Promise} On success, a [SentWebAppMessage](https://core.telegram.org/bots/api#sentwebappmessage) object is returned
3858
+ * @see https://core.telegram.org/bots/api#answerwebappquery
3859
+ */
3860
+
3861
+ }, {
3862
+ key: 'answerWebAppQuery',
3863
+ value: function answerWebAppQuery(webAppQueryId, result) {
3864
+ var form = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
3865
+
3866
+ form.web_app_query_id = webAppQueryId;
3867
+ form.result = stringify(result);
3868
+ return this._request('answerWebAppQuery', { form: form });
3869
+ }
3870
+
3871
+ /**
3872
+ * Use this method to send an invoice.
3873
+ *
3874
+ * @param {Number|String} chatId Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
3875
+ * @param {String} title Product name, 1-32 characters
3876
+ * @param {String} description Product description, 1-255 characters
3877
+ * @param {String} payload Bot defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes.
3878
+ * @param {String} providerToken Payments provider token, obtained via `@BotFather`
3879
+ * @param {String} currency Three-letter ISO 4217 currency code
3880
+ * @param {Array} prices Breakdown of prices
3881
+ * @param {Object} [options] Additional Telegram query options
3882
+ * @return {Promise} On success, the sent [Message](https://core.telegram.org/bots/api#message) is returned
3883
+ * @see https://core.telegram.org/bots/api#sendinvoice
3884
+ */
3885
+
3886
+ }, {
3887
+ key: 'sendInvoice',
3888
+ value: function sendInvoice(chatId, title, description, payload, providerToken, currency, prices) {
3889
+ var form = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : {};
3890
+
3891
+ form.chat_id = chatId;
3892
+ form.title = title;
3893
+ form.description = description;
3894
+ form.payload = payload;
3895
+ form.provider_token = providerToken;
3896
+ form.currency = currency;
3897
+ form.prices = stringify(prices);
3898
+ form.provider_data = stringify(form.provider_data);
3899
+ if (form.suggested_tip_amounts) {
3900
+ form.suggested_tip_amounts = stringify(form.suggested_tip_amounts);
3901
+ }
3902
+ return this._request('sendInvoice', { form: form });
3903
+ }
3904
+
3905
+ /**
3906
+ * Use this method to create a link for an invoice.
3907
+ *
3908
+ * @param {String} title Product name, 1-32 characters
3909
+ * @param {String} description Product description, 1-255 characters
3910
+ * @param {String} payload Bot defined invoice payload
3911
+ * @param {String} providerToken Payment provider token
3912
+ * @param {String} currency Three-letter ISO 4217 currency code
3913
+ * @param {Array} prices Breakdown of prices
3914
+ * @param {Object} [options] Additional Telegram query options
3915
+ * @returns {Promise} The created invoice link as String on success.
3916
+ * @see https://core.telegram.org/bots/api#createinvoicelink
3917
+ */
3918
+
3919
+ }, {
3920
+ key: 'createInvoiceLink',
3921
+ value: function createInvoiceLink(title, description, payload, providerToken, currency, prices) {
3922
+ var form = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : {};
3923
+
3924
+ form.title = title;
3925
+ form.description = description;
3926
+ form.payload = payload;
3927
+ form.provider_token = providerToken;
3928
+ form.currency = currency;
3929
+ form.prices = stringify(prices);
3930
+ return this._request('createInvoiceLink', { form: form });
3931
+ }
3932
+
3933
+ /**
3934
+ * Use this method to reply to shipping queries.
3935
+ *
3936
+ * If you sent an invoice requesting a shipping address and the parameter is_flexible was specified,
3937
+ * the Bot API will send an [Update](https://core.telegram.org/bots/api#update) with a shipping_query field to the bot
3938
+ *
3939
+ * @param {String} shippingQueryId Unique identifier for the query to be answered
3940
+ * @param {Boolean} ok Specify if delivery of the product is possible
3941
+ * @param {Object} [options] Additional Telegram query options
3942
+ * @return {Promise} On success, True is returned
3943
+ * @see https://core.telegram.org/bots/api#answershippingquery
3944
+ */
3945
+
3946
+ }, {
3947
+ key: 'answerShippingQuery',
3948
+ value: function answerShippingQuery(shippingQueryId, ok) {
3949
+ var form = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
3950
+
3951
+ form.shipping_query_id = shippingQueryId;
3952
+ form.ok = ok;
3953
+ form.shipping_options = stringify(form.shipping_options);
3954
+ return this._request('answerShippingQuery', { form: form });
3955
+ }
3956
+
3957
+ /**
3958
+ * Use this method to respond to such pre-checkout queries
3959
+ *
3960
+ * Once the user has confirmed their payment and shipping details, the Bot API sends the final confirmation in the form of
3961
+ * an [Update](https://core.telegram.org/bots/api#update) with the field *pre_checkout_query*.
3962
+ *
3963
+ * **Note:** The Bot API must receive an answer within 10 seconds after the pre-checkout query was sent.
3964
+ *
3965
+ * @param {String} preCheckoutQueryId Unique identifier for the query to be answered
3966
+ * @param {Boolean} ok Specify if every order details are ok
3967
+ * @param {Object} [options] Additional Telegram query options
3968
+ * @return {Promise} On success, True is returned
3969
+ * @see https://core.telegram.org/bots/api#answerprecheckoutquery
3970
+ */
3971
+
3972
+ }, {
3973
+ key: 'answerPreCheckoutQuery',
3974
+ value: function answerPreCheckoutQuery(preCheckoutQueryId, ok) {
3975
+ var form = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
3976
+
3977
+ form.pre_checkout_query_id = preCheckoutQueryId;
3978
+ form.ok = ok;
3979
+ return this._request('answerPreCheckoutQuery', { form: form });
3980
+ }
3981
+
3982
+ /**
3983
+ * Use this method to get the current Telegram Stars balance of the bot.
3984
+ *
3985
+ * @param {Object} [options] Additional Telegram query options
3986
+ * @return {Promise} On success, returns a [StarAmount](https://core.telegram.org/bots/api#staramount) object
3987
+ * @see https://core.telegram.org/bots/api#getmystarbalance
3988
+ */
3989
+
3990
+ }, {
3991
+ key: 'getMyStarBalance',
3992
+ value: function getMyStarBalance() {
3993
+ var form = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3994
+
3995
+ return this._request('getMyStarBalance', { form: form });
3996
+ }
3997
+
3998
+ /**
3999
+ * Use this method for get the bot's Telegram Star transactions in chronological order
4000
+ *
4001
+ * @param {Object} [options] Additional Telegram query options
4002
+ * @return {Promise} On success, returns a [StarTransactions](https://core.telegram.org/bots/api#startransactions) object
4003
+ * @see https://core.telegram.org/bots/api#getstartransactions
4004
+ */
4005
+
4006
+ }, {
4007
+ key: 'getStarTransactions',
4008
+ value: function getStarTransactions() {
4009
+ var form = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4010
+
4011
+ return this._request('getStarTransactions', { form: form });
4012
+ }
4013
+
4014
+ /**
4015
+ * Use this method for refund a successful payment in [Telegram Stars](https://t.me/BotNews/90)
4016
+ *
4017
+ * @param {Number} userId Unique identifier of the user whose payment will be refunded
4018
+ * @param {String} telegramPaymentChargeId Telegram payment identifier
4019
+ * @param {Object} [options] Additional Telegram query options
4020
+ * @return {Promise} On success, True is returned
4021
+ * @see https://core.telegram.org/bots/api#refundstarpayment
4022
+ */
4023
+
4024
+ }, {
4025
+ key: 'refundStarPayment',
4026
+ value: function refundStarPayment(userId, telegramPaymentChargeId) {
4027
+ var form = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
4028
+
4029
+ form.user_id = userId;
4030
+ form.telegram_payment_charge_id = telegramPaymentChargeId;
4031
+ return this._request('refundStarPayment', { form: form });
4032
+ }
4033
+
4034
+ /**
4035
+ * Allows the bot to cancel or re-enable extension of a subscription paid in Telegram Stars.
4036
+ *
4037
+ * @param {Number} userId Unique identifier of the user whose subscription will be canceled or re-enabled
4038
+ * @param {String} telegramPaymentChargeId Telegram payment identifier for the subscription
4039
+ * @param {Boolean} isCanceled True, if the subscription should be canceled, False, if it should be re-enabled
4040
+ * @param {Object} [options] Additional Telegram query options
4041
+ * @return {Promise} On success, True is returned
4042
+ * @see https://core.telegram.org/bots/api#cancelrenewsubscription
4043
+ */
4044
+
4045
+ }, {
4046
+ key: 'editUserStarSubscription',
4047
+ value: function editUserStarSubscription(userId, telegramPaymentChargeId, isCanceled) {
4048
+ var form = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
4049
+
4050
+ form.user_id = userId;
4051
+ form.telegram_payment_charge_id = telegramPaymentChargeId;
4052
+ form.is_canceled = isCanceled;
4053
+ return this._request('editUserStarSubscription', { form: form });
4054
+ }
4055
+
4056
+ /**
4057
+ * Use this method to send a game.
4058
+ *
4059
+ * @param {Number|String} chatId Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
4060
+ * @param {String} gameShortName name of the game to be sent. Set up your games via `@BotFather`.
4061
+ * @param {Object} [options] Additional Telegram query options
4062
+ * @return {Promise} On success, the sent [Message](https://core.telegram.org/bots/api#message) is returned
4063
+ * @see https://core.telegram.org/bots/api#sendgame
4064
+ */
4065
+
4066
+ }, {
4067
+ key: 'sendGame',
4068
+ value: function sendGame(chatId, gameShortName) {
4069
+ var form = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
4070
+
4071
+ form.chat_id = chatId;
4072
+ form.game_short_name = gameShortName;
4073
+ return this._request('sendGame', { form: form });
4074
+ }
4075
+
4076
+ /**
4077
+ * Use this method to set the score of the specified user in a game message.
4078
+ *
4079
+ * @param {Number} userId Unique identifier of the target user
4080
+ * @param {Number} score New score value, must be non-negative
4081
+ * @param {Object} [options] Additional Telegram query options
4082
+ * @return {Promise} On success, if the message is not an inline message, the [Message](https://core.telegram.org/bots/api#message) is returned, otherwise True is returned
4083
+ * @see https://core.telegram.org/bots/api#setgamescore
4084
+ */
4085
+
4086
+ }, {
4087
+ key: 'setGameScore',
4088
+ value: function setGameScore(userId, score) {
4089
+ var form = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
4090
+
4091
+ form.user_id = userId;
4092
+ form.score = score;
4093
+ return this._request('setGameScore', { form: form });
4094
+ }
4095
+
4096
+ /**
4097
+ * Use this method to get data for high score tables.
4098
+ *
4099
+ * Will return the score of the specified user and several of their neighbors in a game.
4100
+ *
4101
+ * @param {Number} userId Unique identifier of the target user
4102
+ * @param {Object} [options] Additional Telegram query options
4103
+ * @return {Promise} On success, returns an Array of [GameHighScore](https://core.telegram.org/bots/api#gamehighscore) objects
4104
+ * @see https://core.telegram.org/bots/api#getgamehighscores
4105
+ */
4106
+
4107
+ }, {
4108
+ key: 'getGameHighScores',
4109
+ value: function getGameHighScores(userId) {
4110
+ var form = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
4111
+
4112
+ form.user_id = userId;
4113
+ return this._request('getGameHighScores', { form: form });
4114
+ }
4115
+
4116
+ /**
4117
+ * Use this method to delete a message, including service messages, with the following limitations:
4118
+ * - A message can only be deleted if it was sent less than 48 hours ago.
4119
+ * - A dice message can only be deleted if it was sent more than 24 hours ago.
4120
+ * - Bots can delete outgoing messages in groups and supergroups.
4121
+ * - Bots can delete incoming messages in groups, supergroups and channels.
4122
+ * - Bots granted `can_post_messages` permissions can delete outgoing messages in channels.
4123
+ * - If the bot is an administrator of a group, it can delete any message there.
4124
+ * - If the bot has `can_delete_messages` permission in a supergroup, it can delete any message there.
4125
+ *
4126
+ * @param {Number|String} chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
4127
+ * @param {Number} messageId Unique identifier of the target message
4128
+ * @param {Object} [options] Additional Telegram query options
4129
+ * @return {Promise} True on success
4130
+ * @see https://core.telegram.org/bots/api#deletemessage
4131
+ */
4132
+
4133
+ }, {
4134
+ key: 'deleteMessage',
4135
+ value: function deleteMessage(chatId, messageId) {
4136
+ var form = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
4137
+
4138
+ form.chat_id = chatId;
4139
+ form.message_id = messageId;
4140
+ return this._request('deleteMessage', { form: form });
4141
+ }
4142
+
4143
+ /**
4144
+ * Use this method to delete multiple messages simultaneously. If some of the specified messages can't be found, they are skipped.
4145
+ *
4146
+ * @param {Number|String} chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
4147
+ * @param {Array<Number|String>} messageIds Identifiers of 1-100 messages to delete. See deleteMessage for limitations on which messages can be deleted
4148
+ * @param {Object} [options] Additional Telegram query options
4149
+ * @return {Promise<Boolean>} True on success
4150
+ * @see https://core.telegram.org/bots/api#deletemessages
4151
+ */
4152
+
4153
+ }, {
4154
+ key: 'deleteMessages',
4155
+ value: function deleteMessages(chatId, messageIds) {
4156
+ var form = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
4157
+
4158
+ form.chat_id = chatId;
4159
+ form.message_ids = stringify(messageIds);
4160
+ return this._request('deleteMessages', { form: form });
4161
+ }
4162
+
4163
+ /**
4164
+ * Use this method to returns the list of gifts that can be sent by the bot to users and channel chats.
4165
+ *
4166
+ * @param {Object} [options] Additional Telegram query options.
4167
+ * @return {Promise} On success, returns a [Gifts](https://core.telegram.org/bots/api#gifts) objects.
4168
+ * @see https://core.telegram.org/bots/api#getavailablegifts
4169
+ */
4170
+
4171
+ }, {
4172
+ key: 'getAvailableGifts',
4173
+ value: function getAvailableGifts() {
4174
+ var form = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4175
+
4176
+ return this._request('getAvailableGifts', { form: form });
4177
+ }
4178
+
4179
+ /**
4180
+ * Use this method to sends a gift to the given user or channel chat.
4181
+ *
4182
+ * @param {String} giftId Unique identifier of the gift
4183
+ * @param {Object} [options] Additional Telegram query options.
4184
+ * @return {Promise} On success, returns true.
4185
+ * @see https://core.telegram.org/bots/api#getavailablegifts
4186
+ */
4187
+
4188
+ }, {
4189
+ key: 'sendGift',
4190
+ value: function sendGift(giftId) {
4191
+ var form = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
4192
+
4193
+ form.gift_id = giftId;
4194
+ return this._request('sendGift', { form: form });
4195
+ }
4196
+
4197
+ /**
4198
+ * Use this method to sends a gift to the given user or channel chat.
4199
+ *
4200
+ * @param {Number} userId Unique identifier of the target user who will receive a Telegram Premium subscription.
4201
+ * @param {Number} monthCount Number of months the Telegram Premium subscription will be active for the user; must be one of 3, 6, or 12.
4202
+ * @param {String} starCount Number of Telegram Stars to pay for the Telegram Premium subscription; must be 1000 for 3 months, 1500 for 6 months, and 2500 for 12 months.
4203
+ * @param {Object} [options] Additional Telegram query options.
4204
+ * @return {Promise} On success, returns true.
4205
+ * @see https://core.telegram.org/bots/api#getavailablegifts
4206
+ */
4207
+
4208
+ }, {
4209
+ key: 'giftPremiumSubscription',
4210
+ value: function giftPremiumSubscription(userId, monthCount, starCount) {
4211
+ var form = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
4212
+
4213
+ form.user_id = userId;
4214
+ form.month_count = monthCount;
4215
+ form.star_count = starCount;
4216
+ return this._request('giftPremiumSubscription', { form: form });
4217
+ }
4218
+
4219
+ /**
4220
+ * This method verifies a user [on behalf of the organization](https://telegram.org/verify#third-party-verification) which is represented by the bot.
4221
+ *
4222
+ * @param {Number} userId Unique identifier of the target user.
4223
+ * @param {Object} [options] Additional Telegram query options.
4224
+ * @return {Promise} On success, returns true.
4225
+ * @see https://core.telegram.org/bots/api#verifyuser
4226
+ */
4227
+
4228
+ }, {
4229
+ key: 'verifyUser',
4230
+ value: function verifyUser(userId) {
4231
+ var form = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
4232
+
4233
+ form.user_id = userId;
4234
+ return this._request('verifyUser', { form: form });
4235
+ }
4236
+
4237
+ /**
4238
+ * This method verifies a chat [on behalf of the organization](https://telegram.org/verify#third-party-verification) which is represented by the bot.
4239
+ *
4240
+ * @param {Number} chatId Unique identifier of the target chat.
4241
+ * @return {Promise} On success, returns true.
4242
+ * @param {Object} [options] Additional Telegram query options.
4243
+ * @see https://core.telegram.org/bots/api#verifychat
4244
+ */
4245
+
4246
+ }, {
4247
+ key: 'verifyChat',
4248
+ value: function verifyChat(chatId) {
4249
+ var form = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
4250
+
4251
+ form.chat_id = chatId;
4252
+ return this._request('verifyChat', { form: form });
4253
+ }
4254
+
4255
+ /**
4256
+ * This method removes verification from a user who is currently verified [on behalf of the organization](https://telegram.org/verify#third-party-verification) which is represented by the bot.
4257
+ *
4258
+ * @param {Number} userId Unique identifier of the target user
4259
+ * @param {Object} [options] Additional Telegram query options
4260
+ * @return {Promise} On success, returns true.
4261
+ * @see https://core.telegram.org/bots/api#removeuserverification
4262
+ */
4263
+
4264
+ }, {
4265
+ key: 'removeUserVerification',
4266
+ value: function removeUserVerification(userId) {
4267
+ var form = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
4268
+
4269
+ form.user_id = userId;
4270
+ return this._request('removeUserVerification', { form: form });
4271
+ }
4272
+
4273
+ /**
4274
+ * This method removes verification from a chat who is currently verified [on behalf of the organization](https://telegram.org/verify#third-party-verification) which is represented by the bot.
4275
+ *
4276
+ * @param {Number} chatId Unique identifier of the target chat.
4277
+ * @param {Object} [options] Additional Telegram query options.
4278
+ * @return {Promise} On success, returns true.
4279
+ * @see https://core.telegram.org/bots/api#removechatverification
4280
+ */
4281
+
4282
+ }, {
4283
+ key: 'removeChatVerification',
4284
+ value: function removeChatVerification(chatId) {
4285
+ var form = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
4286
+
4287
+ form.chat_id = chatId;
4288
+ return this._request('removeChatVerification', { form: form });
4289
+ }
4290
+
4291
+ /**
4292
+ * This method marks incoming message as read on behalf of a business account.
4293
+ *
4294
+ * Requires the **can_read_messages** business bot right
4295
+ *
4296
+ * @param {String} businessConnectionId Unique identifier of the business connection on behalf of which to read the message.
4297
+ * @param {Number} chatId Unique identifier of the chat in which the message was received. The chat must have been active in the last 24 hours.
4298
+ * @param {Number} messageId Unique identifier of the message to mark as read.
4299
+ * @param {Object} [options] Additional Telegram query options
4300
+ * @return {Promise} On success, returns true.
4301
+ * @see https://core.telegram.org/bots/api#readbusinessmessage
4302
+ */
4303
+
4304
+ }, {
4305
+ key: 'readBusinessMessage',
4306
+ value: function readBusinessMessage(businessConnectionId, chatId, messageId) {
4307
+ var form = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
4308
+
4309
+ form.business_connection_id = businessConnectionId;
4310
+ form.chat_id = chatId;
4311
+ form.message_id = messageId;
4312
+ return this._request('readBusinessMessage', { form: form });
4313
+ }
4314
+
4315
+ /**
4316
+ * This method delete messages on behalf of a business account.
4317
+ *
4318
+ * Requires the **can_delete_outgoing_messages** business bot right to delete messages sent by the bot itself, or the **can_delete_all_messages business** bot right to delete any message.
4319
+ *
4320
+ * @param {String} businessConnectionId Unique identifier of the business connection on behalf of which to delete the message.
4321
+ * @param {Number[]} messageIds List of 1-100 identifiers of messages to delete. All messages **must be from the same chat**.
4322
+ * @param {Object} [options] Additional Telegram query options.
4323
+ * @return {Promise} On success, returns true.
4324
+ * @see https://core.telegram.org/bots/api#deletebusinessmessages
4325
+ */
4326
+
4327
+ }, {
4328
+ key: 'deleteBusinessMessages',
4329
+ value: function deleteBusinessMessages(businessConnectionId, messageIds) {
4330
+ var form = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
4331
+
4332
+ form.business_connection_id = businessConnectionId;
4333
+ form.message_ids = stringify(messageIds);
4334
+ return this._request('deleteBusinessMessages', { form: form });
4335
+ }
4336
+
4337
+ /**
4338
+ * This method changes the first and last name of a managed business account.
4339
+ *
4340
+ * Requires the **can_change_name** business bot right.
4341
+ *
4342
+ * @param {String} businessConnectionId Unique identifier of the business connection.
4343
+ * @param {String} firstName The new value of the first name for the business account; 1-64 characters.
4344
+ * @param {Object} [options] Additional Telegram query options
4345
+ * @return {Promise} On success, returns true.
4346
+ * @see https://core.telegram.org/bots/api#setbusinessaccountname
4347
+ */
4348
+
4349
+ }, {
4350
+ key: 'setBusinessAccountName',
4351
+ value: function setBusinessAccountName(businessConnectionId, firstName) {
4352
+ var form = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
4353
+
4354
+ form.business_connection_id = businessConnectionId;
4355
+ form.first_name = firstName;
4356
+ return this._request('setBusinessAccountName', { form: form });
4357
+ }
4358
+
4359
+ /**
4360
+ * This method changes the username of a managed business account.
4361
+ *
4362
+ * Requires the **can_change_username** business bot right.
4363
+ *
4364
+ * @param {String} businessConnectionId Unique identifier of the business connection.
4365
+ * @param {Object} [options] Additional Telegram query options
4366
+ * @return {Promise} On success, returns true.
4367
+ * @see https://core.telegram.org/bots/api#setbusinessaccountusername
4368
+ */
4369
+
4370
+ }, {
4371
+ key: 'setBusinessAccountUsername',
4372
+ value: function setBusinessAccountUsername(businessConnectionId) {
4373
+ var form = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
4374
+
4375
+ form.business_connection_id = businessConnectionId;
4376
+ return this._request('setBusinessAccountUsername', { form: form });
4377
+ }
4378
+
4379
+ /**
4380
+ * This method changes the bio of a managed business account.
4381
+ *
4382
+ * Requires the **can_change_bio** business bot right.
4383
+ *
4384
+ * @param {String} businessConnectionId Unique identifier of the business connection.
4385
+ * @param {Object} [options] Additional Telegram query options
4386
+ * @return {Promise} On success, returns true.
4387
+ * @see https://core.telegram.org/bots/api#setbusinessaccountbio
4388
+ */
4389
+
4390
+ }, {
4391
+ key: 'setBusinessAccountBio',
4392
+ value: function setBusinessAccountBio(businessConnectionId) {
4393
+ var form = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
4394
+
4395
+ form.business_connection_id = businessConnectionId;
4396
+ return this._request('setBusinessAccountBio', { form: form });
4397
+ }
4398
+
4399
+ /**
4400
+ * This method changes the profile photo of a managed business account.
4401
+ *
4402
+ * Requires the **can_edit_profile_photo** business bot right.
4403
+ *
4404
+ * @param {String} businessConnectionId Unique identifier of the business connection.
4405
+ * @param {String|stream.Stream|Buffer} photo New profile photo.
4406
+ * @param {Object} [options] Additional Telegram query options
4407
+ * @return {Promise} On success, returns true.
4408
+ * @see https://core.telegram.org/bots/api#setbusinessaccountprofilephoto
4409
+ */
4410
+
4411
+ }, {
4412
+ key: 'setBusinessAccountProfilePhoto',
4413
+ value: function setBusinessAccountProfilePhoto(businessConnectionId, photo) {
4414
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
4415
+
4416
+ var opts = {
4417
+ qs: options
4418
+ };
4419
+
4420
+ opts.qs.business_connection_id = businessConnectionId;
4421
+
4422
+ try {
4423
+ var sendData = this._formatSendData('photo', photo);
4424
+ opts.formData = sendData[0];
4425
+ opts.qs.photo = sendData[1];
4426
+ } catch (ex) {
4427
+ return Promise.reject(ex);
4428
+ }
4429
+
4430
+ return this._request('setBusinessAccountProfilePhoto', opts);
4431
+ }
4432
+
4433
+ /**
4434
+ * This method removes the current profile photo of a managed business account.
4435
+ *
4436
+ * Requires the **can_edit_profile_photo** business bot right.
4437
+ *
4438
+ * @param {String} businessConnectionId Unique identifier of the business connection.
4439
+ * @param {Object} [options] Additional Telegram query options
4440
+ * @return {Promise} On success, returns true.
4441
+ * @see https://core.telegram.org/bots/api#removebusinessaccountprofilephoto
4442
+ */
4443
+
4444
+ }, {
4445
+ key: 'removeBusinessAccountProfilePhoto',
4446
+ value: function removeBusinessAccountProfilePhoto(businessConnectionId) {
4447
+ var form = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
4448
+
4449
+ form.business_connection_id = businessConnectionId;
4450
+ return this._request('removeBusinessAccountProfilePhoto', { form: form });
4451
+ }
4452
+
4453
+ /**
4454
+ * This method changes the privacy settings pertaining to incoming gifts in a managed business account.
4455
+ *
4456
+ * Requires the **can_change_gift_settings** business bot right.
4457
+ *
4458
+ * @param {String} businessConnectionId Unique identifier of the business connection.
4459
+ * @param {Boolean} showGiftButton Pass True, if a button for sending a gift to the user or by the business account must always be shown in the input field.
4460
+ * @param {Object} acceptedGiftTypes Types of gifts accepted by the business account.
4461
+ * @param {Object} [options] Additional Telegram query options
4462
+ * @return {Promise} On success, returns true.
4463
+ * @see https://core.telegram.org/bots/api#setbusinessaccountgiftsettings
4464
+ */
4465
+
4466
+ }, {
4467
+ key: 'setBusinessAccountGiftSettings',
4468
+ value: function setBusinessAccountGiftSettings(businessConnectionId, showGiftButton, acceptedGiftTypes) {
4469
+ var form = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
4470
+
4471
+ form.business_connection_id = businessConnectionId;
4472
+ form.show_gift_button = showGiftButton;
4473
+ form.accepted_gift_types = acceptedGiftTypes;
4474
+ return this._request('setBusinessAccountGiftSettings', { form: form });
4475
+ }
4476
+
4477
+ /**
4478
+ * This method returns the amount of Telegram Stars owned by a managed business account.
4479
+ *
4480
+ * Requires the **can_view_gifts_and_stars** business bot right.
4481
+ *
4482
+ * @param {String} businessConnectionId Unique identifier of the business connection.
4483
+ * @param {Object} [options] Additional Telegram query options
4484
+ * @return {Promise} On success, returns [StarAmount](https://core.telegram.org/bots/api#staramount).
4485
+ * @see https://core.telegram.org/bots/api#getbusinessaccountstarbalance
4486
+ */
4487
+
4488
+ }, {
4489
+ key: 'getBusinessAccountStarBalance',
4490
+ value: function getBusinessAccountStarBalance(businessConnectionId) {
4491
+ var form = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
4492
+
4493
+ form.business_connection_id = businessConnectionId;
4494
+ return this._request('getBusinessAccountStarBalance', { form: form });
4495
+ }
4496
+
4497
+ /**
4498
+ * This method transfers Telegram Stars from the business account balance to the bot's balance.
4499
+ *
4500
+ * Requires the **can_transfer_stars** business bot right.
4501
+ *
4502
+ * @param {String} businessConnectionId Unique identifier of the business connection.
4503
+ * @param {Number} starCount Number of Telegram Stars to transfer; 1-10000.
4504
+ * @param {Object} [options] Additional Telegram query options.
4505
+ * @return {Promise} On success, returns True.
4506
+ * @see https://core.telegram.org/bots/api#transferbusinessaccountstars
4507
+ */
4508
+
4509
+ }, {
4510
+ key: 'transferBusinessAccountStars',
4511
+ value: function transferBusinessAccountStars(businessConnectionId, startCount) {
4512
+ var form = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
4513
+
4514
+ form.business_connection_id = businessConnectionId;
4515
+ form.star_count = startCount;
4516
+ return this._request('transferBusinessAccountStars', { form: form });
4517
+ }
4518
+
4519
+ /**
4520
+ * This method returns the gifts received and owned by a managed business account.
4521
+ *
4522
+ * Requires the **can_view_gifts_and_stars** business bot right.
4523
+ *
4524
+ * @param {String} businessConnectionId Unique identifier of the business connection.
4525
+ * @param {Object} [options] Additional Telegram query options
4526
+ * @return {Promise} On success, returns [OwnedGifts](https://core.telegram.org/bots/api#ownedgifts).
4527
+ * @see https://core.telegram.org/bots/api#getbusinessaccountgifts
4528
+ */
4529
+
4530
+ }, {
4531
+ key: 'getBusinessAccountGifts',
4532
+ value: function getBusinessAccountGifts(businessConnectionId) {
4533
+ var form = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
4534
+
4535
+ form.business_connection_id = businessConnectionId;
4536
+ return this._request('getBusinessAccountGifts', { form: form });
4537
+ }
4538
+
4539
+ /**
4540
+ * This method converts a given regular gift to Telegram Stars.
4541
+ *
4542
+ * Requires the **can_convert_gifts_to_stars** business bot right.
4543
+ *
4544
+ * @param {String} businessConnectionId Unique identifier of the business connection.
4545
+ * @param {String} ownedGiftId Unique identifier of the regular gift that should be converted to Telegram Stars.
4546
+ * @param {Object} [options] Additional Telegram query options
4547
+ * @return {Promise} On success, returns True.
4548
+ * @see https://core.telegram.org/bots/api#convertgifttostars
4549
+ */
4550
+
4551
+ }, {
4552
+ key: 'convertGiftToStars',
4553
+ value: function convertGiftToStars(businessConnectionId, ownedGiftId) {
4554
+ var form = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
4555
+
4556
+ form.business_connection_id = businessConnectionId;
4557
+ form.owned_gift_id = ownedGiftId;
4558
+ return this._request('convertGiftToStars', { form: form });
4559
+ }
4560
+
4561
+ /**
4562
+ * This method upgrades a given regular gift to a unique gift.
4563
+ *
4564
+ * Requires the **can_transfer_and_upgrade_gifts** business bot right.
4565
+ * Additionally requires the **can_transfer_stars** business bot right **if the upgrade is paid**.
4566
+ *
4567
+ * @param {String} businessConnectionId Unique identifier of the business connection.
4568
+ * @param {String} ownedGiftId Unique identifier of the regular gift that should be upgraded to a unique one.
4569
+ * @param {Object} [options] Additional Telegram query options
4570
+ * @return {Promise} On success, returns True.
4571
+ * @see https://core.telegram.org/bots/api#upgradegift
4572
+ */
4573
+
4574
+ }, {
4575
+ key: 'upgradeGift',
4576
+ value: function upgradeGift(businessConnectionId, ownedGiftId) {
4577
+ var form = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
4578
+
4579
+ form.business_connection_id = businessConnectionId;
4580
+ form.owned_gift_id = ownedGiftId;
4581
+ return this._request('upgradeGift', { form: form });
4582
+ }
4583
+
4584
+ /**
4585
+ * This method transfers an owned unique gift to another user.
4586
+ *
4587
+ * Requires the **can_transfer_and_upgrade_gifts** business bot right.
4588
+ * Additionally requires the **can_transfer_stars** business bot right **if the transfer is paid**.
4589
+ *
4590
+ * @param {String} businessConnectionId Unique identifier of the business connection.
4591
+ * @param {String} ownedGiftId Unique identifier of the regular gift that should be transferred.
4592
+ * @param {Number} newOwnerChatId Unique identifier of the chat which will own the gift. The chat **must be active in the last 24 hours**.
4593
+ * @param {Object} [options] Additional Telegram query options
4594
+ * @return {Promise} On success, returns True.
4595
+ * @see https://core.telegram.org/bots/api#transfergift
4596
+ */
4597
+
4598
+ }, {
4599
+ key: 'transferGift',
4600
+ value: function transferGift(businessConnectionId, ownedGiftId, newOwnerChatId) {
4601
+ var form = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
4602
+
4603
+ form.business_connection_id = businessConnectionId;
4604
+ form.owned_gift_id = ownedGiftId;
4605
+ form.new_owner_chat_id = newOwnerChatId;
4606
+ return this._request('transferGift', { form: form });
4607
+ }
4608
+
4609
+ /**
4610
+ * This method posts a story on behalf of a managed business account.
4611
+ *
4612
+ * Requires the **can_manage_stories** business bot right.
4613
+ *
4614
+ * @param {String} businessConnectionId Unique identifier of the business connection.
4615
+ * @param {Array} content [InputStoryContent](https://core.telegram.org/bots/api#inputpaidmedia). The photo/video property can be String, Stream or Buffer.
4616
+ * @param {Number} activePeriod Unique identifier of the chat which will own the gift. The chat **must be active in the last 24 hours**.
4617
+ * @param {Object} [options] Additional Telegram query options
4618
+ * @return {Promise} On success, returns [Story](https://core.telegram.org/bots/api#story).
4619
+ * @see https://core.telegram.org/bots/api#poststory
4620
+ */
4621
+
4622
+ }, {
4623
+ key: 'postStory',
4624
+ value: function postStory(businessConnectionId, content, activePeriod) {
4625
+ var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
4626
+
4627
+ var opts = {
4628
+ qs: options
4629
+ };
4630
+
4631
+ opts.qs.business_connection_id = businessConnectionId;
4632
+ opts.qs.active_period = activePeriod;
4633
+
4634
+ try {
4635
+ var inputHistoryContent = content;
4636
+ opts.formData = {};
4637
+
4638
+ if (!content.type) {
4639
+ return Promise.reject(new Error('content.type is required'));
4640
+ }
4641
+
4642
+ var _formatSendMultipleDa2 = this._formatSendMultipleData(content.type, [content]),
4643
+ formData = _formatSendMultipleDa2.formData,
4644
+ fileIds = _formatSendMultipleDa2.fileIds;
4645
+
4646
+ opts.formData = formData;
4647
+
4648
+ if (fileIds[0]) {
4649
+ inputHistoryContent[content.type] = fileIds[0];
4650
+ } else {
4651
+ inputHistoryContent[content.type] = 'attach://' + content.type + '_0';
4652
+ }
4653
+
4654
+ opts.qs.content = stringify(inputHistoryContent);
4655
+ } catch (ex) {
4656
+ return Promise.reject(ex);
4657
+ }
4658
+
4659
+ return this._request('postStory', opts);
4660
+ }
4661
+
4662
+ /**
4663
+ * This method edits a story previously posted by the bot on behalf of a managed business account.
4664
+ *
4665
+ * Requires the **can_manage_stories** business bot right.
4666
+ *
4667
+ * @param {String} businessConnectionId Unique identifier of the business connection.
4668
+ * @param {Number} storyId Unique identifier of the story to edit.
4669
+ * @param {Array} content [InputStoryContent](https://core.telegram.org/bots/api#inputpaidmedia). The photo/video property can be String, Stream or Buffer.
4670
+ * @param {Object} [options] Additional Telegram query options
4671
+ * @return {Promise} On success, returns [Story](https://core.telegram.org/bots/api#story).
4672
+ * @see https://core.telegram.org/bots/api#editstory
4673
+ */
4674
+
4675
+ }, {
4676
+ key: 'editStory',
4677
+ value: function editStory(businessConnectionId, storyId, content) {
4678
+ var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
4679
+
4680
+ var opts = {
4681
+ qs: options
4682
+ };
4683
+
4684
+ opts.qs.business_connection_id = businessConnectionId;
4685
+ opts.qs.story_id = storyId;
4686
+
4687
+ try {
4688
+ var inputHistoryContent = content;
4689
+ opts.formData = {};
4690
+
4691
+ if (!content.type) {
4692
+ return Promise.reject(new Error('content.type is required'));
4693
+ }
4694
+
4695
+ var _formatSendMultipleDa3 = this._formatSendMultipleData(content.type, [content]),
4696
+ formData = _formatSendMultipleDa3.formData,
4697
+ fileIds = _formatSendMultipleDa3.fileIds;
4698
+
4699
+ opts.formData = formData;
4700
+
4701
+ if (fileIds[0]) {
4702
+ inputHistoryContent[content.type] = fileIds[0];
4703
+ } else {
4704
+ inputHistoryContent[content.type] = 'attach://' + content.type + '_0';
4705
+ }
4706
+
4707
+ opts.qs.content = stringify(inputHistoryContent);
4708
+ } catch (ex) {
4709
+ return Promise.reject(ex);
4710
+ }
4711
+
4712
+ return this._request('editStory', opts);
4713
+ }
4714
+
4715
+ /**
4716
+ * This method deletes a story previously posted by the bot on behalf of a managed business account.
4717
+ *
4718
+ * Requires the **can_manage_stories** business bot right.
4719
+ *
4720
+ * @param {String} businessConnectionId Unique identifier of the business connection.
4721
+ * @param {Number} storyId Unique identifier of the story to delete.
4722
+ * @param {Object} [options] Additional Telegram query options.
4723
+ * @return {Promise} On success, returns True.
4724
+ * @see https://core.telegram.org/bots/api#deletestory
4725
+ */
4726
+
4727
+ }, {
4728
+ key: 'deleteStory',
4729
+ value: function deleteStory(businessConnectionId, storyId) {
4730
+ var form = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
4731
+
4732
+ form.business_connection_id = businessConnectionId;
4733
+ form.story_id = storyId;
4734
+ return this._request('deleteStory', { form: form });
4735
+ }
4736
+ }]);
4737
+
4738
+ return TelegramBot;
4739
+ }(EventEmitter);
4740
+
4741
+ module.exports = TelegramBot;