mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-02-27 00:40:41 +03:00
Replace custom.Message's class on creation
This commit is contained in:
parent
9db9d1ed5c
commit
e2ce55871e
|
@ -41,6 +41,14 @@ class Message:
|
||||||
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)))
|
||||||
|
|
||||||
|
def __new__(cls, client, original, entities, input_chat):
|
||||||
|
if isinstance(original, types.Message):
|
||||||
|
return super().__new__(_CustomMessage)
|
||||||
|
elif isinstance(original, types.MessageService):
|
||||||
|
return super().__new__(_CustomMessageService)
|
||||||
|
else:
|
||||||
|
return cls
|
||||||
|
|
||||||
def __getattr__(self, item):
|
def __getattr__(self, item):
|
||||||
return getattr(self.original_message, item)
|
return getattr(self.original_message, item)
|
||||||
|
|
||||||
|
@ -328,3 +336,11 @@ class Message:
|
||||||
return self._buttons_flat[i].click()
|
return self._buttons_flat[i].click()
|
||||||
else:
|
else:
|
||||||
return self._buttons[i][j].click()
|
return self._buttons[i][j].click()
|
||||||
|
|
||||||
|
|
||||||
|
class _CustomMessage(Message, types.Message):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class _CustomMessageService(Message, types.MessageService):
|
||||||
|
pass
|
||||||
|
|
Loading…
Reference in New Issue
Block a user