mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-12-01 22:03:46 +03:00
Fix infinite recursion on setattr custom.Message
This commit is contained in:
parent
81c61a0a2e
commit
0a3151175d
|
@ -19,6 +19,7 @@ class Message:
|
||||||
in the original :tl:`Message`.
|
in the original :tl:`Message`.
|
||||||
"""
|
"""
|
||||||
def __init__(self, client, original, entities, input_chat):
|
def __init__(self, client, original, entities, input_chat):
|
||||||
|
self.__dict__['_init'] = False
|
||||||
self.original_message = original
|
self.original_message = original
|
||||||
self.stringify = self.original_message.stringify
|
self.stringify = self.original_message.stringify
|
||||||
self.to_dict = self.original_message.to_dict
|
self.to_dict = self.original_message.to_dict
|
||||||
|
@ -42,6 +43,7 @@ class Message:
|
||||||
elif fwd.channel_id:
|
elif fwd.channel_id:
|
||||||
self._fwd_from_entity = entities.get(get_peer_id(
|
self._fwd_from_entity = entities.get(get_peer_id(
|
||||||
types.PeerChannel(fwd.channel_id)))
|
types.PeerChannel(fwd.channel_id)))
|
||||||
|
self._init = True
|
||||||
|
|
||||||
def __new__(cls, client, original, entities, input_chat):
|
def __new__(cls, client, original, entities, input_chat):
|
||||||
if isinstance(original, types.Message):
|
if isinstance(original, types.Message):
|
||||||
|
@ -55,7 +57,10 @@ class Message:
|
||||||
return getattr(self.original_message, item)
|
return getattr(self.original_message, item)
|
||||||
|
|
||||||
def __setattr__(self, name, value):
|
def __setattr__(self, name, value):
|
||||||
return setattr(self.original_message, name, value)
|
if not self._init or name in self.__dict__:
|
||||||
|
self.__dict__[name] = value
|
||||||
|
else:
|
||||||
|
setattr(self.original_message, name, value)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return str(self.original_message)
|
return str(self.original_message)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user