From ab4dbe4d8c6dc552c6678aaddd46c165b3222a65 Mon Sep 17 00:00:00 2001 From: Jonas De Kegel Date: Thu, 24 Aug 2017 17:57:32 +0200 Subject: [PATCH] Expose message.type to 'message' Closes #409 --- src/telegram.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/telegram.js b/src/telegram.js index c7a53142..00ea648e 100644 --- a/src/telegram.js +++ b/src/telegram.js @@ -491,11 +491,13 @@ class TelegramBot extends EventEmitter { if (message) { debug('Process Update message %j', message); - this.emit('message', message); const processMessageType = messageType => { if (message[messageType]) { debug('Emitting %s: %j', messageType, message); this.emit(messageType, message); + this.emit('message', { ...message, type: messageType }); + } else { + this.emit('message', message); } }; TelegramBot.messageTypes.forEach(processMessageType);