Closed hanigamini closed 9 years ago
1) Commands are simple incoming text messages, starting with "/", you can detect them with Message.Text.StartsWith("/")
. But don't forget to normalize case to correctly detect user commands in different case (like "/MyCommand" and "/mycommand"). "Registering" commands for your bot (with BotFather) is not obligatory, but desirable (they will be included in /help command, and TG client will enable auto-complete when user press "/" key). And AFAIK telegram does NOT currently supports registration of utf-8 commands (only latin), but they work as soon as they are simple messages.
2) Send new SetWebhook(url)
request (added ~12h ago, in version 3.4.50815) when you start your bot, then listen for incoming POST request (implement yourself, it depends of your system architecture) and call DeserializeUpdate
method to convert json text to Update
class. When shutting bot down - call SetWebhook
with null param to disable webhooks (Telegram will not try to send you updates while you are not listening).
Hi, Thanks for your good support and response , about SetWebhook i do not understand , Where should I set url in telegram ?
According to Telegram rules, to work with webhooks you must run HTTPS-enabled website/service, where TG server will make HTTP POST requests for each message. So, after you create such website/service - call SetWebhook with url of your website/service.
Thank you very much, How i send message to all user that add my bot?
you need save all ids of users.
Thank you very much
Hi, thanks for your good code. i have 2 question : 1 - How do I use command with / in bot ? 2 - How do I use web hook?