forked from rDrama/rDrama
1
0
Fork 0

stop undelete.pullpush.io triggering for subreddit links

master
Aevann 2023-10-27 00:34:01 +03:00
parent 49a713fdaf
commit db95791ad8
2 changed files with 4 additions and 2 deletions

View File

@ -168,7 +168,7 @@ def execute_snappy(post, v):
body += "\n\n"
if post.url and not post.url.startswith('/') and not post.url.startswith(f'{SITE_FULL}/') and not post.url.startswith(SITE_FULL_IMAGES):
if post.url.startswith('https://old.reddit.com/r/'):
if reddit_post_permalink_regex.fullmatch(post.url):
rev = post.url.replace('https://old.reddit.com/', '')
rev = f"* [undelete.pullpush.io](https://undelete.pullpush.io/{rev})\n\n"
elif post.url.startswith("https://old.reddit.com/user/"):
@ -195,7 +195,7 @@ def execute_snappy(post, v):
if "Snapshots:\n\n" not in body: body += "Snapshots:\n\n"
if f'**[{title}]({href})**:\n\n' not in body:
addition = f'**[{title}]({href})**:\n\n'
if href.startswith('https://old.reddit.com/r/'):
if reddit_post_permalink_regex.fullmatch(href):
rev = href.replace('https://old.reddit.com/', '')
addition += f'* [undelete.pullpush.io](https://undelete.pullpush.io/{rev})\n\n'
elif href.startswith('https://old.reddit.com/user/'):

View File

@ -248,6 +248,8 @@ reddit_to_vreddit_regex = re.compile('(^|>|")https:\/\/old.reddit.com\/([ru])\/'
#post search
subreddit_name_regex = re.compile('\w{2,25}', flags=re.A)
#undelete.pullpush.io
reddit_post_permalink_regex = re.compile('https:\/\/old.reddit.com\/r\/\w{2,25}\/comments\/.*', flags=re.A)
###YOUTUBE