Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose the message type to on('message') #409

Closed
jlsjonas opened this issue Aug 22, 2017 · 1 comment
Closed

Expose the message type to on('message') #409

jlsjonas opened this issue Aug 22, 2017 · 1 comment

Comments

@jlsjonas
Copy link

jlsjonas commented Aug 22, 2017

Feature Request

I have:

  • searched for such a feature request ( enhancement ) and found none

Introduction

Especially useful for logging/tracking purposes, expose the message type to the message event, avoiding code duplication just to find out the message type

Example

bot.on('message', function onMessage(msg) {
  botan.track(msg, (msg.text)?msg.text.split(' ')[0]:msg.type);
}

(example using botanio, but would be applicable to pretty much any tracking library/system, the msg.text part is added as a more complete example, to track commands)

jlsjonas added a commit to jlsjonas/node-telegram-bot-api that referenced this issue Aug 24, 2017
GochoMugo added a commit that referenced this issue Nov 18, 2017
@GochoMugo
Copy link
Collaborator

v0.30.0 passes metadata to the message event. For example,

bot.on("message", function(message, metadata) {
    console.log(metadata.type); // e.g. "photo"
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants