I'm developing a bot in telegram , here is my problem: I have some posts in my channel which some inline_keyboards are attached to them. when a user press the button , next events happen in a bot and some messages show to a user. if user has been started the bot before , there is no problem , if not I have error. how should I check the user is member of my bot or not to handle this problem???
3 Answers
try to use sendMessage() API and send a message to user. After that telegram will response a status tell you whether success or not.
if started bot receive receive is ok, if not started bot receive is nothing.
{"ok":true,"result":{"message_id":9999,"from":{"id":00000000,"is_bot":true,"first_name":"mybot","username":"mybot"}}}
like that, good luck.
There is no way to check if bot can talk to user or not without send message.
You can use url with https://t.me/Bot?start=some_data
format, and you will receive /start some_data
, please try this link yourself.
The problem with this approach is that if a lot of users do the same, telegram starts to throttle your callbacks :( ... it would be so much easier if you could just read that information somewhere...