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
For writable streams, like `http.ClientRequest`, there is no `end` event, only `finish`. Thus, `req.end` was never called and never sending a response.
This resulted in a nasty bug for WebHook users that basically rendered the library useless because if Telegram doesn't receive a response from the bot server, it will continue to queue and send requests until it does, or until 24 hours have passed.