forked from MarseyWorld/MarseyWorld
make marsey counter work everywhere (not just comments)
parent
8f72407f84
commit
07f2c0d2ca
|
@ -124,7 +124,7 @@ def handler(signum, frame):
|
||||||
print("Timeout!", flush=True)
|
print("Timeout!", flush=True)
|
||||||
raise Exception("Timeout")
|
raise Exception("Timeout")
|
||||||
|
|
||||||
def render_emoji(html, regexp, edit, marseys_used=set(), b=False):
|
def render_emoji(html, regexp, edit, marseys_used, b=False):
|
||||||
emojis = list(regexp.finditer(html))
|
emojis = list(regexp.finditer(html))
|
||||||
captured = set()
|
captured = set()
|
||||||
|
|
||||||
|
@ -162,7 +162,7 @@ def render_emoji(html, regexp, edit, marseys_used=set(), b=False):
|
||||||
return html
|
return html
|
||||||
|
|
||||||
|
|
||||||
def sanitize(sanitized, alert=False, comment=False, edit=False):
|
def sanitize(sanitized, alert=False, edit=False):
|
||||||
|
|
||||||
signal.signal(signal.SIGALRM, handler)
|
signal.signal(signal.SIGALRM, handler)
|
||||||
signal.alarm(1)
|
signal.alarm(1)
|
||||||
|
@ -269,7 +269,7 @@ def sanitize(sanitized, alert=False, comment=False, edit=False):
|
||||||
sanitized = video_sub_regex.sub(r'\1<video controls preload="none"><source src="\2"></video>', sanitized)
|
sanitized = video_sub_regex.sub(r'\1<video controls preload="none"><source src="\2"></video>', sanitized)
|
||||||
sanitized = audio_sub_regex.sub(r'\1<audio controls preload="none" src="\2"></audio>', sanitized)
|
sanitized = audio_sub_regex.sub(r'\1<audio controls preload="none" src="\2"></audio>', sanitized)
|
||||||
|
|
||||||
if comment:
|
if not edit:
|
||||||
for marsey in g.db.query(Marsey).filter(Marsey.name.in_(marseys_used)).all():
|
for marsey in g.db.query(Marsey).filter(Marsey.name.in_(marseys_used)).all():
|
||||||
marsey.count += 1
|
marsey.count += 1
|
||||||
g.db.add(marsey)
|
g.db.add(marsey)
|
||||||
|
@ -364,7 +364,14 @@ def filter_emojis_only(title, edit=False, graceful=False):
|
||||||
|
|
||||||
title = title.replace('','').replace('','').replace("\ufeff", "").replace("𒐪","").replace("\n", "").replace("\r", "").replace("\t", "").replace("&", "&").replace('<','<').replace('>','>').replace('"', '"').replace("'", "'").strip()
|
title = title.replace('','').replace('','').replace("\ufeff", "").replace("𒐪","").replace("\n", "").replace("\r", "").replace("\t", "").replace("&", "&").replace('<','<').replace('>','>').replace('"', '"').replace("'", "'").strip()
|
||||||
|
|
||||||
title = render_emoji(title, emoji_regex3, edit)
|
marseys_used = set()
|
||||||
|
|
||||||
|
title = render_emoji(title, emoji_regex3, edit, marseys_used)
|
||||||
|
|
||||||
|
if not edit:
|
||||||
|
for marsey in g.db.query(Marsey).filter(Marsey.name.in_(marseys_used)).all():
|
||||||
|
marsey.count += 1
|
||||||
|
g.db.add(marsey)
|
||||||
|
|
||||||
title = strikethrough_regex.sub(r'<del>\1</del>', title)
|
title = strikethrough_regex.sub(r'<del>\1</del>', title)
|
||||||
|
|
||||||
|
|
|
@ -325,7 +325,7 @@ def api_comment(v):
|
||||||
if v.agendaposter and not v.marseyawarded and parent_post.id not in ADMIGGERS:
|
if v.agendaposter and not v.marseyawarded and parent_post.id not in ADMIGGERS:
|
||||||
body = torture_ap(body, v.username)
|
body = torture_ap(body, v.username)
|
||||||
|
|
||||||
body_html = sanitize(body, comment=True)
|
body_html = sanitize(body)
|
||||||
|
|
||||||
|
|
||||||
if parent_post.id not in ADMIGGERS and '!slots' not in body.lower() and '!blackjack' not in body.lower() and '!wordle' not in body.lower() and AGENDAPOSTER_PHRASE not in body.lower():
|
if parent_post.id not in ADMIGGERS and '!slots' not in body.lower() and '!blackjack' not in body.lower() and '!wordle' not in body.lower() and AGENDAPOSTER_PHRASE not in body.lower():
|
||||||
|
|
Loading…
Reference in New Issue