Update message.py
This commit is contained in:
parent
168fce09da
commit
32ca805f6b
@ -31,33 +31,27 @@ from ..object import Object
|
|||||||
from ..update import Update
|
from ..update import Update
|
||||||
from ..user_and_chats.chat import Chat
|
from ..user_and_chats.chat import Chat
|
||||||
from ..user_and_chats.user import User
|
from ..user_and_chats.user import User
|
||||||
from ...style import utils
|
from ...style import utils, Markdown, HTML
|
||||||
|
|
||||||
|
|
||||||
class Str(str):
|
class Str(str):
|
||||||
def __init__(self, *args):
|
def __init__(self, *args):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
self._client = None
|
self.entities = None
|
||||||
self._entities = None
|
|
||||||
|
|
||||||
def init(self, client, entities):
|
def init(self, entities):
|
||||||
self._client = client
|
self.entities = entities
|
||||||
self._entities = entities
|
|
||||||
|
|
||||||
return self
|
return self
|
||||||
|
|
||||||
@property
|
|
||||||
def text(self):
|
|
||||||
return self
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def markdown(self):
|
def markdown(self):
|
||||||
return self._client.markdown.unparse(self, self._entities)
|
return Markdown.unparse(self, self.entities)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def html(self):
|
def html(self):
|
||||||
return self._client.html.unparse(self, self._entities)
|
return HTML.unparse(self, self.entities)
|
||||||
|
|
||||||
def __getitem__(self, item):
|
def __getitem__(self, item):
|
||||||
return utils.remove_surrogates(utils.add_surrogates(self)[item])
|
return utils.remove_surrogates(utils.add_surrogates(self)[item])
|
||||||
@ -490,7 +484,7 @@ class Message(Object, Update):
|
|||||||
|
|
||||||
if isinstance(message, types.Message):
|
if isinstance(message, types.Message):
|
||||||
entities = [MessageEntity._parse(client, entity, users) for entity in message.entities]
|
entities = [MessageEntity._parse(client, entity, users) for entity in message.entities]
|
||||||
entities = list(filter(lambda x: x is not None, entities))
|
entities = pyrogram.List(filter(lambda x: x is not None, entities))
|
||||||
|
|
||||||
forward_from = None
|
forward_from = None
|
||||||
forward_sender_name = None
|
forward_sender_name = None
|
||||||
@ -607,8 +601,8 @@ class Message(Object, Update):
|
|||||||
date=message.date,
|
date=message.date,
|
||||||
chat=Chat._parse(client, message, users, chats),
|
chat=Chat._parse(client, message, users, chats),
|
||||||
from_user=User._parse(client, users.get(message.from_id, None)),
|
from_user=User._parse(client, users.get(message.from_id, None)),
|
||||||
text=Str(message.message).init(client, entities) or None if media is None else None,
|
text=Str(message.message).init(entities) or None if media is None else None,
|
||||||
caption=Str(message.message).init(client, entities) or None if media is not None else None,
|
caption=Str(message.message).init(entities) or None if media is not None else None,
|
||||||
entities=entities or None if media is None else None,
|
entities=entities or None if media is None else None,
|
||||||
caption_entities=entities or None if media is not None else None,
|
caption_entities=entities or None if media is not None else None,
|
||||||
author_signature=message.post_author,
|
author_signature=message.post_author,
|
||||||
|
Loading…
Reference in New Issue
Block a user