mirror of
https://github.com/yagop/node-telegram-bot-api
synced 2025-08-29 05:17:41 +00:00
src/polling: Add options to TelegramBot#stopPolling()
Feature: * Simply, pass through options to TelegramBot#stopPolling(options) to TelegramBotPolling#stop(options) References: * Related PR: https://github.com/yagop/node-telegram-bot-api/pull/456
This commit is contained in:
parent
ce9ff57a63
commit
b1f0ebaf17
@ -12,6 +12,7 @@ Added:
|
||||
* (#440) *TelegramBot#setChatStickerSet*, *TelegramBot#deleteChatStickerSet* (by @kamikazechaser)
|
||||
1. Support Bot API v3.5:
|
||||
* Support `provider_data` parameter in *TelegramBot#sendInvoice* (by @GochoMugo)
|
||||
1. Add options to *TelegramBot#stopPolling()* (by @GochoMugo)
|
||||
1. Add `metadata` argument in `message` event (and
|
||||
friends e.g. `text`, `audio`, etc.) (#409) (by @jlsjonas, @GochoMugo)
|
||||
1. Add forward-compatibility i.e. support future additional Telegram options (by @GochoMugo)
|
||||
|
11
doc/api.md
11
doc/api.md
@ -16,7 +16,7 @@ TelegramBot
|
||||
* [.on(event, listener)](#TelegramBot+on)
|
||||
* [.startPolling([options])](#TelegramBot+startPolling) ⇒ <code>Promise</code>
|
||||
* ~~[.initPolling([options])](#TelegramBot+initPolling) ⇒ <code>Promise</code>~~
|
||||
* [.stopPolling()](#TelegramBot+stopPolling) ⇒ <code>Promise</code>
|
||||
* [.stopPolling([options])](#TelegramBot+stopPolling) ⇒ <code>Promise</code>
|
||||
* [.isPolling()](#TelegramBot+isPolling) ⇒ <code>Boolean</code>
|
||||
* [.openWebHook()](#TelegramBot+openWebHook) ⇒ <code>Promise</code>
|
||||
* [.closeWebHook()](#TelegramBot+closeWebHook) ⇒ <code>Promise</code>
|
||||
@ -169,12 +169,19 @@ Alias of `TelegramBot#startPolling()`. This is **deprecated**.
|
||||
|
||||
<a name="TelegramBot+stopPolling"></a>
|
||||
|
||||
### telegramBot.stopPolling() ⇒ <code>Promise</code>
|
||||
### telegramBot.stopPolling([options]) ⇒ <code>Promise</code>
|
||||
Stops polling after the last polling request resolves.
|
||||
Multiple invocations do nothing if polling is already stopped.
|
||||
Returning the promise of the last polling request is **deprecated**.
|
||||
|
||||
**Kind**: instance method of <code>[TelegramBot](#TelegramBot)</code>
|
||||
|
||||
| Param | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| [options] | <code>Object</code> | Options |
|
||||
| [options.cancel] | <code>Boolean</code> | Cancel current request |
|
||||
| [options.reason] | <code>String</code> | Reason for stopping polling |
|
||||
|
||||
<a name="TelegramBot+isPolling"></a>
|
||||
|
||||
### telegramBot.isPolling() ⇒ <code>Boolean</code>
|
||||
|
@ -375,13 +375,16 @@ class TelegramBot extends EventEmitter {
|
||||
* Stops polling after the last polling request resolves.
|
||||
* Multiple invocations do nothing if polling is already stopped.
|
||||
* Returning the promise of the last polling request is **deprecated**.
|
||||
* @param {Object} [options] Options
|
||||
* @param {Boolean} [options.cancel] Cancel current request
|
||||
* @param {String} [options.reason] Reason for stopping polling
|
||||
* @return {Promise}
|
||||
*/
|
||||
stopPolling() {
|
||||
stopPolling(options) {
|
||||
if (!this._polling) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
return this._polling.stop();
|
||||
return this._polling.stop(options);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -49,7 +49,7 @@ class TelegramBotPolling {
|
||||
|
||||
/**
|
||||
* Stop polling
|
||||
* @param {Object} [options]
|
||||
* @param {Object} [options] Options
|
||||
* @param {Boolean} [options.cancel] Cancel current request
|
||||
* @param {String} [options.reason] Reason for stopping polling
|
||||
* @return {Promise}
|
||||
|
Loading…
x
Reference in New Issue
Block a user