make blackjack affect usernames too

master
Aevann 2023-10-26 23:08:29 +03:00
parent 6dbdf10531
commit 0b0f8c69d5
4 changed files with 15 additions and 26 deletions

View File

@ -511,27 +511,11 @@ def execute_antispam_comment_check(body, v):
g.db.commit()
abort(403, "Too much spam!")
def execute_by_username(v):
username = v.username.lower()
if username.startswith("icosaka") or ("dylan" in username and "hewitt" in username):
v.shadowbanned = AUTOJANNY_ID
v.ban_reason = "Banned username"
g.db.add(v)
ma = ModAction(
kind="shadowban",
user_id=AUTOJANNY_ID,
target_user_id=v.id,
_note=f'reason: "Banned username ({v.age} seconds)"'
)
g.db.add(ma)
def execute_under_siege(v, target, body, kind):
if v.shadowbanned: return
if SITE == 'watchpeopledie.tv':
execute_by_username(v)
if v.shadowbanned: return
if kind != 'post': return
if SITE == 'watchpeopledie.tv' and kind != 'post':
return
if not get_setting("under_siege"): return
if v.admin_level >= PERMS['BYPASS_UNDER_SIEGE_MODE']: return

View File

@ -412,15 +412,16 @@ def award_thing(v, thing_type, id):
if not valid_username_regex.fullmatch(new_name):
abort(400, "You need to enter a valid username to change the recipient to.")
existing = get_user(new_name, graceful=True)
if existing and existing.id != author.id:
abort(400, f"@{new_name} is already taken!")
if not execute_blackjack(v, None, new_name, f'namelock award attempt on @{author.username}'):
existing = get_user(new_name, graceful=True)
if existing and existing.id != author.id:
abort(400, f"@{new_name} is already taken!")
if not author.prelock_username:
author.prelock_username = author.username
author.username = new_name
author.namechanged = int(time.time()) + 86400
badge_grant(user=author, badge_id=281)
if not author.prelock_username:
author.prelock_username = author.username
author.username = new_name
author.namechanged = int(time.time()) + 86400
badge_grant(user=author, badge_id=281)
elif kind == "pause":
badge_grant(badge_id=68, user=author)
elif kind == "unpausable":

View File

@ -359,6 +359,8 @@ def sign_up_post(v):
elif CARP_ID:
send_notification(CARP_ID, f"A new user - @{new_user.username} - has signed up!")
execute_blackjack(new_user, None, new_user.username, 'username')
if redir and is_site_url(redir) and redir not in NO_LOGIN_REDIRECT_URLS:
return redirect(redir)
return redirect('/')

View File

@ -777,6 +777,8 @@ def settings_name_change(v):
g.db.add(v)
execute_blackjack(v, None, v.username, 'username')
return {"message": "Name successfully changed!"}
@app.post("/settings/song_change_mp3")