Open Khalanar opened 7 years ago
I am trying to pass an array too:
var hello = ["hello", "Hello", "HELLO"];
when ( new TextCommand(hello, 'greetingCommand'), GreetingController())
But it's not working either. Am i doing something wrong?
Thanks!
Maybe you should try with .otherwise and then filter the command or message inside!
Hi Jesús, thanks for your reply. I actually managed to fix this with regex. If someone else is interested, you can pass several strings to a regex like this: /string1|string2|string3/i Where "i" marks all strings as non case sensitive.
Snippet of my actual code: var hello = /hola|hello|hi|ey/i; tg.router .when(new Telegram.RegexpCommand ( hello, 'helloCommand'), todoCtrl)
I hope it helps any one else trying to achieve something similar.
A solution is :
class RegexController extends TelegramBaseController {
helloregexHandler($) {
$.sendMessage('Hi !')
}
get routes() {
return {
'helloregexCommand': 'helloregexHandler'
}
}
}
var hello = /hola|hello|hi|ey/i;
tg.router
.when(
new RegexpCommand(hello, 'helloregexCommand'),
new RegexController()
)
:+1:
Hi all,
Is there any way of checking for multiple strings in a single call? Something like when ( new TextCommand('hello' || 'Hello', 'greetingCommand'), GreetingController())
I've tried several things and have been utterly unsuccessful.
Thanks!