GochoMugo 9 years ago
parent 942fc4854b
commit cda9d8d597
No known key found for this signature in database
GPG Key ID: 7B6A01CB57AA39E4
  1. 15
      doc/api.md
  2. 14
      src/telegram.js
  3. 15
      test/telegram.js

@ -61,6 +61,7 @@ TelegramBot
* [.sendGame(chatId, gameShortName, [options])](#TelegramBot+sendGame) ⇒ <code>Promise</code>
* [.setGameScore(userId, score, [options])](#TelegramBot+setGameScore) ⇒ <code>Promise</code>
* [.getGameHighScores(userId, [options])](#TelegramBot+getGameHighScores) ⇒ <code>Promise</code>
* [.deleteMessage(chatId, messageId, [options])](#TelegramBot+deleteMessage) ⇒ <code>Promise</code>
<a name="new_TelegramBot_new"></a>
@ -760,6 +761,20 @@ Use this method to get data for high score table.
| userId | <code>String</code> | Unique identifier of the target user |
| [options] | <code>Object</code> | Additional Telegram query options |
<a name="TelegramBot+deleteMessage"></a>
### telegramBot.deleteMessage(chatId, messageId, [options]) ⇒ <code>Promise</code>
Use this method to delete a message.
**Kind**: instance method of <code>[TelegramBot](#TelegramBot)</code>
**See**: https://core.telegram.org/bots/api#deletemessage
| Param | Type | Description |
| --- | --- | --- |
| chatId | <code>String</code> | Unique identifier of the target chat |
| messageId | <code>String</code> | Unique identifier of the target message |
| [options] | <code>Object</code> | Additional Telegram query options |
* * *

@ -1192,6 +1192,20 @@ 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;

@ -875,6 +875,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,

Loading…
Cancel
Save