E
E
enabl32017-12-29 13:44:20
Access rights
enabl3, 2017-12-29 13:44:20

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

1 answer(s)
S
sar0ka8, 2017-12-29
@enabl3

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 question

Ask a Question

731 491 924 answers to any question