forked from rDrama/rDrama
fix 500 error
parent
b90d698973
commit
0cf1ac4831
|
@ -21,7 +21,6 @@ from files.classes.group import Group
|
||||||
from files.helpers.config.const import *
|
from files.helpers.config.const import *
|
||||||
from files.helpers.const_stateful import *
|
from files.helpers.const_stateful import *
|
||||||
from files.helpers.regex import *
|
from files.helpers.regex import *
|
||||||
from files.helpers.alerts import *
|
|
||||||
from files.helpers.get import *
|
from files.helpers.get import *
|
||||||
|
|
||||||
TLDS = ( # Original gTLDs and ccTLDs
|
TLDS = ( # Original gTLDs and ccTLDs
|
||||||
|
@ -155,6 +154,39 @@ def callback(attrs, new=False):
|
||||||
|
|
||||||
return attrs
|
return attrs
|
||||||
|
|
||||||
|
def create_comment_duplicated(text_html):
|
||||||
|
new_comment = Comment(author_id=AUTOJANNY_ID,
|
||||||
|
parent_submission=None,
|
||||||
|
body_html=text_html,
|
||||||
|
distinguish_level=6,
|
||||||
|
is_bot=True)
|
||||||
|
g.db.add(new_comment)
|
||||||
|
g.db.flush()
|
||||||
|
|
||||||
|
new_comment.top_comment_id = new_comment.id
|
||||||
|
|
||||||
|
return new_comment.id
|
||||||
|
|
||||||
|
def send_repeatable_notification_duplicated(uid, text):
|
||||||
|
|
||||||
|
if uid in bots: return
|
||||||
|
|
||||||
|
text_html = sanitize(text)
|
||||||
|
|
||||||
|
existing_comments = g.db.query(Comment.id).filter_by(author_id=AUTOJANNY_ID, parent_submission=None, body_html=text_html, is_bot=True).order_by(Comment.id).all()
|
||||||
|
|
||||||
|
for c in existing_comments:
|
||||||
|
existing_notif = g.db.query(Notification.user_id).filter_by(user_id=uid, comment_id=c.id).one_or_none()
|
||||||
|
if not existing_notif:
|
||||||
|
notif = Notification(comment_id=c.id, user_id=uid)
|
||||||
|
g.db.add(notif)
|
||||||
|
return
|
||||||
|
|
||||||
|
cid = create_comment_duplicated(text_html)
|
||||||
|
notif = Notification(comment_id=cid, user_id=uid)
|
||||||
|
g.db.add(notif)
|
||||||
|
|
||||||
|
|
||||||
def execute_blackjack(v, target, body, type):
|
def execute_blackjack(v, target, body, type):
|
||||||
if not blackjack or not body: return False
|
if not blackjack or not body: return False
|
||||||
|
|
||||||
|
@ -199,7 +231,7 @@ def execute_blackjack(v, target, body, type):
|
||||||
|
|
||||||
if extra_info:
|
if extra_info:
|
||||||
for id in notified_ids:
|
for id in notified_ids:
|
||||||
send_repeatable_notification(id, f"Blackjack by @{v.username}: {extra_info}")
|
send_repeatable_notification_duplicated(id, f"Blackjack by @{v.username}: {extra_info}")
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def render_emoji(html, regexp, golden, emojis_used, b=False):
|
def render_emoji(html, regexp, golden, emojis_used, b=False):
|
||||||
|
|
Loading…
Reference in New Issue