Fix ChatAction for groups with hidden members

This commit is contained in:
Lonami Exo 2023-02-26 11:17:12 +01:00
parent 07a7a8b404
commit 4de1609d4e

View File

@ -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.