Skip to content

Commit

Permalink
feat: Support test enviroment (#994)
Browse files Browse the repository at this point in the history
* Added a support for testing enviroment

* Added annotation for testing enviroment and run doc

Co-authored-by: Mohamed Sohail <sohailsameja@gmail.com>
  • Loading branch information
tinsaeDev and kamikazechaser committed Aug 14, 2022
1 parent f50cf98 commit c9b05e7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion doc/api.md
Expand Up @@ -136,6 +136,7 @@ Emits `message` when a message arrives.
| [options] | <code>Object</code> | | |
| [options.polling] | <code>Boolean</code> \| <code>Object</code> | <code>false</code> | Set true to enable polling or set options. If a WebHook has been set, it will be deleted automatically. |
| [options.polling.timeout] | <code>String</code> \| <code>Number</code> | <code>10</code> | *Deprecated. Use `options.polling.params` instead*. Timeout in seconds for long polling. |
| [options.testEnvironment] | <code>Boolean</code> | <code>false</code> | Set true to work with test enviroment. When working with the test environment, you may use HTTP links without TLS to test your Web App. |
| [options.polling.interval] | <code>String</code> \| <code>Number</code> | <code>300</code> | Interval between requests in miliseconds |
| [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. |
Expand Down Expand Up @@ -1677,7 +1678,7 @@ Animated stickers can be added to animated sticker sets and only to them:
| --- | --- | --- | --- |
| userId | <code>Number</code> | | User identifier of sticker set owner |
| name | <code>String</code> | | Sticker set name |
| sticker | <code>String</code> \| <code>stream.Stream</code> \| <code>Buffer</code> | | Png image with the sticker (must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px), [TGS animation](https://core.telegram.org/stickers#animated-sticker-requirements) with the sticker or [WEBM video](https://core.telegram.org/stickers#video-sticker-requirements) with the sticker. |
| sticker | <code>String</code> \| <code>stream.Stream</code> \| <code>Buffer</code> | | Png image with the sticker (must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px, [TGS animation](https://core.telegram.org/stickers#animated-sticker-requirements) with the sticker or [WEBM video](https://core.telegram.org/stickers#video-sticker-requirements) with the sticker. |
| emojis | <code>String</code> | | One or more emoji corresponding to the sticker |
| stickerType | <code>String</code> | <code>png_sticker</code> | Allow values: `png_sticker`, `tgs_sticker`, or `webm_sticker`. |
| [options] | <code>Object</code> | | Additional Telegram query options |
Expand Down
4 changes: 3 additions & 1 deletion src/telegram.js
Expand Up @@ -121,6 +121,8 @@ class TelegramBot extends EventEmitter {
* If a WebHook has been set, it will be deleted automatically.
* @param {String|Number} [options.polling.timeout=10] *Deprecated. Use `options.polling.params` instead*.
* Timeout in seconds for long polling.
* @param {Boolean} [options.testEnvironment=false] Set true to work with test enviroment.
* When working with the test environment, you may use HTTP links without TLS to test your Web App.
* @param {String|Number} [options.polling.interval=300] Interval between requests in miliseconds
* @param {Boolean} [options.polling.autoStart=true] Start polling immediately
* @param {Object} [options.polling.params] Parameters to be used in polling API requests.
Expand Down Expand Up @@ -192,7 +194,7 @@ class TelegramBot extends EventEmitter {
* @see https://core.telegram.org/bots/api#making-requests
*/
_buildURL(_path) {
return `${this.options.baseApiUrl}/bot${this.token}/${_path}`;
return `${this.options.baseApiUrl}/bot${this.token}${this.options.testEnvironment ? '/test' : ''}/${_path}`;
}

/**
Expand Down

0 comments on commit c9b05e7

Please sign in to comment.