Add IDFilter support for ChatJoinRequest events (#983)

This commit is contained in:
Nikita Sychev 2022-08-30 01:24:22 +03:00 committed by GitHub
parent 7214ba2f4b
commit 87a8b50949
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -10,7 +10,7 @@ from babel.support import LazyProxy
from aiogram import types
from aiogram.dispatcher.filters.filters import BoundFilter, Filter
from aiogram.types import CallbackQuery, ChatType, InlineQuery, Message, Poll, ChatMemberUpdated, BotCommand
from aiogram.types import CallbackQuery, ChatType, InlineQuery, Message, Poll, ChatMemberUpdated, BotCommand, ChatJoinRequest
ChatIDArgumentType = typing.Union[typing.Iterable[typing.Union[int, str]], str, int]
@ -619,7 +619,7 @@ class IDFilter(Filter):
return result
async def check(self, obj: Union[Message, CallbackQuery, InlineQuery, ChatMemberUpdated]):
async def check(self, obj: Union[Message, CallbackQuery, InlineQuery, ChatMemberUpdated, ChatJoinRequest]):
if isinstance(obj, Message):
user_id = None
if obj.from_user is not None:
@ -637,6 +637,9 @@ class IDFilter(Filter):
elif isinstance(obj, ChatMemberUpdated):
user_id = obj.from_user.id
chat_id = obj.chat.id
elif isinstance(obj, ChatJoinRequest):
user_id = obj.from_user.id
chat_id = obj.chat.id
else:
return False