python-3.xbotstelegramtelegram-botpy-telegram-bot-api

Checking bot for admin permissions pytelegrambotapi python


I had a question: is there a way to check bot itself for admin permissions? If bot has got an admin permissions such as deleting messages,restricting users it should send message that it has admin permissions, else it should say "give me admin". I am using pytelegrambotapi, python. Thank you! Python 3.7


Solution

  • You can check using get_chat_administrators

    1. Get admin list of the chat.
    2. Check if bot's ID is in the IDs of admins of the chat