Node-telegram-bot-api: onText with two commands

Created on 19 Apr 2018  路  1Comment  路  Source: yagop/node-telegram-bot-api

Is there a way to let the bot listen on two commands?
My try was:
bot.onText(/^(\/cmd1||\/cmd2)/, function(msg, match) {})
But I was not able to get it to work.

Most helpful comment

Only one |, no brackets and ^ also on second option.
Use website like regex101 to test before :)
bot.onText(/^\/cmd1|^\/cmd2/, function(msg, match) {})

>All comments

Only one |, no brackets and ^ also on second option.
Use website like regex101 to test before :)
bot.onText(/^\/cmd1|^\/cmd2/, function(msg, match) {})

Was this page helpful?
0 / 5 - 0 ratings