Skip to content

Commit

Permalink
Expose message.type to 'message'
Browse files Browse the repository at this point in the history
Closes yagop#409
  • Loading branch information
jlsjonas authored Aug 24, 2017
1 parent 28160c7 commit ab4dbe4
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/telegram.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit ab4dbe4

Please sign in to comment.