diff --git a/aiogram/dispatcher/filters/builtin.py b/aiogram/dispatcher/filters/builtin.py index d64fb97a..5615964c 100644 --- a/aiogram/dispatcher/filters/builtin.py +++ b/aiogram/dispatcher/filters/builtin.py @@ -522,14 +522,10 @@ class IdFilter(Filter): @classmethod def validate(cls, full_config: typing.Dict[str, typing.Any]) -> typing.Optional[typing.Dict[str, typing.Any]]: result = {} - if 'user' in full_config: - result['user_id'] = full_config.pop('user') - elif 'user_id' in full_config: + if 'user_id' in full_config: result['user_id'] = full_config.pop('user_id') - if 'chat' in full_config: - result['chat_id'] = full_config.pop('chat') - elif 'chat_id' in full_config: + if 'chat_id' in full_config: result['chat_id'] = full_config.pop('chat_id') return result diff --git a/examples/id_filter_example.py b/examples/id_filter_example.py index b46ab056..64dc3b3f 100644 --- a/examples/id_filter_example.py +++ b/examples/id_filter_example.py @@ -9,43 +9,29 @@ user_id_to_test = None # todo: Set id here chat_id_to_test = user_id_to_test -@dp.message_handler(user=user_id_to_test) -async def handler1(msg: types.Message): - await bot.send_message(msg.chat.id, - "Hello, checking with user=") - raise SkipHandler - - @dp.message_handler(user_id=user_id_to_test) -async def handler2(msg: types.Message): +async def handler1(msg: types.Message): await bot.send_message(msg.chat.id, "Hello, checking with user_id=") raise SkipHandler -@dp.message_handler(chat=chat_id_to_test) -async def handler3(msg: types.Message): - await bot.send_message(msg.chat.id, - "Hello, checking with chat=") - raise SkipHandler - - @dp.message_handler(chat_id=chat_id_to_test) -async def handler4(msg: types.Message): +async def handler2(msg: types.Message): await bot.send_message(msg.chat.id, "Hello, checking with chat_id=") raise SkipHandler -@dp.message_handler(user=user_id_to_test, chat_id=chat_id_to_test) -async def handler5(msg: types.Message): +@dp.message_handler(user_id=user_id_to_test, chat_id=chat_id_to_test) +async def handler3(msg: types.Message): await bot.send_message(msg.chat.id, "Hello from user= & chat_id=") -@dp.message_handler(user=[user_id_to_test, 123]) # todo: add second id here -async def handler6(msg: types.Message): - print("Checked with list!") +@dp.message_handler(user_id=[user_id_to_test, 123]) # todo: add second id here +async def handler4(msg: types.Message): + print("Checked user_id with list!") if __name__ == '__main__':