master
Aevann1 2022-02-26 12:21:25 +02:00
parent 2d33495a2e
commit 0be18d93df
4 changed files with 22 additions and 24 deletions

File diff suppressed because one or more lines are too long

View File

@ -11,10 +11,6 @@ from random import random, choice
import signal
import time
db = db_session()
marseys = [x[0] for x in db.query(Marsey.name).all()] + ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','0','1','2','3','4','5','6','7','8','9','exclamationpoint','period','questionmark']
db.close()
allowed_tags = tags = ['b',
'blockquote',
'br',
@ -222,9 +218,9 @@ def sanitize(sanitized, noimages=False, alert=False, comment=False, edit=False):
classes = 'emoji-md'
remoji = emoji
if not edit and random() < 0.005 and ('marsey' in emoji or emoji in marseys): classes += ' golden'
if not edit and random() < 0.005 and ('marsey' in emoji or emoji in marseys_const): classes += ' golden'
if remoji == 'marseyrandom': remoji = choice(marseys)
if remoji == 'marseyrandom': remoji = choice(marseys_const)
if path.isfile(f'files/assets/images/emojis/{remoji}.webp'):
new = re.sub(f'(?<!"):{emoji}:', f'<img loading="lazy" data-bs-toggle="tooltip" alt=":{emoji}:" title=":{emoji}:" class="{classes}" src="/e/{remoji}.webp" >', new, flags=re.I)
@ -244,10 +240,10 @@ def sanitize(sanitized, noimages=False, alert=False, comment=False, edit=False):
if emoji.startswith("!"):
emoji = emoji[1:]
classes = 'emoji mirrored'
if not edit and random() < 0.005 and ('marsey' in emoji or emoji in marseys): classes += ' golden'
if not edit and random() < 0.005 and ('marsey' in emoji or emoji in marseys_const): classes += ' golden'
old = emoji
if emoji == 'marseyrandom': emoji = choice(marseys)
if emoji == 'marseyrandom': emoji = choice(marseys_const)
else: emoji = old
if path.isfile(f'files/assets/images/emojis/{emoji}.webp'):
@ -255,10 +251,10 @@ def sanitize(sanitized, noimages=False, alert=False, comment=False, edit=False):
if comment: marseys_used.add(emoji)
else:
classes = 'emoji'
if not edit and random() < 0.005 and ('marsey' in emoji or emoji in marseys): classes += ' golden'
if not edit and random() < 0.005 and ('marsey' in emoji or emoji in marseys_const): classes += ' golden'
old = emoji
if emoji == 'marseyrandom': emoji = choice(marseys)
if emoji == 'marseyrandom': emoji = choice(marseys_const)
else: emoji = old
if path.isfile(f'files/assets/images/emojis/{emoji}.webp'):
@ -332,10 +328,10 @@ def filter_emojis_only(title, edit=False, graceful=False):
if emoji.startswith("!"):
emoji = emoji[1:]
classes = 'emoji mirrored'
if not edit and random() < 0.005 and ('marsey' in emoji or emoji in marseys): classes += ' golden'
if not edit and random() < 0.005 and ('marsey' in emoji or emoji in marseys_const): classes += ' golden'
old = emoji
if emoji == 'marseyrandom': emoji = choice(marseys)
if emoji == 'marseyrandom': emoji = choice(marseys_const)
else: emoji = old
if path.isfile(f'files/assets/images/emojis/{emoji}.webp'):
@ -343,10 +339,10 @@ def filter_emojis_only(title, edit=False, graceful=False):
else:
classes = 'emoji'
if not edit and random() < 0.005 and ('marsey' in emoji or emoji in marseys): classes += ' golden'
if not edit and random() < 0.005 and ('marsey' in emoji or emoji in marseys_const): classes += ' golden'
old = emoji
if emoji == 'marseyrandom': emoji = choice(marseys)
if emoji == 'marseyrandom': emoji = choice(marseys_const)
else: emoji = old
if path.isfile(f'files/assets/images/emojis/{emoji}.webp'):

View File

@ -209,7 +209,7 @@ def api_comment(v):
f.write('\n{[para]}\n' + body)
if v.marseyawarded and parent_post.id not in (37696,37697,37749,37833,37838):
marregex = list(re.finditer("^(:[!#]{0,2}m\w+:\s*)+$", body, flags=re.A))
marregex = list(re.finditer("^(:[!#A-Za-z0-9]{1,30}?:\s*)+$", body, flags=re.A))
if len(marregex) == 0: return {"error":"You can only type marseys!"}, 403
if v.longpost and len(body) < 280 or ' [](' in body or body.startswith('[]('): return {"error":"You have to type more than 280 characters!"}, 403
@ -717,7 +717,7 @@ def edit_comment(cid, v):
if body != c.body or request.files.get("file") and request.headers.get("cf-ipcountry") != "T1":
if v.marseyawarded:
marregex = list(re.finditer("^(:[!#]{0,2}m\w+:\s*)+$", body, flags=re.A))
marregex = list(re.finditer("^(:[!#A-Za-z0-9]{1,30}?:\s*)+$", body, flags=re.A))
if len(marregex) == 0: return {"error":"You can only type marseys!"}, 403
if v.longpost and len(body) < 280 or ' [](' in body or body.startswith('[]('): return {"error":"You have to type more than 280 characters!"}, 403

View File

@ -20,9 +20,7 @@ import requests
from shutil import copyfile
from sys import stdout
db = db_session()
marseys = [f':#{x[0]}:' for x in db.query(Marsey.name).all()]
db.close()
marseys = [f':#{x[0]}:' for x in marseys_const]
if path.exists(f'snappy_{SITE_NAME}.txt'):
with open(f'snappy_{SITE_NAME}.txt', "r", encoding="utf-8") as f:
@ -463,10 +461,10 @@ def edit_post(pid, v):
if len(body) > 20000: return {"error":"Character limit is 20000!"}, 403
if v.marseyawarded:
marregex = list(re.finditer("^(:[!#]{0,2}m\w+:\s*)+$", title, flags=re.A))
marregex = list(re.finditer("^(:[!#A-Za-z0-9]{1,30}?:\s*)+$", title, flags=re.A))
if len(marregex) == 0: return {"error":"You can only type marseys!"}, 403
if body:
marregex = list(re.finditer("^(:[!#]{0,2}m\w+:\s*)+$", body, flags=re.A))
marregex = list(re.finditer("^(:[!#A-Za-z0-9]{1,30}?:\s*)+$", body, flags=re.A))
if len(marregex) == 0: return {"error":"You can only type marseys!"}, 403
if v.longpost and len(body) < 280 or ' [](' in body or body.startswith('[]('): return {"error":"You have to type more than 280 characters!"}, 403
@ -972,10 +970,10 @@ def submit_post(v, sub=None):
return error("There's a 500 character limit for titles.")
if v.marseyawarded:
marregex = list(re.finditer("^(:[!#]{0,2}m\w+:\s*)+$", title, flags=re.A))
marregex = list(re.finditer("^(:[!#A-Za-z0-9]{1,30}?:\s*)+$", title, flags=re.A))
if len(marregex) == 0: return error("You can only type marseys!")
if body:
marregex = list(re.finditer("^(:[!#]{0,2}m\w+:\s*)+$", body, flags=re.A))
marregex = list(re.finditer("^(:[!#A-Za-z0-9]{1,30}?:\s*)+$", body, flags=re.A))
if len(marregex) == 0: return error("You can only type marseys!")
if v.longpost and len(body) < 280 or ' [](' in body or body.startswith('[]('): return error("You have to type more than 280 characters!")