Skip to content
Permalink
Browse files

Fix ChatAction.user_left was considered as user_kicked

Closes #1660.
  • Loading branch information
Lonami committed Jan 2, 2021
1 parent d0ee3c3 commit 3df4807fb942519f8a228a111e429df6601b8584
Showing with 4 additions and 15 deletions.
  1. +4 −15 telethon/events/chataction.py
@@ -54,20 +54,9 @@ def build(cls, update, others=None, self_id=None):
kicked_by=True,
users=update.user_id)

elif isinstance(update, types.UpdateChannel):
# We rely on the fact that update._entities is set by _process_update
# This update only has the channel ID, and Telegram *should* have sent
# the entity in the Updates.chats list. If it did, check Channel.left
# to determine what happened.
peer = types.PeerChannel(update.channel_id)
channel = update._entities.get(utils.get_peer_id(peer))
if channel is not None:
if isinstance(channel, types.ChannelForbidden) or channel.left:
return cls.Event(peer,
kicked_by=True)
else:
return cls.Event(peer,
added_by=True)
# UpdateChannel is sent if we leave a channel, and the update._entities
# set by _process_update would let us make some guesses. However it's
# better not to rely on this. Rely only in MessageActionChatDeleteUser.

elif (isinstance(update, (
types.UpdateNewMessage, types.UpdateNewChannelMessage))
@@ -86,7 +75,7 @@ def build(cls, update, others=None, self_id=None):
users=action.users)
elif isinstance(action, types.MessageActionChatDeleteUser):
return cls.Event(msg,
kicked_by=msg.from_id or True,
kicked_by=utils.get_peer_id(msg.from_id) if msg.from_id else True,
users=action.user_id)
elif isinstance(action, types.MessageActionChatCreate):
return cls.Event(msg,

0 comments on commit 3df4807

Please sign in to comment.