Answer the question
In order to leave comments, you need to log in
Telegram bot access?
Hello everyone, I've run into a problem.
I made a registration for access to the bot, so that it would not be available to everyone.
I store chat.id in the database.
The user writes a certain command, I get a message from the bot that someone wants to register, and I either confirm or reject the registration.
After confirmation, the new chat.id of the user is registered in the database, but the bot still writes that access is limited.
And so it will be until I restart the bot. What am I doing wrong?
Access did this:
@bot.message_handler(func=lambda message: str(message.chat.id) not in users)
def send_deny_message(message):
bot.send_message(message.chat.id, "Нет доступа!")
Answer the question
In order to leave comments, you need to log in
rewrite the code, the function to receive all messages. Inside the function, make a request to the database and then check if the user has access or not, in your version, only those who are already registered in the database at the time the program starts will work.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question