diff --git a/examples/id_filter_example.py b/examples/id_filter_example.py index 64dc3b3f..343253e3 100644 --- a/examples/id_filter_example.py +++ b/examples/id_filter_example.py @@ -1,37 +1,35 @@ from aiogram import Bot, Dispatcher, executor, types from aiogram.dispatcher.handler import SkipHandler -API_TOKEN = 'API_TOKE_HERE' + +API_TOKEN = 'BOT_TOKEN_HERE' bot = Bot(token=API_TOKEN) dp = Dispatcher(bot) -user_id_to_test = None # todo: Set id here -chat_id_to_test = user_id_to_test +user_id_required = None # TODO: Set id here +chat_id_required = user_id_required # Change for use in groups (user_id == chat_id in pm) -@dp.message_handler(user_id=user_id_to_test) +@dp.message_handler(user_id=user_id_required) async def handler1(msg: types.Message): - await bot.send_message(msg.chat.id, - "Hello, checking with user_id=") - raise SkipHandler + await bot.send_message(msg.chat.id, "Hello, checking with user_id=") + raise SkipHandler # just for demo -@dp.message_handler(chat_id=chat_id_to_test) +@dp.message_handler(chat_id=chat_id_required) async def handler2(msg: types.Message): - await bot.send_message(msg.chat.id, - "Hello, checking with chat_id=") - raise SkipHandler + await bot.send_message(msg.chat.id, "Hello, checking with chat_id=") + raise SkipHandler # just for demo -@dp.message_handler(user_id=user_id_to_test, chat_id=chat_id_to_test) +@dp.message_handler(user_id=user_id_required, chat_id=chat_id_required) async def handler3(msg: types.Message): - await bot.send_message(msg.chat.id, - "Hello from user= & chat_id=") + await msg.reply("Hello from user= & chat_id=", reply=False) -@dp.message_handler(user_id=[user_id_to_test, 123]) # todo: add second id here +@dp.message_handler(user_id=[user_id_required, 42]) # TODO: You can add any number of ids here async def handler4(msg: types.Message): - print("Checked user_id with list!") + await msg.reply("Checked user_id with list!", reply=False) if __name__ == '__main__':