Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions doc/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ TelegramBot
* [.sendPoll(chatId, question, pollOptions, [options])](#TelegramBot+sendPoll) ⇒ <code>Promise</code>
* [.sendChecklist(businessConnectionId, chatId, checklist, [options])](#TelegramBot+sendChecklist) ⇒ <code>Promise</code>
* [.sendDice(chatId, [options])](#TelegramBot+sendDice) ⇒ <code>Promise</code>
* [.sendMessageDraft(chatId, draftId, text, [options])](#TelegramBot+sendMessageDraft) ⇒ <code>Promise</code>
* [.sendChatAction(chatId, action, [options])](#TelegramBot+sendChatAction) ⇒ <code>Promise</code>
* [.setMessageReaction(chatId, messageId, [options])](#TelegramBot+setMessageReaction) ⇒ <code>Promise.&lt;Boolean&gt;</code>
* [.getUserProfilePhotos(userId, [options])](#TelegramBot+getUserProfilePhotos) ⇒ <code>Promise</code>
Expand Down Expand Up @@ -968,6 +969,23 @@ Use this method to send an animated emoji that will display a random value.
| chatId | <code>Number</code> \| <code>String</code> | Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) |
| [options] | <code>Object</code> | Additional Telegram query options |

<a name="TelegramBot+sendMessageDraft"></a>

### telegramBot.sendMessageDraft(chatId, draftId, text, [options]) ⇒ <code>Promise</code>
Send Message Draft
Use this method to stream a partial message to a user while the message is being generated; supported only for bots with forum topic mode enabled. Returns True on success.

**Kind**: instance method of [<code>TelegramBot</code>](#TelegramBot)
**Returns**: <code>Promise</code> - On success, return true
**See**: https://core.telegram.org/bots/api#sendmessagedraft

| Param | Type | Description |
| --- | --- | --- |
| chatId | <code>Number</code> \| <code>String</code> | Unique identifier for the target private chat |
| draftId | <code>Number</code> | Unique identifier of the message draft; must be non-zero. Changes of drafts with the same identifier are animated |
| text | <code>String</code> | Text of the message to be sent, 1-4096 characters after entities parsing |
| [options] | <code>Object</code> | Additional Telegram query options |

<a name="TelegramBot+sendChatAction"></a>

### telegramBot.sendChatAction(chatId, action, [options]) ⇒ <code>Promise</code>
Expand Down
16 changes: 16 additions & 0 deletions src/telegram.js
Original file line number Diff line number Diff line change
Expand Up @@ -1588,6 +1588,22 @@ class TelegramBot extends EventEmitter {
return this._request('sendDice', opts);
}

/**
* Send Message Draft
* Use this method to stream a partial message to a user while the message is being generated; supported only for bots with forum topic mode enabled. Returns True on success.
* @param {Number|String} chatId Unique identifier for the target private chat
* @param {Number} draftId Unique identifier of the message draft; must be non-zero. Changes of drafts with the same identifier are animated
* @param {String} text Text of the message to be sent, 1-4096 characters after entities parsing
* @param {Object} [options] Additional Telegram query options
* @return {Promise} On success, return true
* @see https://core.telegram.org/bots/api#sendmessagedraft
*/
sendMessageDraft(chatId, draftId, text, form = {}) {
form.chat_id = chatId;
form.draft_id = draftId;
form.text = text;
return this._request('sendMessageDraft', { form });
}

/**
* Send chat action.
Expand Down
10 changes: 10 additions & 0 deletions test/telegram.js
Original file line number Diff line number Diff line change
Expand Up @@ -1107,6 +1107,16 @@ describe('TelegramBot', function telegramSuite() {
});
});

describe('#sendMessageDraft', function sendMessageDraftSuite() {
it('should send a Draft', function test() {
const draftId = Date.now();
const text = 'test content';
return bot.sendMessageDraft(GROUPID, draftId, text).then(resp => {
assert.ok(is.boolean(resp));
});
});
});

describe('#sendChatAction', function sendChatActionSuite() {
before(function before() {
utils.handleRatelimit(bot, 'sendChatAction', this);
Expand Down