Skip to content

Commit

Permalink
Add IDFilter support for ChatJoinRequest events (#983)
Browse files Browse the repository at this point in the history
  • Loading branch information
nsychev committed Aug 29, 2022
1 parent 7214ba2 commit 87a8b50
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions aiogram/dispatcher/filters/builtin.py
Expand Up @@ -10,7 +10,7 @@

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]

Expand Down Expand Up @@ -619,7 +619,7 @@ def validate(cls, full_config: typing.Dict[str, typing.Any]) -> typing.Optional[

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:
Expand All @@ -637,6 +637,9 @@ async def check(self, obj: Union[Message, CallbackQuery, InlineQuery, ChatMember
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

Expand Down

0 comments on commit 87a8b50

Please sign in to comment.