From 4de1609d4e3bd87316b059fd4f2a8b637482d6ce Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Sun, 26 Feb 2023 11:17:12 +0100 Subject: [PATCH] Fix ChatAction for groups with hidden members --- telethon/events/chataction.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/telethon/events/chataction.py b/telethon/events/chataction.py index 8261d6e1..46563059 100644 --- a/telethon/events/chataction.py +++ b/telethon/events/chataction.py @@ -108,6 +108,17 @@ class ChatAction(EventBuilder): return cls.Event(msg, new_score=action.score) + elif isinstance(update, types.UpdateChannelParticipant) \ + and bool(update.new_participant) != bool(update.prev_participant): + # If members are hidden, bots will receive this update instead, + # as there won't be a service message. Promotions and demotions + # seem to have both new and prev participant, which are ignored + # by this event. + return cls.Event(types.PeerChannel(update.channel_id), + users=update.user_id, + added_by=update.actor_id if update.new_participant else None, + kicked_by=update.actor_id if update.prev_participant else None) + class Event(EventCommon): """ Represents the event of a new chat action. @@ -142,7 +153,7 @@ class ChatAction(EventBuilder): new_title (`str`, optional): The new title string for the chat, if applicable. - + new_score (`str`, optional): The new score string for the game, if applicable.