mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-22 09:26:37 +03:00
parent
7cac3668d6
commit
363c2604df
|
@ -87,10 +87,15 @@ class MessageParseMethods:
|
||||||
message, msg_entities = parse_mode.parse(message)
|
message, msg_entities = parse_mode.parse(message)
|
||||||
if original_message and not message and not msg_entities:
|
if original_message and not message and not msg_entities:
|
||||||
raise ValueError("Failed to parse message")
|
raise ValueError("Failed to parse message")
|
||||||
|
|
||||||
for i in reversed(range(len(msg_entities))):
|
for i in reversed(range(len(msg_entities))):
|
||||||
e = msg_entities[i]
|
e = msg_entities[i]
|
||||||
if isinstance(e, types.MessageEntityTextUrl):
|
if not e.length:
|
||||||
|
# 0-length MessageEntity is no longer valid #3884.
|
||||||
|
# Because the user can provide their own parser (with reasonable 0-length
|
||||||
|
# entities), strip them here rather than fixing the built-in parsers.
|
||||||
|
del msg_entities[i]
|
||||||
|
elif isinstance(e, types.MessageEntityTextUrl):
|
||||||
m = re.match(r'^@|\+|tg://user\?id=(\d+)', e.url)
|
m = re.match(r'^@|\+|tg://user\?id=(\d+)', e.url)
|
||||||
if m:
|
if m:
|
||||||
user = int(m.group(1)) if m.group(1) else e.url
|
user = int(m.group(1)) if m.group(1) else e.url
|
||||||
|
|
Loading…
Reference in New Issue
Block a user