/** * Alias of `TelegramBot#startPolling()`. This is **deprecated**. * @param {Object} [options] * @return {Promise} * @deprecated */ initPolling() { deprecate('TelegramBot#initPolling() is deprecated. Use TelegramBot#startPolling() instead.'); return this.startPolling(); }
/** * Add listener for the specified [event](https://github.com/yagop/node-telegram-bot-api/blob/master/doc/usage.md#events). * This is the usual `emitter.on()` method. * @param {String} event * @param {Function} listener * @see {@link https://github.com/yagop/node-telegram-bot-api/blob/master/doc/usage.md#events|Available events} * @see https://nodejs.org/api/events.html#events_emitter_on_eventname_listener */ on(event, listener) { if (_deprecatedMessageTypes.indexOf(event) !== -1) { const url = 'https://github.com/yagop/node-telegram-bot-api/blob/master/doc/usage.md#events'; deprecate(`Events ${_deprecatedMessageTypes.join(',')} are deprecated. See the updated list of events: ${url}`); } super.on(event, listener); }
/** * Handles polling against the Telegram servers. * @param {TelegramBot} bot * @see https://core.telegram.org/bots/api#getting-updates */ constructor(bot) { this.bot = bot; this.options = (typeof bot.options.polling === 'boolean') ? {} : bot.options.polling; this.options.interval = (typeof this.options.interval === 'number') ? this.options.interval : 300; this.options.params = (typeof this.options.params === 'object') ? this.options.params : {}; this.options.params.offset = (typeof this.options.params.offset === 'number') ? this.options.params.offset : 0; this.options.params.timeout = (typeof this.options.params.timeout === 'number') ? this.options.params.timeout : 10; if (typeof this.options.timeout === 'number') { deprecate('`options.polling.timeout` is deprecated. Use `options.polling.params` instead.'); this.options.params.timeout = this.options.timeout; } this._lastUpdate = 0; this._lastRequest = null; this._abort = false; this._pollingTimeout = null; }
deprecate('The method signature setWebHook(url, cert) has been deprecated since v0.25.0'); cert = options;
deprecate(`Buffers will have their filenames default to "filename" instead of "data". ${deprecationMessage}`); filename = 'data'; deprecate(`An error will no longer be thrown if file-type of buffer could not be detected. ${deprecationMessage}`); throw new errors.FatalError('Unsupported Buffer file-type'); contentType = contentType || 'application/octet-stream'; } else { deprecate(`In the future, content-type of files you send will default to "application/octet-stream". ${deprecationMessage}`);
/** * Use this method to get a list of profile pictures for a user. * Returns a [UserProfilePhotos](https://core.telegram.org/bots/api#userprofilephotos) object. * This method has an [older, compatible signature][getUserProfilePhotos-v0.25.0] * that is being deprecated. * * @param {Number} userId Unique identifier of the target user * @param {Object} [options] Additional Telegram query options * @return {Promise} * @see https://core.telegram.org/bots/api#getuserprofilephotos */ getUserProfilePhotos(userId, form = {}) { /* The older method signature was getUserProfilePhotos(userId, offset, limit). * We need to ensure backwards-compatibility while maintaining * consistency of the method signatures throughout the library */ if (typeof form !== 'object') { /* eslint-disable no-param-reassign, prefer-rest-params */ deprecate('The method signature getUserProfilePhotos(userId, offset, limit) has been deprecated since v0.25.0'); form = { offset: arguments[1], limit: arguments[2], }; /* eslint-enable no-param-reassign, prefer-rest-params */ } form.user_id = userId; return this._request('getUserProfilePhotos', { form }); }
deprecate('Client({ config }), see ' + 'https://github.com/godaddy/kubernetes-client/blob/master/merging-with-kubernetes.md')
deprecate('Request() without a .kubeconfig option, see ' + 'https://github.com/godaddy/kubernetes-client/blob/master/merging-with-kubernetes.md') convertedOptions = options
/** * Use the given middleware `fn`. * * Old-style middleware will be converted. * * @param {Function} fn * @return {Application} self * @api public */ use(fn) { if (typeof fn !== 'function') throw new TypeError('middleware must be a function!'); if (isGeneratorFunction(fn)) { deprecate('Support for generators will be removed in v3. ' + 'See the documentation for examples of how to convert old middleware ' + 'https://github.com/koajs/koa/blob/master/docs/migration.md'); fn = convert(fn); } debug('use %s', fn._name || fn.name || '-'); this.middleware.push(fn); return this; }
/** * Use this method to receive incoming updates using long polling. * This method has an [older, compatible signature][getUpdates-v0.25.0] * that is being deprecated. * * @param {Object} [options] Additional Telegram query options * @return {Promise} * @see https://core.telegram.org/bots/api#getupdates */ getUpdates(form = {}) { /* The older method signature was getUpdates(timeout, limit, offset). * We need to ensure backwards-compatibility while maintaining * consistency of the method signatures throughout the library */ if (typeof form !== 'object') { /* eslint-disable no-param-reassign, prefer-rest-params */ deprecate('The method signature getUpdates(timeout, limit, offset) has been deprecated since v0.25.0'); form = { timeout: arguments[0], limit: arguments[1], offset: arguments[2], }; /* eslint-enable no-param-reassign, prefer-rest-params */ } return this._request('getUpdates', { form }); }