mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-03-03 10:45:52 +03:00
Fix EventCommon/custom.Message conflicting properties
This commit is contained in:
parent
8c8a0153ef
commit
997f2b62ce
|
@ -151,7 +151,6 @@ class EventCommon(abc.ABC):
|
|||
|
||||
Note that this might be ``None`` if the library can't find it.
|
||||
"""
|
||||
|
||||
if self._input_chat is None and self._chat_peer is not None:
|
||||
try:
|
||||
self._input_chat = self._client.get_input_entity(
|
||||
|
|
|
@ -129,8 +129,7 @@ class NewMessage(EventBuilder):
|
|||
available members and methods.
|
||||
"""
|
||||
def __init__(self, message):
|
||||
# Having to override __setattr__ makes things... complicated
|
||||
self.__dict__['_init'] = False
|
||||
self.__dict__ = message.__dict__
|
||||
if not message.out and isinstance(message.to_id, types.PeerUser):
|
||||
# Incoming message (e.g. from a bot) has to_id=us, and
|
||||
# from_id=bot (the actual "chat" from an user's perspective).
|
||||
|
@ -145,15 +144,8 @@ class NewMessage(EventBuilder):
|
|||
|
||||
def _set_client(self, client):
|
||||
super()._set_client(client)
|
||||
# Note that this new message also shares the same __dict__.
|
||||
# By treating everything as the same message it simplifies
|
||||
# the mess that would otherwise be using get/setattr.
|
||||
self.message = custom.Message(
|
||||
client, self.message, self._entities, None)
|
||||
self._init = True
|
||||
|
||||
def __getattr__(self, item):
|
||||
return getattr(self.message, item)
|
||||
|
||||
def __setattr__(self, name, value):
|
||||
if self._init:
|
||||
setattr(self.__dict__['message'], name, value)
|
||||
else:
|
||||
super().__setattr__(name, value)
|
||||
|
|
Loading…
Reference in New Issue
Block a user