Not accepting commands in "/command@botusername" format.
Closed this issue · 8 comments
The example here won't respond to commands in "/command@botusername" format but only to "/command".
Am I using the library in a wrong way?
Hey, I'm not familiar with this syntax, is it like a command executed for an inline bot? Can you point to some examples in the Telegram documentation?
I mean you could just register the command "/command@botusername", but I have the feeling that you are looking for something else.
Thanks for the reply.
For example, I have a bot and it’s username is “@somewhatbot”, and I set a command at BotFather which is /command.Now if I type / in a group with this bot, Telegram will provide an auto-completion in a format of “/command@somewhatbot”. If I only register the “/command” in the program then the bot won’t respond to it.
Register an additional command can fix it, but it’s kind of messy. If the library can support commands in that format directly would be better.
Bot API provides getMe so it won’t be hard to implement.
Sorry for my poor English... XD
Mh I never heard about this feature. Perhaps you can set the command list directly in the BotFather (https://stackoverflow.com/questions/34457568/how-to-show-options-in-telegram-bot)? Can you perhaps point me to some documentation in the specs of the Bot API.
Sorry for the delay, I was busy for the last couple of days
So... for example, I have a bot with username @pakreqBot, and I've set a command of /pakreq
at BotFather.
Then I invite it into a group, and type /
or click the "/" icon near the send button, an auto-completion menu will appear:
Then I click /pakreq, it will send the command as /pakreq@pakreqBot
automatically.
(This bot isn't using telebot so it will respond correctly.)
The problem is, if I only register a command of /pakreq
in telebot, while running the bot will not respond to "/pakreq@pakreqBot" but only to /pakreq
.
Ah I see, this is definitely possible. Do you want to give it a try? here is a short list what you need to change:
- add a field "name: RefCell" to the Bot struct in bot.rs
- call get_me().send() in the run function in bot.rs and map the result to the name field
- extend the filter_map in get_stream to look for the command OR the command + @bot_name
Otherwise I will implement it next week. Have a nice weekend.
Sorry for replying this late. I would like to have a try but I have no confidence for doing it 😂
Update:
I need some time to learn how to use futures, so...