Skip to content

Commit e89bd93

Browse files
Princic-1837592alissonlauffer
authored andcommitted
Added CallbackQuery support to other filters
Squashed commit of the following: commit ae78045 Author: Andrea Princic <48788808+Princic-1837592@users.noreply.github.com> Date: Thu Feb 3 15:03:23 2022 +0100 Added CallbackQuery support to other filters commit 7ff0465 Author: Andrea Princic <48788808+Princic-1837592@users.noreply.github.com> Date: Sat Jan 29 19:08:14 2022 +0100 Now filters.group supports callback queries
1 parent d9dbdd3 commit e89bd93

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

pyrogram/filters.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -439,8 +439,9 @@ async def media_spoiler_filter(_, __, m: Message):
439439
# endregion
440440

441441
# region private_filter
442-
async def private_filter(_, __, m: Message):
443-
return bool(m.chat and m.chat.type in {enums.ChatType.PRIVATE, enums.ChatType.BOT})
442+
async def private_filter(_, __, u: Update):
443+
m = u.message if isinstance(u, CallbackQuery) else u
444+
return bool(m and m.chat and m.chat.type in {enums.ChatType.PRIVATE, enums.ChatType.BOT})
444445

445446

446447
private = create(private_filter)
@@ -450,8 +451,9 @@ async def private_filter(_, __, m: Message):
450451
# endregion
451452

452453
# region group_filter
453-
async def group_filter(_, __, m: Message):
454-
return bool(m.chat and m.chat.type in {enums.ChatType.GROUP, enums.ChatType.SUPERGROUP})
454+
async def group_filter(_, __, u: Update):
455+
m = u.message if isinstance(u, CallbackQuery) else u
456+
return bool(m and m.chat and m.chat.type in {enums.ChatType.GROUP, enums.ChatType.SUPERGROUP})
455457

456458

457459
group = create(group_filter)
@@ -461,8 +463,9 @@ async def group_filter(_, __, m: Message):
461463
# endregion
462464

463465
# region channel_filter
464-
async def channel_filter(_, __, m: Message):
465-
return bool(m.chat and m.chat.type == enums.ChatType.CHANNEL)
466+
async def channel_filter(_, __, u: Update):
467+
m = u.message if isinstance(u, CallbackQuery) else u
468+
return bool(m and m.chat and m.chat.type == enums.ChatType.CHANNEL)
466469

467470

468471
channel = create(channel_filter)

0 commit comments

Comments
 (0)