Feature:
We can now pass a custom API Base URL to
be used during making HTTP requests. This is useful in
proxying requests, or running tests.
In particular, this library is (almost) ready to
be used with PWRTelegram API (http://pwrtelegram.xyz/).
Feature:
For finer control over bot's polling and web-hook, the
following methods have been added:
* TelegramBot#isPolling()
* TelegramBot#openWebHook()
* TelegramBot#closeWebHook()
* TelegramBot#hasOpenWebHook()
Please read README.md for more information on the
new methods.
Feature:
Currently, if the constructor option 'options.webHook' is passed,
the bot opens the webHook immediately! There's NO way to disable
this behavior, which might be useful in cases such as:
* providing custom webhook parameters without opening the webhook
immediately
The new boolean option, 'autoOpen', can now be used to control this
behavior. For example,
```js
const bot = new TelegramBot(token, {
webHook: {
autoOpen: false,
},
});
```
If set to 'false', the bot does NOT open the web-hook immediately.
Currently, there's NO way to open the web-hook in this case.
I'm working on that. Expect a feature to add a method to open
the web-hook manually!
If not provided, its value defaults to 'true'.
Implementation:
* Backwards-compatible: the behavior of opening the web-hook
immediately remains, when the parameter is NOT provided.
Feature:
Currently, if the constructor option 'options.polling' is
passed, the bot begins polling immediately! There's NO
way to disable this behavior, which might be useful in
cases such as:
* providing custom polling parameters without starting
the polling immediately
The boolean option, 'autoStart', can now be used to control this
behavior. For example,
```js
const bot = new TelegramBot(token, {
polling: {
autoStart: false,
},
});
```
If set to 'false', the bot does NOT begin polling
immediately. You'll have to use TelegramBot#initPolling().
If not provided, its value defaults to 'true'.
Implementation:
* Backwards-compatible: the behavior of starting polling
immediately remains, when the parameter is NOT provided
Bug:
The (private) method TelegramBot#_formatSendData(), used by public
methods, such as TelegramBot#sendPhoto(), throws an error
if the stream passed (fs.readStream) has the property 'path',
being an instance of Buffer.
For example,
const stream = fs.createReadStream(Buffer.from('cat.png'));
bot.sendPhoto(chatId, stream);
Would throw an error, like
TypeError: Path must be a string. Received <Buffer 60 62 63 64>
This is because of this line:
src/telegram.js:297
fileName = URL.parse(path.basename(data.path)).pathname;
path.basename() can not handle buffer (non-string) paths. From the
docs, "A TypeError is thrown if path is not a string...".
Fix:
Ensure path.basename() receives a string, by converting the buffer
to string.
References:
* fs.ReadStream: https://nodejs.org/docs/latest/api/fs.html#fs_class_fs_readstream
- Adds support for callback_query-type messages
- Adds a showAlert option to answerCallbackQuery to more-closely align with the real bot API
- Adds tests for message editing functionality
- Adds a global test timeout of 10s and adds done() calls to all tests for assurance
- Adds support for callback_query-type messages
- Adds a showAlert option to answerCallbackQuery to more-closely align with the real bot API
- Adds tests for message editing functionality
- Adds a global test timeout of 10s and adds done() calls to all tests for assurance