mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-22 17:36:34 +03:00
Fix from_id/sender_id value on message updates
This commit is contained in:
parent
572229e536
commit
5c93ea8019
|
@ -107,9 +107,7 @@ class NewMessage(EventBuilder):
|
||||||
media_unread=update.media_unread,
|
media_unread=update.media_unread,
|
||||||
silent=update.silent,
|
silent=update.silent,
|
||||||
id=update.id,
|
id=update.id,
|
||||||
# Note that peer_id/from_id complement each other in private
|
peer_id=types.PeerUser(update.user_id),
|
||||||
# messages, depending on whether the message was outgoing.
|
|
||||||
peer_id=types.PeerUser(update.user_id if update.out else self_id),
|
|
||||||
from_id=types.PeerUser(self_id if update.out else update.user_id),
|
from_id=types.PeerUser(self_id if update.out else update.user_id),
|
||||||
message=update.message,
|
message=update.message,
|
||||||
date=update.date,
|
date=update.date,
|
||||||
|
@ -125,7 +123,7 @@ class NewMessage(EventBuilder):
|
||||||
media_unread=update.media_unread,
|
media_unread=update.media_unread,
|
||||||
silent=update.silent,
|
silent=update.silent,
|
||||||
id=update.id,
|
id=update.id,
|
||||||
from_id=types.PeerUser(update.from_id),
|
from_id=types.PeerUser(self_id if update.out else update.from_id),
|
||||||
peer_id=types.PeerChat(update.chat_id),
|
peer_id=types.PeerChat(update.chat_id),
|
||||||
message=update.message,
|
message=update.message,
|
||||||
date=update.date,
|
date=update.date,
|
||||||
|
|
|
@ -210,20 +210,20 @@ class Message(ChatGetter, SenderGetter, TLObject, abc.ABC):
|
||||||
self._via_input_bot = None
|
self._via_input_bot = None
|
||||||
self._action_entities = None
|
self._action_entities = None
|
||||||
|
|
||||||
if not out and isinstance(peer_id, types.PeerUser):
|
sender_id = None
|
||||||
chat_peer = from_id
|
if from_id is not None:
|
||||||
if from_id == peer_id:
|
sender_id = utils.get_peer_id(from_id)
|
||||||
self.out = not self.fwd_from # Patch out in our chat
|
elif peer_id:
|
||||||
else:
|
# If the message comes from a Channel, let the sender be it
|
||||||
chat_peer = peer_id
|
# ...or...
|
||||||
|
# incoming messages in private conversations no longer have from_id
|
||||||
|
# (layer 119+), but the sender can only be the chat we're in.
|
||||||
|
if post or (not out and isinstance(peer_id, types.PeerUser)):
|
||||||
|
sender_id = utils.get_peer_id(peer_id)
|
||||||
|
|
||||||
# Note that these calls would reset the client
|
# Note that these calls would reset the client
|
||||||
ChatGetter.__init__(self, chat_peer, broadcast=post)
|
ChatGetter.__init__(self, peer_id, broadcast=post)
|
||||||
SenderGetter.__init__(self, utils.get_peer_id(from_id) if from_id else None)
|
SenderGetter.__init__(self, sender_id)
|
||||||
|
|
||||||
if post and not from_id and chat_peer:
|
|
||||||
# If the message comes from a Channel, let the sender be it
|
|
||||||
self._sender_id = utils.get_peer_id(chat_peer)
|
|
||||||
|
|
||||||
self._forward = None
|
self._forward = None
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user