mirror of
https://github.com/yagop/node-telegram-bot-api
synced 2025-08-23 18:38:01 +00:00
src/telegram: Support 'deleteMessage' API method
This commit is contained in:
parent
64bbefd898
commit
673e09cd08
@ -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…
x
Reference in New Issue
Block a user