Skip to content

Commit f0ab18f

Browse files
authored
Add show_message_sender_enabled, has_aggressive_anti_spam_enabled, has_protected_content, is_forum to ChatEvent
1 parent 9199ea4 commit f0ab18f

File tree

3 files changed

+66
-2
lines changed

3 files changed

+66
-2
lines changed

pyrogram/enums/chat_event_action.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,5 +132,17 @@ class ChatEventAction(AutoName):
132132
MEMBER_SUBSCRIPTION_EXTENDED = auto()
133133
"A chat member extended their subscription to the chat (``old_chat_member`` and ``new_chat_member``)"
134134

135+
SHOW_MESSAGE_SENDER_ENABLED = auto()
136+
"the show message senders have been enabled or disabled (see ``show_message_sender_enabled``)"
137+
138+
AGGRESSIVE_ANTI_SPAM_TOGGLED = auto()
139+
"The ``has_aggressive_anti_spam_enabled`` setting of a supergroup was toggled. (see ``has_aggressive_anti_spam_enabled``)"
140+
141+
PROTECTED_CONTENT_TOGGLED = auto()
142+
"The ``has_protected_content`` setting of a channel was toggled (see ``has_protected_content``)"
143+
144+
CHAT_IS_FORUM_TOGGLED = auto()
145+
"The ``is_forum`` setting of a channel was toggled. (see ``is_forum``)"
146+
135147
UNKNOWN = auto()
136148
"Unknown chat event action"

pyrogram/types/user_and_chats/chat_event.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,22 @@ class ChatEvent(Object):
150150
Affected chat member status of the user.
151151
For :obj:`~pyrogram.enums.ChatEventAction.MEMBER_SUBSCRIPTION_EXTENDED` action only.
152152
153+
show_message_sender_enabled (``bool``, *optional*):
154+
The show_message_sender setting of a channel was toggled.
155+
For :obj:`~pyrogram.enums.ChatEventAction.SHOW_MESSAGE_SENDER_ENABLED` action only.
156+
157+
has_aggressive_anti_spam_enabled (``bool``, *optional*):
158+
The ``has_aggressive_anti_spam_enabled`` setting of a supergroup was toggled.
159+
For :obj:`~pyrogram.enums.ChatEventAction.AGGRESSIVE_ANTI_SPAM_TOGGLED` action only.
160+
161+
has_protected_content (``bool``, *optional*):
162+
The ``has_protected_content`` setting of a channel was toggled.
163+
For :obj:`~pyrogram.enums.ChatEventAction.PROTECTED_CONTENT_TOGGLED` action only.
164+
165+
is_forum (``bool``, *optional*):
166+
The ``is_forum`` setting of a channel was toggled.
167+
For :obj:`~pyrogram.enums.ChatEventAction.CHAT_IS_FORUM_TOGGLED` action only.
168+
153169
"""
154170

155171
def __init__(
@@ -220,6 +236,11 @@ def __init__(
220236

221237
old_chat_member: "types.ChatMember" = None,
222238
new_chat_member: "types.ChatMember" = None,
239+
240+
show_message_sender_enabled: bool = None,
241+
has_aggressive_anti_spam_enabled: bool = None,
242+
has_protected_content: bool = None,
243+
is_forum: bool = None,
223244
):
224245
super().__init__()
225246

@@ -290,6 +311,11 @@ def __init__(
290311
self.old_chat_member = old_chat_member
291312
self.new_chat_member = new_chat_member
292313

314+
self.show_message_sender_enabled = show_message_sender_enabled
315+
self.has_aggressive_anti_spam_enabled = has_aggressive_anti_spam_enabled
316+
self.has_protected_content = has_protected_content
317+
self.is_forum = is_forum
318+
293319
@staticmethod
294320
async def _parse(
295321
client: "pyrogram.Client",
@@ -365,6 +391,11 @@ async def _parse(
365391
old_chat_member: Optional[types.ChatMember] = None
366392
new_chat_member: Optional[types.ChatMember] = None
367393

394+
show_message_sender_enabled: Optional[bool] = None
395+
has_aggressive_anti_spam_enabled: Optional[bool] = None
396+
has_protected_content: Optional[bool] = None
397+
is_forum: Optional[bool] = None
398+
368399
if isinstance(action, raw.types.ChannelAdminLogEventActionChangeAbout):
369400
old_description = action.prev_value
370401
new_description = action.new_value
@@ -509,6 +540,22 @@ async def _parse(
509540
new_chat_member = types.ChatMember._parse(client, action.new_participant, users, chats)
510541
action = enums.ChatEventAction.MEMBER_SUBSCRIPTION_EXTENDED
511542

543+
elif isinstance(action, raw.types.ChannelAdminLogEventActionToggleSignatureProfiles):
544+
show_message_sender_enabled = action.new_value
545+
action = enums.ChatEventAction.SHOW_MESSAGE_SENDER_ENABLED
546+
547+
elif isinstance(action, raw.types.ChannelAdminLogEventActionToggleAntiSpam):
548+
has_aggressive_anti_spam_enabled = action.new_value
549+
action = enums.ChatEventAction.AGGRESSIVE_ANTI_SPAM_TOGGLED
550+
551+
elif isinstance(action, raw.types.ChannelAdminLogEventActionToggleNoForwards):
552+
has_protected_content = action.new_value
553+
action = enums.ChatEventAction.PROTECTED_CONTENT_TOGGLED
554+
555+
elif isinstance(action, raw.types.ChannelAdminLogEventActionToggleForum):
556+
is_forum = action.new_value
557+
action = enums.ChatEventAction.CHAT_IS_FORUM_TOGGLED
558+
512559
else:
513560
action = f"{enums.ChatEventAction.UNKNOWN}-{action.QUALNAME}"
514561

@@ -579,4 +626,9 @@ async def _parse(
579626

580627
old_chat_member=old_chat_member,
581628
new_chat_member=new_chat_member,
629+
630+
show_message_sender_enabled=show_message_sender_enabled,
631+
has_aggressive_anti_spam_enabled=has_aggressive_anti_spam_enabled,
632+
has_protected_content=has_protected_content,
633+
is_forum=is_forum,
582634
)

pyrogram/types/user_and_chats/chat_event_filter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,6 @@ def write(self) -> "raw.base.ChannelAdminLogEventsFilter":
194194
group_call=group_call,
195195
invites=invites,
196196
# send
197-
forums=forum_changes.
198-
sub_extend=subscription_extensions
197+
forums=forum_changes,
198+
sub_extend=subscription_extensions,
199199
)

0 commit comments

Comments
 (0)