mirror of
https://github.com/paul-nameless/tg
synced 2024-11-22 03:43:19 +00:00
handle urls in textEntityTypeTextUrl
This commit is contained in:
parent
30fe11bd68
commit
abb7258fe3
1 changed files with 8 additions and 7 deletions
|
@ -122,15 +122,16 @@ class Controller:
|
|||
text = msg["content"]["text"]["text"]
|
||||
urls = []
|
||||
for entity in msg["content"]["text"]["entities"]:
|
||||
if entity["type"]["@type"] != "textEntityTypeUrl":
|
||||
_type = entity["type"]["@type"]
|
||||
if _type == "textEntityTypeUrl":
|
||||
offset = entity["offset"]
|
||||
length = entity["length"]
|
||||
url = text[offset : offset + length]
|
||||
elif _type == "textEntityTypeTextUrl":
|
||||
url = entity["type"]["url"]
|
||||
else:
|
||||
continue
|
||||
offset = entity["offset"]
|
||||
length = entity["length"]
|
||||
url = text[offset : offset + length]
|
||||
urls.append(url)
|
||||
if web_url := msg["content"].get("web_page", {}).get("url"):
|
||||
urls.append(web_url)
|
||||
|
||||
if not urls:
|
||||
return self.present_error("No url to open")
|
||||
if len(urls) == 1:
|
||||
|
|
Loading…
Reference in a new issue