Please use MessageEntity to determine the message contains a command or not
Closed this issue · 4 comments
Message type contains a field of entities which is an array of MessageEntities ( https://core.telegram.org/bots/api#message ).
And if a message contains a command, there should be an entity of bot_command
with an offset of 0.
( https://core.telegram.org/bots/api#messageentity ).
If we only use starts_with("/")
to determine it is a command or not, fixed width or bold texts (which aren't bot commands) will also be accepted.
Ups I missed that in the documentation, this is indeed a more reliable way to find bot command. Perhaps I find time to change it later this day.
I have one question: can the entities field contains multiply bot commands with different offset, so that you have for example "/cmd1 /cmd2 /cmd3"?
@bytesnake
I've just tested it, and yes, entities can contain multiple bot_command
.
(e.g. "entities":[{"offset":0,"length":5,"type":"bot_command"},{"offset":6,"length":5,"type":"bot_command"}]
)
I think we only need to respond to the the one with offset 0...