mirror of
https://github.com/pyrogram/pyrogram
synced 2025-08-29 13:27:47 +00:00
Automatically cast message and caption arguments to str
This commit is contained in:
parent
4f6990d735
commit
d69a93d253
@ -38,12 +38,12 @@ class HTML:
|
|||||||
def __init__(self, peers_by_id):
|
def __init__(self, peers_by_id):
|
||||||
self.peers_by_id = peers_by_id
|
self.peers_by_id = peers_by_id
|
||||||
|
|
||||||
def parse(self, text):
|
def parse(self, message: str):
|
||||||
entities = []
|
entities = []
|
||||||
text = utils.add_surrogates(text)
|
message = utils.add_surrogates(str(message))
|
||||||
offset = 0
|
offset = 0
|
||||||
|
|
||||||
for match in self.HTML_RE.finditer(text):
|
for match in self.HTML_RE.finditer(message):
|
||||||
start = match.start() - offset
|
start = match.start() - offset
|
||||||
style, url, body = match.group(1, 3, 4)
|
style, url, body = match.group(1, 3, 4)
|
||||||
|
|
||||||
@ -73,12 +73,12 @@ class HTML:
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
entities.append(entity)
|
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)
|
offset += len(style) * 2 + 5 + (len(url) + 8 if url else 0)
|
||||||
|
|
||||||
# TODO: OrderedDict to be removed in Python3.6
|
# TODO: OrderedDict to be removed in Python3.6
|
||||||
return OrderedDict([
|
return OrderedDict([
|
||||||
("message", utils.remove_surrogates(text)),
|
("message", utils.remove_surrogates(message)),
|
||||||
("entities", entities)
|
("entities", entities)
|
||||||
])
|
])
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ class Markdown:
|
|||||||
self.peers_by_id = peers_by_id
|
self.peers_by_id = peers_by_id
|
||||||
|
|
||||||
def parse(self, message: str):
|
def parse(self, message: str):
|
||||||
message = utils.add_surrogates(message).strip()
|
message = utils.add_surrogates(str(message)).strip()
|
||||||
entities = []
|
entities = []
|
||||||
offset = 0
|
offset = 0
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user