Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Telegram bot - Get user response (command) from keyboard without slash

I want get a command from custom keyboard, without slash.
I read in other issue and inthe documentation, that this is not possible, the commands must always start with the ‘/’ symbol.
But in many bots i see that is possible.
For example @TriviaBot
I thought to get the string before the trigger start and add "/" to the string but without success.
Other solutions?

PS: I'm developing my bot in php using this API
https://github.com/irazasyed/telegram-bot-sdk

like image 221
frencisdrame Avatar asked Mar 11 '26 20:03

frencisdrame


1 Answers

Telegram Bot Commands must be start with a slash /.

However, its are sent to bot as standard message, so the effective bot behavior is totally delegate to it.

If you want to use a string as command, you can do it simply processing the text message. I.e.:

if( $text == 'myCommand' )
{
    // Do Something...
}

Obviously, you have to consider possible ambiguities with a not-command message.

like image 97
fusion3k Avatar answered Mar 14 '26 09:03

fusion3k



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!