make ChatTypeFilter work with inline queries

This commit is contained in:
abrikk 2022-05-17 17:39:10 +05:00
parent 8d58ed909d
commit d41074972f
2 changed files with 9 additions and 5 deletions

View file

@ -728,18 +728,20 @@ class ChatTypeFilter(BoundFilter):
self.chat_type: typing.Set[str] = set(chat_type)
async def check(self, obj: Union[Message, CallbackQuery, ChatMemberUpdated]):
async def check(self, obj: Union[Message, CallbackQuery, ChatMemberUpdated, InlineQuery]):
if isinstance(obj, Message):
obj = obj.chat
chat_type = obj.chat.type
elif isinstance(obj, CallbackQuery):
obj = obj.message.chat
chat_type = obj.message.chat.type
elif isinstance(obj, ChatMemberUpdated):
obj = obj.chat
chat_type = obj.chat.type
elif isinstance(obj, InlineQuery):
chat_type = obj.chat_type
else:
warnings.warn("ChatTypeFilter doesn't support %s as input", type(obj))
return False
return obj.type in self.chat_type
return chat_type in self.chat_type
class MediaGroupFilter(BoundFilter):

View file

@ -652,6 +652,7 @@ class ChatType(helper.Helper):
"""
List of chat types
:key: SENDER
:key: PRIVATE
:key: GROUP
:key: SUPER_GROUP
@ -661,6 +662,7 @@ class ChatType(helper.Helper):
mode = helper.HelperMode.lowercase
SENDER = helper.Item() # sender
PRIVATE = helper.Item() # private
GROUP = helper.Item() # group
SUPERGROUP = helper.Item() # supergroup