mirror of
https://github.com/yagop/node-telegram-bot-api
synced 2025-08-29 13:27:44 +00:00
Closes #133: JSON-stringify reply_markup in qs
This commit is contained in:
commit
ab3464c679
@ -141,6 +141,14 @@ class TelegramBot extends EventEmitter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_fixReplyMarkup(obj) {
|
||||||
|
const replyMarkup = obj.reply_markup;
|
||||||
|
if (replyMarkup && typeof replyMarkup !== 'string') {
|
||||||
|
// reply_markup must be passed as JSON stringified to Telegram
|
||||||
|
obj.reply_markup = JSON.stringify(replyMarkup);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// request-promise
|
// request-promise
|
||||||
_request(_path, options = {}) {
|
_request(_path, options = {}) {
|
||||||
if (!this.token) {
|
if (!this.token) {
|
||||||
@ -148,11 +156,10 @@ class TelegramBot extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (options.form) {
|
if (options.form) {
|
||||||
const replyMarkup = options.form.reply_markup;
|
this._fixReplyMarkup(options.form);
|
||||||
if (replyMarkup && typeof replyMarkup !== 'string') {
|
}
|
||||||
// reply_markup must be passed as JSON stringified to Telegram
|
if (options.qs) {
|
||||||
options.form.reply_markup = JSON.stringify(replyMarkup);
|
this._fixReplyMarkup(options.qs);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
options.url = this._buildURL(_path);
|
options.url = this._buildURL(_path);
|
||||||
options.simple = false;
|
options.simple = false;
|
||||||
|
@ -205,6 +205,18 @@ describe('Telegram', function telegramSuite() {
|
|||||||
assert.ok(is.object(resp));
|
assert.ok(is.object(resp));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should send a photo along with reply_markup', function test() {
|
||||||
|
const bot = new Telegram(TOKEN);
|
||||||
|
const photo = fs.readFileSync(`${__dirname}/bot.gif`);
|
||||||
|
return bot.sendPhoto(USERID, photo, {
|
||||||
|
reply_markup: {
|
||||||
|
hide_keyboard: true
|
||||||
|
}
|
||||||
|
}).then(resp => {
|
||||||
|
assert.ok(is.object(resp));
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('#sendChatAction', function sendChatActionSuite() {
|
describe('#sendChatAction', function sendChatActionSuite() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user