forked from rDrama/rDrama
1
0
Fork 0

simplify comment spam detection

master
Aevann1 2022-08-11 12:28:45 +02:00
parent ce9c4a1a41
commit d07556afc6
1 changed files with 4 additions and 6 deletions

View File

@ -301,14 +301,13 @@ def comment(v):
is_bot = v.id != 12125 and (bool(request.headers.get("Authorization")) or (SITE == 'pcmemes.net' and v.id == SNAPPY_ID)) is_bot = v.id != 12125 and (bool(request.headers.get("Authorization")) or (SITE == 'pcmemes.net' and v.id == SNAPPY_ID))
if '!slots' not in body.lower() and '!blackjack' not in body.lower() and '!wordle' not in body.lower() and parent_post.id not in ADMIGGERS and not is_bot and not v.marseyawarded and AGENDAPOSTER_PHRASE not in body.lower() and len(body) > 10: if len(body) > 50:
now = int(time.time()) now = int(time.time())
cutoff = now - 60 * 60 * 24 cutoff = now - 60 * 60 * 24
similar_comments = g.db.query(Comment).filter( similar_comments = g.db.query(Comment).filter(
Comment.author_id == v.id, Comment.author_id == v.id,
Comment.body.op( Comment.body.op('<->')(body) < COMMENT_SPAM_SIMILAR_THRESHOLD,
'<->')(body) < COMMENT_SPAM_SIMILAR_THRESHOLD,
Comment.created_utc > cutoff Comment.created_utc > cutoff
).all() ).all()
@ -674,15 +673,14 @@ def edit_comment(cid, v):
) )
g.db.add(option) g.db.add(option)
if '!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 len(body) > 50:
now = int(time.time()) now = int(time.time())
cutoff = now - 60 * 60 * 24 cutoff = now - 60 * 60 * 24
similar_comments = g.db.query(Comment similar_comments = g.db.query(Comment
).filter( ).filter(
Comment.author_id == v.id, Comment.author_id == v.id,
Comment.body.op( Comment.body.op('<->')(body) < SPAM_SIMILARITY_THRESHOLD,
'<->')(body) < SPAM_SIMILARITY_THRESHOLD,
Comment.created_utc > cutoff Comment.created_utc > cutoff
).all() ).all()