I’m using telebot (https://github.com/eternnoir/pyTelegramBotAPI) to create a bot to send photos to its users. The point is I didn’t see a way to restrict the access to this bot as I intend to share private images through this bot.
I read in this forum that through python-telegram-bot there is a way to limit the access from the sender’s message (How To Limit Access To A Telegram Bot), but I didn’t know if via pyTelegramBotAPI it is possible.
Do you know how can I solve it?
2
Answers
The easiest way is probably a hard coded check on the user id.
A bit late tot the party – perhaps for future post readers. You can wrap the function to disallow access.
An example below:
Then where you are handling commands you can restrict access to the command like this:
Keep in mind, order matters. First the message-handler and then your custom decorator – or it will not work.