mirror of
https://github.com/ail-project/ail-framework.git
synced 2024-11-27 00:07:16 +00:00
fix: [telegram] fix regex
This commit is contained in:
parent
1aa63e8a08
commit
8ec4370043
1 changed files with 4 additions and 3 deletions
|
@ -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')
|
||||||
|
|
Loading…
Reference in a new issue