master
Aevann1 2021-10-01 02:13:20 +02:00
parent be47614c8f
commit 80b68ae91d
1 changed files with 12 additions and 15 deletions

View File

@ -214,29 +214,26 @@ def sanitize(sanitized, noimages=False):
if start in sanitized and end in sanitized and start in sanitized.split(end)[0] and end in sanitized.split(start)[1]: sanitized = sanitized.replace(start, '<span class="spoiler">').replace(end, '</span>')
for i in re.finditer("<p>\s*((:\w+:)\s*)+<\/p>", sanitized):
print(i.group(0))
emojis = i.group(0).lower().replace("<p>", "").replace("</p>", "")
for i in re.finditer('\w*(?<!"):([^ ]{1,30}?):', emojis):
emoji = i.group(1).lower()
if path.isfile(f'./files/assets/images/emojis/{emoji}.webp'):
emojis = re.sub(f'\w*(?<!"):{emoji}:', f'<img loading="lazy" data-bs-toggle="tooltip" alt=":{emoji}:" title=":{emoji}:" delay="0" height=60 src="https://{site}/assets/images/emojis/{emoji}.webp">', emojis)
# if emoji in session["favorite_emojis"]: session["favorite_emojis"][emoji] += 1
# else: session["favorite_emojis"][emoji] = 1
print(sanitized)
print(emojis)
sanitized = sanitized.replace(i.group(1), emojis)
if emoji in session["favorite_emojis"]: session["favorite_emojis"][emoji] += 1
else: session["favorite_emojis"][emoji] = 1
sanitized = sanitized.replace(i.group(0), emojis)
# for i in re.finditer('\w*(?<!"):([^ ]{1,30}?):', sanitized):
# emoji = i.group(1).lower()
# if path.isfile(f'./files/assets/images/emojis/{emoji}.webp'):
# sanitized = re.sub(f'\w*(?<!"):{emoji}:', f'<img loading="lazy" data-bs-toggle="tooltip" alt=":{emoji}:" title=":{emoji}:" delay="0" height=30 src="https://{site}/assets/images/emojis/{emoji}.webp">', sanitized)
for i in re.finditer('\w*(?<!"):([^ ]{1,30}?):', sanitized):
emoji = i.group(1).lower()
if path.isfile(f'./files/assets/images/emojis/{emoji}.webp'):
sanitized = re.sub(f'\w*(?<!"):{emoji}:', f'<img loading="lazy" data-bs-toggle="tooltip" alt=":{emoji}:" title=":{emoji}:" delay="0" height=30 src="https://{site}/assets/images/emojis/{emoji}.webp">', sanitized)
# try:
# if emoji in session["favorite_emojis"]: session["favorite_emojis"][emoji] += 1
# else: session["favorite_emojis"][emoji] = 1
# except:
# pass
try:
if emoji in session["favorite_emojis"]: session["favorite_emojis"][emoji] += 1
else: session["favorite_emojis"][emoji] = 1
except:
pass
sanitized = sanitized.replace("https://www.", "https://").replace("https://youtu.be/", "https://youtube.com/watch?v=").replace("https://music.youtube.com/watch?v=", "https://youtube.com/watch?v=").replace("https://open.spotify.com/", "https://open.spotify.com/embed/").replace("https://streamable.com/", "https://streamable.com/e/").replace("https://youtube.com/shorts/", "https://youtube.com/watch?v=").replace("https://mobile.twitter", "https://twitter").replace("https://m.facebook", "https://facebook").replace("https://m.wikipedia", "https://wikipedia").replace("https://m.youtube", "https://youtube")