2
0
mirror of https://github.com/pyrogram/pyrogram synced 2025-08-28 12:57:52 +00:00

Automatically cast message and caption arguments to str

This commit is contained in:
Dan 2019-01-03 20:53:48 +01:00
parent 4f6990d735
commit d69a93d253
2 changed files with 6 additions and 6 deletions

View File

@ -38,12 +38,12 @@ class HTML:
def __init__(self, peers_by_id):
self.peers_by_id = peers_by_id
def parse(self, text):
def parse(self, message: str):
entities = []
text = utils.add_surrogates(text)
message = utils.add_surrogates(str(message))
offset = 0
for match in self.HTML_RE.finditer(text):
for match in self.HTML_RE.finditer(message):
start = match.start() - offset
style, url, body = match.group(1, 3, 4)
@ -73,12 +73,12 @@ class HTML:
continue
entities.append(entity)
text = text.replace(match.group(), body)
message = message.replace(match.group(), body)
offset += len(style) * 2 + 5 + (len(url) + 8 if url else 0)
# TODO: OrderedDict to be removed in Python3.6
return OrderedDict([
("message", utils.remove_surrogates(text)),
("message", utils.remove_surrogates(message)),
("entities", entities)
])

View File

@ -56,7 +56,7 @@ class Markdown:
self.peers_by_id = peers_by_id
def parse(self, message: str):
message = utils.add_surrogates(message).strip()
message = utils.add_surrogates(str(message)).strip()
entities = []
offset = 0