From 4746011dd1907be6a759c59d5b914cc3c49d19b5 Mon Sep 17 00:00:00 2001 From: Chris54721 Date: Thu, 15 Sep 2016 17:58:40 +0200 Subject: [PATCH 1/5] Add edited_message support --- src/telegram.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/telegram.js b/src/telegram.js index 7359306..6513dc7 100644 --- a/src/telegram.js +++ b/src/telegram.js @@ -82,6 +82,7 @@ class TelegramBot extends EventEmitter { processUpdate(update) { debug('Process Update %j', update); const message = update.message; + const editedMessage = update.edited_message; const inlineQuery = update.inline_query; const chosenInlineResult = update.chosen_inline_result; const callbackQuery = update.callback_query; @@ -120,6 +121,9 @@ class TelegramBot extends EventEmitter { } }); } + } else if (editedMessage) { + debug('Process Update edited_message %j', editedMessage); + this.emit('edited_message', editedMessage); } else if (inlineQuery) { debug('Process Update inline_query %j', inlineQuery); this.emit('inline_query', inlineQuery); From 7518c44997bff7d01e98ded7f96db10522f3427e Mon Sep 17 00:00:00 2001 From: Chris54721 Date: Thu, 15 Sep 2016 18:23:16 +0200 Subject: [PATCH 2/5] Document edited_message event --- README.hbs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.hbs b/README.hbs index eea8e82..8c04606 100644 --- a/README.hbs +++ b/README.hbs @@ -32,8 +32,8 @@ bot.on('message', function (msg) { There are some other examples on [examples](https://github.com/yagop/node-telegram-bot-api/tree/master/examples). ### Events -Every time TelegramBot receives a message, it emits a `message`. Depending on which [message](https://core.telegram.org/bots/api#message) was received, emits an event from this ones: `text`, `audio`, `document`, `photo`, `sticker`, `video`, `voice`, `contact`, `location`, `new_chat_participant`, `left_chat_participant`, `new_chat_title`, `new_chat_photo`, `delete_chat_photo`, `group_chat_created`. Its much better to listen a specific event rather than a `message` in order to stay safe from the content. -TelegramBot emits `inline_query` when receives an [Inline Query](https://core.telegram.org/bots/api#inlinequery) and `chosen_inline_result` when receives a [ChosenInlineResult](https://core.telegram.org/bots/api#choseninlineresult). Bot must be enabled on [inline mode](https://core.telegram.org/bots/api#inline-mode) +Every time TelegramBot receives a message, it emits a `message`. Depending on which [message](https://core.telegram.org/bots/api#message) was received, emits an event from this ones: `text`, `audio`, `document`, `photo`, `sticker`, `video`, `voice`, `contact`, `location`, `new_chat_participant`, `left_chat_participant`, `new_chat_title`, `new_chat_photo`, `delete_chat_photo`, `group_chat_created`. It's much better to listen a specific event rather than a `message` in order to stay safe from the content. +TelegramBot also emits `edited_message` when a message is edited, `inline_query` when it receives an [Inline Query](https://core.telegram.org/bots/api#inlinequery) and `chosen_inline_result` when it receives a [ChosenInlineResult](https://core.telegram.org/bots/api#choseninlineresult). Bot must be enabled on [inline mode](https://core.telegram.org/bots/api#inline-mode). * * * ### WebHooks From bf3302a957a1ccc7db8ed1c249495839a4c6299a Mon Sep 17 00:00:00 2001 From: Chris54721 Date: Thu, 15 Sep 2016 18:24:01 +0200 Subject: [PATCH 3/5] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 01607d5..fc077ab 100644 --- a/README.md +++ b/README.md @@ -32,8 +32,8 @@ bot.on('message', function (msg) { There are some other examples on [examples](https://github.com/yagop/node-telegram-bot-api/tree/master/examples). ### Events -Every time TelegramBot receives a message, it emits a `message`. Depending on which [message](https://core.telegram.org/bots/api#message) was received, emits an event from this ones: `text`, `audio`, `document`, `photo`, `sticker`, `video`, `voice`, `contact`, `location`, `new_chat_participant`, `left_chat_participant`, `new_chat_title`, `new_chat_photo`, `delete_chat_photo`, `group_chat_created`. Its much better to listen a specific event rather than a `message` in order to stay safe from the content. -TelegramBot emits `inline_query` when receives an [Inline Query](https://core.telegram.org/bots/api#inlinequery) and `chosen_inline_result` when receives a [ChosenInlineResult](https://core.telegram.org/bots/api#choseninlineresult). Bot must be enabled on [inline mode](https://core.telegram.org/bots/api#inline-mode) +Every time TelegramBot receives a message, it emits a `message`. Depending on which [message](https://core.telegram.org/bots/api#message) was received, emits an event from this ones: `text`, `audio`, `document`, `photo`, `sticker`, `video`, `voice`, `contact`, `location`, `new_chat_participant`, `left_chat_participant`, `new_chat_title`, `new_chat_photo`, `delete_chat_photo`, `group_chat_created`. It's much better to listen a specific event rather than a `message` in order to stay safe from the content. +TelegramBot also emits `edited_message` when a message is edited, `inline_query` when it receives an [Inline Query](https://core.telegram.org/bots/api#inlinequery) and `chosen_inline_result` when it receives a [ChosenInlineResult](https://core.telegram.org/bots/api#choseninlineresult). Bot must be enabled on [inline mode](https://core.telegram.org/bots/api#inline-mode). * * * ### WebHooks From f9aa16f322727e6ac86e9d90cda6b2a4530a64b8 Mon Sep 17 00:00:00 2001 From: Chris54721 Date: Thu, 15 Sep 2016 18:46:09 +0200 Subject: [PATCH 4/5] Additional edited_message events - edited_message_text - edited_message_caption --- src/telegram.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/telegram.js b/src/telegram.js index 6513dc7..313bff1 100644 --- a/src/telegram.js +++ b/src/telegram.js @@ -124,6 +124,12 @@ class TelegramBot extends EventEmitter { } else if (editedMessage) { debug('Process Update edited_message %j', editedMessage); this.emit('edited_message', editedMessage); + if (editedMessage.text) { + this.emit('edited_message_text', editedMessage); + } + if (editedMessage.caption) { + this.emit('edited_message_caption', editedMessage); + } } else if (inlineQuery) { debug('Process Update inline_query %j', inlineQuery); this.emit('inline_query', inlineQuery); From b308c956ae1490981ab279ee341f941d6a777fb4 Mon Sep 17 00:00:00 2001 From: Chris54721 Date: Thu, 15 Sep 2016 18:48:32 +0200 Subject: [PATCH 5/5] Update documentation --- README.hbs | 5 ++++- README.md | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/README.hbs b/README.hbs index 8c04606..edb9b78 100644 --- a/README.hbs +++ b/README.hbs @@ -33,7 +33,10 @@ There are some other examples on [examples](https://github.com/yagop/node-telegr ### Events Every time TelegramBot receives a message, it emits a `message`. Depending on which [message](https://core.telegram.org/bots/api#message) was received, emits an event from this ones: `text`, `audio`, `document`, `photo`, `sticker`, `video`, `voice`, `contact`, `location`, `new_chat_participant`, `left_chat_participant`, `new_chat_title`, `new_chat_photo`, `delete_chat_photo`, `group_chat_created`. It's much better to listen a specific event rather than a `message` in order to stay safe from the content. -TelegramBot also emits `edited_message` when a message is edited, `inline_query` when it receives an [Inline Query](https://core.telegram.org/bots/api#inlinequery) and `chosen_inline_result` when it receives a [ChosenInlineResult](https://core.telegram.org/bots/api#choseninlineresult). Bot must be enabled on [inline mode](https://core.telegram.org/bots/api#inline-mode). +TelegramBot also emits `edited_message` when a message is edited, and also `edited_message_text` or `edited_message_caption` depending on which type +of message was edited. +If [inline mode](https://core.telegram.org/bots/api#inline-mode) is enabled, it will emit `inline_query` when it receives an [Inline Query](https://core.telegram.org/bots/api#inlinequery) and `chosen_inline_result` when it receives a +[ChosenInlineResult](https://core.telegram.org/bots/api#choseninlineresult). * * * ### WebHooks diff --git a/README.md b/README.md index fc077ab..42297c9 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,10 @@ There are some other examples on [examples](https://github.com/yagop/node-telegr ### Events Every time TelegramBot receives a message, it emits a `message`. Depending on which [message](https://core.telegram.org/bots/api#message) was received, emits an event from this ones: `text`, `audio`, `document`, `photo`, `sticker`, `video`, `voice`, `contact`, `location`, `new_chat_participant`, `left_chat_participant`, `new_chat_title`, `new_chat_photo`, `delete_chat_photo`, `group_chat_created`. It's much better to listen a specific event rather than a `message` in order to stay safe from the content. -TelegramBot also emits `edited_message` when a message is edited, `inline_query` when it receives an [Inline Query](https://core.telegram.org/bots/api#inlinequery) and `chosen_inline_result` when it receives a [ChosenInlineResult](https://core.telegram.org/bots/api#choseninlineresult). Bot must be enabled on [inline mode](https://core.telegram.org/bots/api#inline-mode). +TelegramBot also emits `edited_message` when a message is edited, and also `edited_message_text` or `edited_message_caption` depending on which type +of message was edited. +If [inline mode](https://core.telegram.org/bots/api#inline-mode) is enabled, it will emit `inline_query` when it receives an [Inline Query](https://core.telegram.org/bots/api#inlinequery) and `chosen_inline_result` when it receives a +[ChosenInlineResult](https://core.telegram.org/bots/api#choseninlineresult). * * * ### WebHooks