understanding commited on
Commit
33b99cd
·
verified ·
1 Parent(s): 01792e5

Create link_parser.py

Browse files
Files changed (1) hide show
  1. bot/youtube/link_parser.py +18 -0
bot/youtube/link_parser.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # PATH: bot/youtube/link_parser.py
2
+ from __future__ import annotations
3
+
4
+ from typing import Tuple, Union
5
+
6
+ from bot.core.link_parser import ChatRef, parse_link
7
+
8
+
9
+ def parse_telegram_link(link: str) -> Tuple[ChatRef, int]:
10
+ """
11
+ handlers.py expects this to raise on bad links.
12
+ Returns: (chat_ref, msg_id)
13
+ chat_ref: int (-100... for private channels) or username str
14
+ """
15
+ out = parse_link(link)
16
+ if not out:
17
+ raise ValueError("invalid_telegram_link")
18
+ return out