edisonchee / slimbot

Telegram Bot API for Node.js
MIT License
223 stars 37 forks source link

[QUESTION] How can I listen for a specific command ? #22

Closed sinout closed 6 years ago

sinout commented 6 years ago

E.g how can I listen for /start command ? Is this available only by parsing message text property or by entities[0].type ?

edisonchee commented 6 years ago

Hi @sinout, you can do this:

slimbot.on('message', message => {
  if (message.text === '/start') {
    // do your thing here when someone uses the /start command
  }
});
sinout commented 6 years ago

Yeah, thank you. Just wanted to know if there are any predefined listeners for commands.