From 82631f57c309b27c32e5a7c749287c25390c9b34 Mon Sep 17 00:00:00 2001 From: Ilias Ismanalijev Date: Mon, 6 Jul 2015 01:36:48 +0200 Subject: [PATCH 1/3] send chat action --- src/telegram.js | 18 ++++++++++++++++++ test/index.js | 12 ++++++++++++ 2 files changed, 30 insertions(+) diff --git a/src/telegram.js b/src/telegram.js index 4aae57d..301a587 100644 --- a/src/telegram.js +++ b/src/telegram.js @@ -295,4 +295,22 @@ TelegramBot.prototype.sendAudio = function (chatId, audio, options) { return this._request('sendAudio', opts); }; +/** + * Send chat action + * @param {Number|String} chatId Unique identifier for the message recipient + * @param {String} 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. + * @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; diff --git a/test/index.js b/test/index.js index 202a80f..29946bb 100644 --- a/test/index.js +++ b/test/index.js @@ -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 () { }); }); + }); From a45b35453b738842f1c1aa74577de4ae794ea682 Mon Sep 17 00:00:00 2001 From: Ilias Ismanalijev Date: Mon, 6 Jul 2015 01:40:54 +0200 Subject: [PATCH 2/3] send chat action readme --- README.md | 16 ++++++++++++++++ src/telegram.js | 8 +++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 27b4abb..7a4372e 100644 --- a/README.md +++ b/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|stream.Stream** *action* Type of action to broadcast. + +### Return: + +* **Promise** diff --git a/src/telegram.js b/src/telegram.js index 301a587..fc06d3d 100644 --- a/src/telegram.js +++ b/src/telegram.js @@ -296,12 +296,14 @@ TelegramBot.prototype.sendAudio = function (chatId, audio, options) { }; /** - * Send chat action - * @param {Number|String} chatId Unique identifier for the message recipient - * @param {String} action Type of action to broadcast. `typing` for text messages, + * 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 */ From 1f3cc7b02c75553010f7cf00ec65d20eed82da54 Mon Sep 17 00:00:00 2001 From: Ilias Ismanalijev Date: Mon, 6 Jul 2015 02:04:27 +0200 Subject: [PATCH 3/3] readme chat action --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7a4372e..dbaab75 100644 --- a/README.md +++ b/README.md @@ -146,7 +146,7 @@ See: https://core.telegram.org/bots/api#sendchataction ### Params: * **Number|String** *chatId* Unique identifier for the message recipient -* **String|stream.Stream** *action* Type of action to broadcast. +* **String** *action* Type of action to broadcast. ### Return: