fix: [telegram] fix regex

pull/594/head
Terrtia 2023-05-15 10:12:58 +02:00
parent 1aa63e8a08
commit 8ec4370043
No known key found for this signature in database
GPG Key ID: 1E1B1F50D84613D0
1 changed files with 4 additions and 3 deletions

View File

@ -28,7 +28,7 @@ class Telegram(AbstractModule):
super(Telegram, self).__init__() super(Telegram, self).__init__()
# https://github.com/LonamiWebs/Telethon/wiki/Special-links # https://github.com/LonamiWebs/Telethon/wiki/Special-links
self.re_telegram_link = r'(telegram\.me|t\.me|telegram\.dog|telesco\.pe)/([^\.\",\s]+)' self.re_telegram_link = r'(telegram\.me|t\.me|telegram\.dog|telesco\.pe)/(\w+)'
self.re_tg_link = r'tg://.+' self.re_tg_link = r'tg://.+'
re.compile(self.re_telegram_link) re.compile(self.re_telegram_link)
@ -49,9 +49,10 @@ class Telegram(AbstractModule):
# extract telegram links # extract telegram links
telegram_links = self.regex_findall(self.re_telegram_link, item.get_id(), item_content) telegram_links = self.regex_findall(self.re_telegram_link, item.get_id(), item_content)
telegram_links = set(telegram_links)
for telegram_link_tuple in telegram_links: for telegram_link_tuple in telegram_links:
print(telegram_link_tuple) # print(telegram_link_tuple)
print(telegram_link_tuple[2:-2].split("', '", 1)) # print(telegram_link_tuple[2:-2].split("', '", 1))
base_url, url_path = telegram_link_tuple[2:-2].split("', '", 1) base_url, url_path = telegram_link_tuple[2:-2].split("', '", 1)
dict_url = telegram.get_data_from_telegram_url(base_url, url_path) dict_url = telegram.get_data_from_telegram_url(base_url, url_path)
user_id = dict_url.get('username') user_id = dict_url.get('username')