forked from rDrama/rDrama
antispam: under siege mode
parent
b59e4cadaa
commit
0106a4e340
|
@ -12,8 +12,10 @@ from files.classes.notifications import Notification
|
||||||
from files.helpers.alerts import send_repeatable_notification
|
from files.helpers.alerts import send_repeatable_notification
|
||||||
from files.helpers.const import *
|
from files.helpers.const import *
|
||||||
from files.helpers.const_stateful import *
|
from files.helpers.const_stateful import *
|
||||||
|
from files.helpers.discord import discord_message_send
|
||||||
from files.helpers.get import *
|
from files.helpers.get import *
|
||||||
from files.helpers.sanitize import *
|
from files.helpers.sanitize import *
|
||||||
|
from files.helpers.settings import get_setting
|
||||||
from files.helpers.slots import check_slots_command
|
from files.helpers.slots import check_slots_command
|
||||||
|
|
||||||
|
|
||||||
|
@ -38,7 +40,6 @@ def archive_url(url):
|
||||||
url = url.replace('https://instagram.com/', 'https://imginn.com/')
|
url = url.replace('https://instagram.com/', 'https://imginn.com/')
|
||||||
gevent.spawn(_archiveorg, url)
|
gevent.spawn(_archiveorg, url)
|
||||||
|
|
||||||
|
|
||||||
def execute_snappy(post, v):
|
def execute_snappy(post, v):
|
||||||
snappy = get_account(SNAPPY_ID)
|
snappy = get_account(SNAPPY_ID)
|
||||||
|
|
||||||
|
@ -360,18 +361,6 @@ def execute_antispam_submission_check(title, v, url):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def execute_blackjack_custom(v, target, body, type):
|
def execute_blackjack_custom(v, target, body, type):
|
||||||
if v.age < (10 * 60):
|
|
||||||
v.shadowbanned = 'AutoJanny'
|
|
||||||
if not v.is_banned: v.ban_reason = f"Under Siege"
|
|
||||||
v.is_muted = True
|
|
||||||
g.db.add(v)
|
|
||||||
with open(f"/under_siege.log", "a", encoding="utf-8") as f:
|
|
||||||
t = time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime(time.time()))
|
|
||||||
f.write(f"[{t}] {v.id} @{v.username} {type} {v.age}s\n")
|
|
||||||
from files.helpers.discord import discord_message_send
|
|
||||||
discord_message_send("1041917843094110239",
|
|
||||||
f"<{SITE_FULL}/id/{v.id}> `@{v.username} {type} {v.age}s`")
|
|
||||||
return False
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def execute_blackjack(v, target, body, type):
|
def execute_blackjack(v, target, body, type):
|
||||||
|
@ -458,6 +447,21 @@ def execute_antispam_comment_check(body:str, v:User):
|
||||||
g.db.commit()
|
g.db.commit()
|
||||||
abort(403, "Too much spam!")
|
abort(403, "Too much spam!")
|
||||||
|
|
||||||
|
def execute_under_siege(v:User, target:Optional[Union[Submission, Comment]], body, type:str):
|
||||||
|
if not get_setting("under_siege"): return True
|
||||||
|
if v.age < UNDER_SIEGE_AGE_THRESHOLD and not v.admin_level >= PERMS['SITE_BYPASS_UNDER_SIEGE_MODE']:
|
||||||
|
v.shadowbanned = 'AutoJanny'
|
||||||
|
if not v.is_banned: v.ban_reason = f"Under Siege"
|
||||||
|
v.is_muted = True
|
||||||
|
g.db.add(v)
|
||||||
|
with open(f"/under_siege.log", "a", encoding="utf-8") as f:
|
||||||
|
t = time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime(time.time()))
|
||||||
|
f.write(f"[{t}] {v.id} @{v.username} {type} {v.age}s\n")
|
||||||
|
discord_message_send(UNDER_SIEGE_CHANNEL_ID,
|
||||||
|
f"<{SITE_FULL}/id/{v.id}> `@{v.username} {type} {v.age}s`")
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
def execute_lawlz_actions(v:User, p:Submission):
|
def execute_lawlz_actions(v:User, p:Submission):
|
||||||
if v.id != LAWLZ_ID: return
|
if v.id != LAWLZ_ID: return
|
||||||
if SITE_NAME != 'rDrama': return
|
if SITE_NAME != 'rDrama': return
|
||||||
|
|
|
@ -199,6 +199,7 @@ AGENDAPOSTER_MSG_HTML = """<p>Hi <a href="/id/{id}"><img loading="lazy" src="/pp
|
||||||
|
|
||||||
DISCORD_CHANGELOG_CHANNEL_ID = 1034632681788538980
|
DISCORD_CHANGELOG_CHANNEL_ID = 1034632681788538980
|
||||||
WPD_CHANNEL_ID = 1013990963846332456
|
WPD_CHANNEL_ID = 1013990963846332456
|
||||||
|
UNDER_SIEGE_CHANNEL_ID = 1041917843094110239
|
||||||
PIN_AWARD_TEXT = " (pin award)"
|
PIN_AWARD_TEXT = " (pin award)"
|
||||||
|
|
||||||
THEMES = ["4chan","classic","classic_dark","coffee","dark","dramblr","light","midnight","transparent","tron","win98"]
|
THEMES = ["4chan","classic","classic_dark","coffee","dark","dramblr","light","midnight","transparent","tron","win98"]
|
||||||
|
@ -271,6 +272,7 @@ PERMS = { # Minimum admin_level to perform action.
|
||||||
'VIEW_VOTE_BUTTONS_ON_USER_PAGE': 2,
|
'VIEW_VOTE_BUTTONS_ON_USER_PAGE': 2,
|
||||||
'PRINT_MARSEYBUX_FOR_KIPPY_ON_PCMEMES': 3, # note: explicitly disabled on rDrama
|
'PRINT_MARSEYBUX_FOR_KIPPY_ON_PCMEMES': 3, # note: explicitly disabled on rDrama
|
||||||
'SITE_BYPASS_READ_ONLY_MODE': 1,
|
'SITE_BYPASS_READ_ONLY_MODE': 1,
|
||||||
|
'SITE_BYPASS_UNDER_SIEGE_MODE': 1,
|
||||||
'SITE_SETTINGS': 3,
|
'SITE_SETTINGS': 3,
|
||||||
'SITE_SETTINGS_SIDEBARS_BANNERS_BADGES': 3,
|
'SITE_SETTINGS_SIDEBARS_BANNERS_BADGES': 3,
|
||||||
'SITE_SETTINGS_SNAPPY_QUOTES': 3,
|
'SITE_SETTINGS_SNAPPY_QUOTES': 3,
|
||||||
|
@ -407,6 +409,7 @@ PFP_DEFAULT_MARSEY = True
|
||||||
NEW_USER_HAT_AGE = 0 # seconds of age to show new-user forced hat
|
NEW_USER_HAT_AGE = 0 # seconds of age to show new-user forced hat
|
||||||
NOTIFICATION_SPAM_AGE_THRESHOLD = 0.5 * 86400
|
NOTIFICATION_SPAM_AGE_THRESHOLD = 0.5 * 86400
|
||||||
COMMENT_SPAM_LENGTH_THRESHOLD = 50
|
COMMENT_SPAM_LENGTH_THRESHOLD = 50
|
||||||
|
UNDER_SIEGE_AGE_THRESHOLD = 10
|
||||||
|
|
||||||
HOLE_NAME = 'hole'
|
HOLE_NAME = 'hole'
|
||||||
HOLE_STYLE_FLAIR = False
|
HOLE_STYLE_FLAIR = False
|
||||||
|
|
|
@ -12,6 +12,7 @@ _SETTINGS = {
|
||||||
"Read-only mode": False,
|
"Read-only mode": False,
|
||||||
"Signups": True,
|
"Signups": True,
|
||||||
"login_required": False,
|
"login_required": False,
|
||||||
|
"under_siege": False,
|
||||||
}
|
}
|
||||||
|
|
||||||
def get_setting(setting:str):
|
def get_setting(setting:str):
|
||||||
|
|
|
@ -11,7 +11,7 @@ from files.helpers.get import *
|
||||||
from files.helpers.media import *
|
from files.helpers.media import *
|
||||||
from files.helpers.sanitize import *
|
from files.helpers.sanitize import *
|
||||||
from files.helpers.security import *
|
from files.helpers.security import *
|
||||||
from files.helpers.settings import toggle_setting
|
from files.helpers.settings import get_settings, toggle_setting
|
||||||
from files.helpers.useractions import *
|
from files.helpers.useractions import *
|
||||||
from files.routes.routehelpers import check_for_alts
|
from files.routes.routehelpers import check_for_alts
|
||||||
from files.routes.wrappers import *
|
from files.routes.wrappers import *
|
||||||
|
@ -455,6 +455,8 @@ def admin_git_head():
|
||||||
@app.post("/admin/site_settings/<setting>")
|
@app.post("/admin/site_settings/<setting>")
|
||||||
@admin_level_required(PERMS['SITE_SETTINGS'])
|
@admin_level_required(PERMS['SITE_SETTINGS'])
|
||||||
def change_settings(v, setting):
|
def change_settings(v, setting):
|
||||||
|
if setting not in get_settings().keys():
|
||||||
|
abort(404, f"Setting '{setting}' not found")
|
||||||
val = toggle_setting(setting)
|
val = toggle_setting(setting)
|
||||||
if val: word = 'enable'
|
if val: word = 'enable'
|
||||||
else: word = 'disable'
|
else: word = 'disable'
|
||||||
|
@ -463,7 +465,7 @@ def change_settings(v, setting):
|
||||||
user_id=v.id,
|
user_id=v.id,
|
||||||
)
|
)
|
||||||
g.db.add(ma)
|
g.db.add(ma)
|
||||||
return {'message': f"{setting} {word}d successfully!"}
|
return {'message': f"{setting.replace('_', ' ').title()} {word}d successfully!"}
|
||||||
|
|
||||||
@app.post("/admin/clear_cloudflare_cache")
|
@app.post("/admin/clear_cloudflare_cache")
|
||||||
@admin_level_required(PERMS['SITE_CACHE_PURGE_CDN'])
|
@admin_level_required(PERMS['SITE_CACHE_PURGE_CDN'])
|
||||||
|
|
|
@ -239,6 +239,7 @@ def comment(v):
|
||||||
g.db.flush()
|
g.db.flush()
|
||||||
|
|
||||||
execute_blackjack(v, c, c.body, "comment")
|
execute_blackjack(v, c, c.body, "comment")
|
||||||
|
execute_under_siege(v, c, c.body, "comment")
|
||||||
|
|
||||||
if c.level == 1: c.top_comment_id = c.id
|
if c.level == 1: c.top_comment_id = c.id
|
||||||
else: c.top_comment_id = parent.top_comment_id
|
else: c.top_comment_id = parent.top_comment_id
|
||||||
|
@ -444,6 +445,7 @@ def edit_comment(cid, v):
|
||||||
c.body_html = body_html
|
c.body_html = body_html
|
||||||
|
|
||||||
execute_blackjack(v, c, c.body, "comment")
|
execute_blackjack(v, c, c.body, "comment")
|
||||||
|
execute_under_siege(v, c, c.body, "comment")
|
||||||
|
|
||||||
if c.post.id not in ADMIGGER_THREADS and v.agendaposter and not v.marseyawarded and AGENDAPOSTER_PHRASE not in c.body.lower() and c.post.sub != 'chudrama':
|
if c.post.id not in ADMIGGER_THREADS and v.agendaposter and not v.marseyawarded and AGENDAPOSTER_PHRASE not in c.body.lower() and c.post.sub != 'chudrama':
|
||||||
abort(403, f'You have to include "{AGENDAPOSTER_PHRASE}" in your comment!')
|
abort(403, f'You have to include "{AGENDAPOSTER_PHRASE}" in your comment!')
|
||||||
|
|
|
@ -392,7 +392,9 @@ def edit_post(pid, v):
|
||||||
|
|
||||||
p.body = body
|
p.body = body
|
||||||
|
|
||||||
for text in {p.body, p.title, p.url}:
|
execute_under_siege(v, p, p.body, 'submission')
|
||||||
|
|
||||||
|
for text in [p.body, p.title, p.url]:
|
||||||
if not execute_blackjack(v, p, text, 'submission'): break
|
if not execute_blackjack(v, p, text, 'submission'): break
|
||||||
|
|
||||||
if len(body_html) > POST_BODY_HTML_LENGTH_LIMIT:
|
if len(body_html) > POST_BODY_HTML_LENGTH_LIMIT:
|
||||||
|
|
|
@ -18,6 +18,7 @@ from files.__main__ import app, limiter, cache
|
||||||
def flag_post(pid, v):
|
def flag_post(pid, v):
|
||||||
post = get_post(pid)
|
post = get_post(pid)
|
||||||
reason = request.values.get("reason", "").strip()
|
reason = request.values.get("reason", "").strip()
|
||||||
|
execute_under_siege(v, post, reason, 'flag')
|
||||||
execute_blackjack(v, post, reason, 'flag')
|
execute_blackjack(v, post, reason, 'flag')
|
||||||
if v.is_muted: abort(403, "You are forbidden from making reports.")
|
if v.is_muted: abort(403, "You are forbidden from making reports.")
|
||||||
reason = reason[:100]
|
reason = reason[:100]
|
||||||
|
@ -76,6 +77,7 @@ def flag_comment(cid, v):
|
||||||
if existing: abort(409, "You already reported this comment!")
|
if existing: abort(409, "You already reported this comment!")
|
||||||
|
|
||||||
reason = request.values.get("reason", "").strip()
|
reason = request.values.get("reason", "").strip()
|
||||||
|
execute_under_siege(v, comment, reason, 'flag')
|
||||||
execute_blackjack(v, comment, reason, 'flag')
|
execute_blackjack(v, comment, reason, 'flag')
|
||||||
reason = reason[:100]
|
reason = reason[:100]
|
||||||
reason = filter_emojis_only(reason)
|
reason = filter_emojis_only(reason)
|
||||||
|
|
|
@ -231,6 +231,7 @@ def submit_contact(v):
|
||||||
g.db.add(new_comment)
|
g.db.add(new_comment)
|
||||||
g.db.flush()
|
g.db.flush()
|
||||||
execute_blackjack(v, new_comment, new_comment.body_html, 'modmail')
|
execute_blackjack(v, new_comment, new_comment.body_html, 'modmail')
|
||||||
|
execute_under_siege(v, new_comment, new_comment.body_html, 'modmail')
|
||||||
new_comment.top_comment_id = new_comment.id
|
new_comment.top_comment_id = new_comment.id
|
||||||
|
|
||||||
admins = g.db.query(User).filter(User.admin_level >= PERMS['NOTIFICATIONS_MODMAIL'], User.id != AEVANN_ID)
|
admins = g.db.query(User).filter(User.admin_level >= PERMS['NOTIFICATIONS_MODMAIL'], User.id != AEVANN_ID)
|
||||||
|
|
|
@ -13,7 +13,7 @@ from files.classes import *
|
||||||
from files.classes.leaderboard import Leaderboard
|
from files.classes.leaderboard import Leaderboard
|
||||||
from files.classes.transactions import *
|
from files.classes.transactions import *
|
||||||
from files.classes.views import *
|
from files.classes.views import *
|
||||||
from files.helpers.actions import execute_blackjack
|
from files.helpers.actions import execute_blackjack, execute_under_siege
|
||||||
from files.helpers.alerts import *
|
from files.helpers.alerts import *
|
||||||
from files.helpers.const import *
|
from files.helpers.const import *
|
||||||
from files.helpers.mail import *
|
from files.helpers.mail import *
|
||||||
|
@ -461,6 +461,7 @@ def message2(v, username):
|
||||||
g.db.add(c)
|
g.db.add(c)
|
||||||
g.db.flush()
|
g.db.flush()
|
||||||
execute_blackjack(v, c, c.body_html, 'message')
|
execute_blackjack(v, c, c.body_html, 'message')
|
||||||
|
execute_under_siege(v, c, c.body_html, 'message')
|
||||||
c.top_comment_id = c.id
|
c.top_comment_id = c.id
|
||||||
|
|
||||||
if user.id not in bots:
|
if user.id not in bots:
|
||||||
|
@ -536,6 +537,7 @@ def messagereply(v):
|
||||||
g.db.add(c)
|
g.db.add(c)
|
||||||
g.db.flush()
|
g.db.flush()
|
||||||
execute_blackjack(v, c, c.body_html, 'message')
|
execute_blackjack(v, c, c.body_html, 'message')
|
||||||
|
execute_under_siege(v, c, c.body_html, 'message')
|
||||||
|
|
||||||
if user_id and user_id not in (v.id, 2, bots):
|
if user_id and user_id not in (v.id, 2, bots):
|
||||||
notif = g.db.query(Notification).filter_by(comment_id=c.id, user_id=user_id).one_or_none()
|
notif = g.db.query(Notification).filter_by(comment_id=c.id, user_id=user_id).one_or_none()
|
||||||
|
|
|
@ -80,7 +80,6 @@ echo "psql -U postgres" > /p
|
||||||
echo "tmux -S /tmp/s a -t 0" > /c
|
echo "tmux -S /tmp/s a -t 0" > /c
|
||||||
echo "tmux -S /tmp/s a -t 1" > /c2
|
echo "tmux -S /tmp/s a -t 1" > /c2
|
||||||
echo "cd /rDrama && git pull" > /g
|
echo "cd /rDrama && git pull" > /g
|
||||||
echo '{"Bots": true, "Fart mode": false, "Read-only mode": false, "Signups": true, "login_required": false}' > /site_settings.json
|
|
||||||
|
|
||||||
cd ./chat
|
cd ./chat
|
||||||
yarn install
|
yarn install
|
||||||
|
|
Loading…
Reference in New Issue