Issue
Is there anyway that telegram bot can set commands that is available for administrator only? Because I wanted to implement a function that only admins of the telegram bot can use, not for other users.
Solution
With python-telegram-bot
there are several ways to do that. A decorator as inyrface suggested can work - see also here and here for a way to cache the admins list. Another option is to user Filters.user
. Finally, ptbcontrib/roles
has a built-in cached admin check.
in addition to all of that, you can set up the commands such that in the gui they are only visible to admins - using BotCommandScopeChatAdministrators
. This doesn't prevent other users from manually typing the command, but's an additional step.
Disclaimer: I.m currently the maintainer of python-telegram-bot
Answered By - CallMeStag
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.