From 14ac3b1c15742a1d4c6624399be0d76dd034a2d8 Mon Sep 17 00:00:00 2001 From: Aevann Date: Fri, 6 Oct 2023 20:09:40 +0300 Subject: [PATCH] fix 500 error --- files/helpers/actions.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/files/helpers/actions.py b/files/helpers/actions.py index 7700afe33..b199a4995 100644 --- a/files/helpers/actions.py +++ b/files/helpers/actions.py @@ -267,11 +267,13 @@ def execute_snappy(post, v): def execute_zozbot(c, level, post, v): if SITE_NAME != 'rDrama': return - if post.sub and g.db.query(Exile.user_id).filter_by(user_id=ZOZBOT_ID, sub=post.sub).one_or_none(): - return + if random.random() >= 0.001: return posting_to_post = isinstance(post, Post) - if random.random() >= 0.001: return + + if posting_to_post and post.sub and g.db.query(Exile.user_id).filter_by(user_id=ZOZBOT_ID, sub=post.sub).one_or_none(): + return + c2 = Comment(author_id=ZOZBOT_ID, parent_post=post.id if posting_to_post else None, wall_user_id=post.id if not posting_to_post else None, @@ -336,12 +338,15 @@ def execute_zozbot(c, level, post, v): def execute_longpostbot(c, level, body, body_html, post, v): if SITE_NAME != 'rDrama': return - if post.sub and g.db.query(Exile.user_id).filter_by(user_id=LONGPOSTBOT_ID, sub=post.sub).one_or_none(): - return + if not len(c.body.split()) >= 200: return + + if "" in body_html: return posting_to_post = isinstance(post, Post) - if not len(c.body.split()) >= 200: return - if "" in body_html: return + + if posting_to_post and post.sub and g.db.query(Exile.user_id).filter_by(user_id=LONGPOSTBOT_ID, sub=post.sub).one_or_none(): + return + body = random.choice(LONGPOSTBOT_REPLIES) if body.startswith('▼'): body = body[1:]