Fix issues and rework AdminFilter

This commit is contained in:
Arslan 'Ars2014' Sakhapov 2019-08-08 20:53:52 +05:00
parent 9f6b577f08
commit c0e60f8706
5 changed files with 58 additions and 29 deletions

View file

@ -2,26 +2,31 @@ import logging
from aiogram import Bot, Dispatcher, types, executor
API_TOKEN = 'API TOKEN HERE'
API_TOKEN = 'API_TOKEN_HERE'
logging.basicConfig(level=logging.DEBUG)
bot = Bot(token=API_TOKEN)
dp = Dispatcher(bot=bot)
chat_id = -1001241113577
# checks specified chat
@dp.message_handler(admin_chat_id=chat_id)
async def handler(msg: types.Message):
await msg.reply(f"You are an admin of the chat '{chat_id}'", reply=False)
@dp.message_handler(is_chat_admin=-1001241113577)
async def handle_specified(msg: types.Message):
await msg.answer("You are an admin of the specified chat!")
# checks multiple chats
@dp.message_handler(is_chat_admin=[-1001241113577, -320463906])
async def handle_multiple(msg: types.Message):
await msg.answer("You are an admin of multiple chats!")
# checks current chat
@dp.message_handler(admin_current_chat=True)
async def handler(msg: types.Message):
await msg.reply("You are an admin of the current chat!", reply=False)
@dp.message_handler(is_chat_admin=True)
async def handler3(msg: types.Message):
await msg.answer("You are an admin of the current chat!")
if __name__ == '__main__':