Answer the question
In order to leave comments, you need to log in
How to restrict access to a telegram bot?
Hello.
There is a certain bot, tell me please, how to allow him access only to certain users?
Interested in the method through the white list of chat id users.
If a person writes, and his chat id is on the list, it can work, if not, then nothing happens, or there will be an answer that you do not have access to the bot.
Thank you.
Answer the question
In order to leave comments, you need to log in
Use a handler at the beginning with a check for the presence of id in a variable (or in something else)
Example for python + telebot
@bot.message_handler(func=lambda message: message.chat.id not in users)
def some(message):
bot.send_message(message.chat.id, "Sorry")
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question