mirror of
https://github.com/yagop/node-telegram-bot-api
synced 2025-08-29 05:17:41 +00:00
commit
013d680a25
16
README.md
16
README.md
@ -135,3 +135,19 @@ See: https://core.telegram.org/bots/api#sendaudio
|
||||
### Return:
|
||||
|
||||
* **Promise**
|
||||
|
||||
|
||||
## sendChatAction(chatId, action)
|
||||
|
||||
Send chat action. Type of `action` to broadcast. `typing` for text messages, `upload_photo` for photos, `record_video` or `upload_video` for videos, `record_audio` or `upload_audio` for audio files, `upload_document` for general files, `find_location` for location data.
|
||||
|
||||
See: https://core.telegram.org/bots/api#sendchataction
|
||||
|
||||
### Params:
|
||||
|
||||
* **Number|String** *chatId* Unique identifier for the message recipient
|
||||
* **String** *action* Type of action to broadcast.
|
||||
|
||||
### Return:
|
||||
|
||||
* **Promise**
|
||||
|
@ -295,4 +295,24 @@ TelegramBot.prototype.sendAudio = function (chatId, audio, options) {
|
||||
return this._request('sendAudio', opts);
|
||||
};
|
||||
|
||||
/**
|
||||
* Send chat action.
|
||||
* `typing` for text messages,
|
||||
* `upload_photo` for photos, `record_video` or `upload_video` for videos,
|
||||
* `record_audio` or `upload_audio` for audio files, `upload_document` for general files,
|
||||
* `find_location` for location data.
|
||||
*
|
||||
* @param {Number|String} chatId Unique identifier for the message recipient
|
||||
* @param {String} action Type of action to broadcast.
|
||||
* @return {Promise}
|
||||
* @see https://core.telegram.org/bots/api#sendchataction
|
||||
*/
|
||||
TelegramBot.prototype.sendChatAction = function (chatId, action) {
|
||||
var query = {
|
||||
chat_id: chatId,
|
||||
action: action
|
||||
};
|
||||
return this._request('sendChatAction', {qs: query});
|
||||
};
|
||||
|
||||
module.exports = TelegramBot;
|
||||
|
@ -179,6 +179,17 @@ describe('Telegram', function () {
|
||||
});
|
||||
});
|
||||
|
||||
describe('#sendChatAction', function () {
|
||||
it('should send a chat action', function (done) {
|
||||
var bot = new Telegram(TOKEN);
|
||||
var action = "typing";
|
||||
bot.sendChatAction(USERID, action).then(function (resp) {
|
||||
resp.should.be.exactly(true);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('#sendAudio', function () {
|
||||
it('should send an OGG audio', function (done) {
|
||||
var bot = new Telegram(TOKEN);
|
||||
@ -190,4 +201,5 @@ describe('Telegram', function () {
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user