Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add IDFilter support for ChatJoinRequest events #983

Merged
merged 1 commit into from Aug 29, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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