2
0
mirror of https://github.com/yagop/node-telegram-bot-api synced 2025-08-23 02:17:16 +00:00

src/telegram: Support 'deleteMessage' API method

This commit is contained in:
Jonas Fowl 2017-05-07 18:14:25 +02:00 committed by GochoMugo
parent 64bbefd898
commit 673e09cd08
2 changed files with 30 additions and 0 deletions

View File

@ -1167,6 +1167,21 @@ class TelegramBot extends EventEmitter {
form.user_id = userId;
return this._request('getGameHighScores', { form });
}
/**
* Use this method to delete a message.
* @param {String} chatId Unique identifier of the target chat
* @param {String} messageId Unique identifier of the target message
* @param {Object} [options] Additional Telegram query options
* @return {Promise}
* @see https://core.telegram.org/bots/api#deletemessage
*/
deleteMessage(chatId, messageId, form = {}) {
form.chat_id = chatId;
form.message_id = messageId;
return this._request('deleteMessage', { form });
}
}
module.exports = TelegramBot;

View File

@ -837,6 +837,21 @@ describe('TelegramBot', function telegramSuite() {
});
});
describe('#deleteMessage', function deleteMessageSuite() {
let messageId;
before(function before() {
utils.handleRatelimit(bot, 'deleteMessage', this);
return bot.sendMessage(USERID, 'To be deleted').then(resp => {
messageId = resp.message_id;
});
});
it('should delete message', function test() {
return bot.deleteMessage(USERID, messageId).then(resp => {
assert.equal(resp, true);
});
});
});
describe('#getUserProfilePhotos', function getUserProfilePhotosSuite() {
const opts = {
offset: 0,