telegram-node-bot
telegram-node-bot copied to clipboard
Multiple commands
In the previous version, I could make something like
tg.router .when(['command', 'Command', 'COMMAND'], new CommandController())
Now I can't with the new version. Is the unique way to achieve this declare multiple times the "new TextCommand()"?
Do you want to accept case insensitive commands? I guess you should use RegexpCommand
.
Really. I'am receiving this error using multiples commands array:
TypeError: command.test is not a function
at TelegramRoute.test (/node_modules/telegram-node-bot/lib/routing/TelegramRoute.js:33:25)
Probably because of this implementation https://github.com/Naltox/telegram-node-bot/commit/865d9c435777889149567da8b6369e0e58a363e8#diff-5d0478b9911fd18a6c78d0b1bcd7b310R26 in 4.0 Version
If you are planning to use RegexpCommand and you getting this error
TypeError: command.test is not a function
at TelegramRoute.test (/node_modules/telegram-node-bot/lib/routing/TelegramRoute.js:33:25)
Just pass an RegExp object rather than a string as it stated in Readme example. It should be something like this
.when(new RegexpCommand(new RegExp('query','i'), 'NameCommand'),
new NameController())
Thanks. but the README describes this structure and does not works
.when(['/sum :num1 :num2'], new SumController())
https://github.com/Naltox/telegram-node-bot#scope-extensions
Yeah, but it's completely different thing. This one is about RegExp and yours is about retrieving parameters. I have asked this one already, but still no answer. Worth digging previous version and see how it worked there.
Hi all, any luck with this? Im trying a similar thing and can't get it right.
Thanks!