mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Added AdminFilter and example of its usage
This commit is contained in:
parent
8823c8f22a
commit
bd032f066e
4 changed files with 76 additions and 2 deletions
28
examples/admin_filter_example.py
Normal file
28
examples/admin_filter_example.py
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
import logging
|
||||
|
||||
from aiogram import Bot, Dispatcher, types, executor
|
||||
|
||||
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)
|
||||
|
||||
|
||||
# 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)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
executor.start_polling(dp)
|
||||
Loading…
Add table
Add a link
Reference in a new issue