telegram-node-bot icon indicating copy to clipboard operation
telegram-node-bot copied to clipboard

Multiple commands

Open jokame opened this issue 8 years ago • 6 comments

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()"?

jokame avatar Oct 05 '16 22:10 jokame

Do you want to accept case insensitive commands? I guess you should use RegexpCommand.

chiu0602 avatar Oct 06 '16 08:10 chiu0602

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

ocordeiro avatar Oct 08 '16 23:10 ocordeiro

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())

MikhailMS avatar Oct 09 '16 22:10 MikhailMS

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

ocordeiro avatar Oct 09 '16 23:10 ocordeiro

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.

MikhailMS avatar Oct 09 '16 23:10 MikhailMS

Hi all, any luck with this? Im trying a similar thing and can't get it right.

Thanks!

Khalanar avatar Feb 20 '17 19:02 Khalanar