Telegram-bot user control

I want to create a telegram bot for a home project and I want the bot to only talk to 3 people, how can I do that? I thought to create a file with the chat id of each of us and check it before responding to any command, I think it will work. the bot will send the correct information if he is one of us and "goodbye" to any other

But is there any other way to block any other conversation with my bot?

Pd: I am using python-telegram-bot

+3


source to share


1 answer


In the first part of your question, you can create a private group and add your bot as one of your admins. He can then talk to members and respond to their commands.

Even if you don't want to do this, it is possible by checking the chatID of every update the bot receives. If the chatID exists in a file, DataBase, or even a simple array, the bot responds to the command, and if it just ignores or sends plain text like what you said goodbye.



Please note that bots cannot block people, they can ignore their messages.

+1


source







All Articles