Skip to content

Commit c9b05e7

Browse files
feat: Support test enviroment (#994)
* Added a support for testing enviroment * Added annotation for testing enviroment and run doc Co-authored-by: Mohamed Sohail <sohailsameja@gmail.com>
1 parent f50cf98 commit c9b05e7

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

doc/api.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ Emits `message` when a message arrives.
136136
| [options] | <code>Object</code> | | |
137137
| [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. |
138138
| [options.polling.timeout] | <code>String</code> \| <code>Number</code> | <code>10</code> | *Deprecated. Use `options.polling.params` instead*. Timeout in seconds for long polling. |
139+
| [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. |
139140
| [options.polling.interval] | <code>String</code> \| <code>Number</code> | <code>300</code> | Interval between requests in miliseconds |
140141
| [options.polling.autoStart] | <code>Boolean</code> | <code>true</code> | Start polling immediately |
141142
| [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. |
@@ -1677,7 +1678,7 @@ Animated stickers can be added to animated sticker sets and only to them:
16771678
| --- | --- | --- | --- |
16781679
| userId | <code>Number</code> | | User identifier of sticker set owner |
16791680
| name | <code>String</code> | | Sticker set name |
1680-
| 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. |
1681+
| 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. |
16811682
| emojis | <code>String</code> | | One or more emoji corresponding to the sticker |
16821683
| stickerType | <code>String</code> | <code>png_sticker</code> | Allow values: `png_sticker`, `tgs_sticker`, or `webm_sticker`. |
16831684
| [options] | <code>Object</code> | | Additional Telegram query options |

src/telegram.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ class TelegramBot extends EventEmitter {
121121
* If a WebHook has been set, it will be deleted automatically.
122122
* @param {String|Number} [options.polling.timeout=10] *Deprecated. Use `options.polling.params` instead*.
123123
* Timeout in seconds for long polling.
124+
* @param {Boolean} [options.testEnvironment=false] Set true to work with test enviroment.
125+
* When working with the test environment, you may use HTTP links without TLS to test your Web App.
124126
* @param {String|Number} [options.polling.interval=300] Interval between requests in miliseconds
125127
* @param {Boolean} [options.polling.autoStart=true] Start polling immediately
126128
* @param {Object} [options.polling.params] Parameters to be used in polling API requests.
@@ -192,7 +194,7 @@ class TelegramBot extends EventEmitter {
192194
* @see https://core.telegram.org/bots/api#making-requests
193195
*/
194196
_buildURL(_path) {
195-
return `${this.options.baseApiUrl}/bot${this.token}/${_path}`;
197+
return `${this.options.baseApiUrl}/bot${this.token}${this.options.testEnvironment ? '/test' : ''}/${_path}`;
196198
}
197199

198200
/**

0 commit comments

Comments
 (0)