src/telegram: Support 'deleteMessage' API method

experimental
Jonas Fowl 9 years ago committed by GochoMugo
parent 64bbefd898
commit 673e09cd08
  1. 15
      src/telegram.js
  2. 15
      test/telegram.js

@ -1167,6 +1167,21 @@ class TelegramBot extends EventEmitter {
form.user_id = userId; form.user_id = userId;
return this._request('getGameHighScores', { form }); 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; module.exports = TelegramBot;

@ -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() { describe('#getUserProfilePhotos', function getUserProfilePhotosSuite() {
const opts = { const opts = {
offset: 0, offset: 0,

Loading…
Cancel
Save