Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ Emits `message` when a message arrives.
| [options.polling.autoStart] | <code>Boolean</code> | <code>true</code> | Start polling immediately |
| [options.polling.params] | <code>Object</code> | | Parameters to be used in polling API requests. See https://core.telegram.org/bots/api#getupdates for more information. |
| [options.polling.params.timeout] | <code>Number</code> | <code>10</code> | Timeout in seconds for long polling. |
| [options.polling.params.allowed_updates] | <code>Array</code> \| <code>String</code> | | A JSON-serialized list of the update types you want your bot to receive. For example, specify ["message", "edited_channel_post", "callback_query"] to only receive updates of these types. |
| [options.webHook] | <code>Boolean</code> \| <code>Object</code> | <code>false</code> | Set true to enable WebHook or set options |
| [options.webHook.host] | <code>String</code> | <code>&quot;0.0.0.0&quot;</code> | Host to bind to |
| [options.webHook.port] | <code>Number</code> | <code>8443</code> | Port to bind to |
Expand Down
8 changes: 8 additions & 0 deletions src/telegram.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ class TelegramBot extends EventEmitter {
* @param {Object} [options.polling.params] Parameters to be used in polling API requests.
* See https://core.telegram.org/bots/api#getupdates for more information.
* @param {Number} [options.polling.params.timeout=10] Timeout in seconds for long polling.
* @param {Array<String>|String} [options.polling.params.allowed_updates] A JSON-serialized list of the update types you want your bot to receive.
* For example, specify ["message", "edited_channel_post", "callback_query"] to only receive updates of these types.
* @param {Boolean|Object} [options.webHook=false] Set true to enable WebHook or set options
* @param {String} [options.webHook.host="0.0.0.0"] Host to bind to
* @param {Number} [options.webHook.port=8443] Port to bind to
Expand Down Expand Up @@ -923,6 +925,12 @@ class TelegramBot extends EventEmitter {
/* eslint-enable no-param-reassign, prefer-rest-params */
}

// If allowed_updates is present and is an array, stringify it.
// If it's already a string (e.g., user did JSON.stringify), leave as is.
if (form.allowed_updates) {
form.allowed_updates = stringify(form.allowed_updates);
}

return this._request('getUpdates', { form });
}

Expand Down