Add a notification when temp-banned users reconnect (#27811)

* Add a notification when temp-banned users reconnect

* Stray space

* ID mistake

* For warnings too
This commit is contained in:
ShiftyRail
2020-09-22 23:49:28 +02:00
committed by GitHub
parent 3e3e022fa2
commit b2f4862ef5
9 changed files with 133 additions and 10 deletions

View File

@@ -93,10 +93,19 @@
else else
adminwho += ", [C]" adminwho += ", [C]"
reason = sql_sanitize_text(reason) var/sql = "INSERT INTO erro_ban (`id`,`bantime`,`serverip`,`bantype`,`reason`,`job`,`duration`,`rounds`,`expiration_time`,`ckey`,`computerid`,`ip`,`a_ckey`,`a_computerid`,`a_ip`,`who`,`adminwho`,`edits`,`unbanned`,`unbanned_datetime`,`unbanned_ckey`,`unbanned_computerid`,`unbanned_ip`, `unbanned_notification`) VALUES (null, Now(), '[serverip]', '[bantype_str]', :reason, :job, [(duration)?"[duration]":"0"], [(rounds)?"[rounds]":"0"], Now() + INTERVAL [(duration>0) ? duration : 0] MINUTE, :ckey, :computer_id, :ip, :a_ckey, :a_computerid, :a_ip, :who, :admin_who, '', null, null, null, null, null, 0)"
var/datum/DBQuery/query_insert = SSdbcore.NewQuery(sql, list(
var/sql = "INSERT INTO erro_ban (`id`,`bantime`,`serverip`,`bantype`,`reason`,`job`,`duration`,`rounds`,`expiration_time`,`ckey`,`computerid`,`ip`,`a_ckey`,`a_computerid`,`a_ip`,`who`,`adminwho`,`edits`,`unbanned`,`unbanned_datetime`,`unbanned_ckey`,`unbanned_computerid`,`unbanned_ip`) VALUES (null, Now(), '[serverip]', '[bantype_str]', '[reason]', '[job]', [(duration)?"[duration]":"0"], [(rounds)?"[rounds]":"0"], Now() + INTERVAL [(duration>0) ? duration : 0] MINUTE, '[ckey]', '[computerid]', '[ip]', '[a_ckey]', '[a_computerid]', '[a_ip]', '[who]', '[adminwho]', '', null, null, null, null, null)" "reason" = reason,
var/datum/DBQuery/query_insert = SSdbcore.NewQuery(sql) "job" = job,
"ckey" = ckey,
"computer_id" = computerid,
"ip" = ip,
"a_ckey" = a_ckey,
"a_computerid" = a_computerid,
"a_ip" = a_ip,
"who" = who,
"admin_who" = adminwho,
))
if(!query_insert.Execute()) if(!query_insert.Execute())
message_admins("Error: [query_insert.ErrorMsg()]") message_admins("Error: [query_insert.ErrorMsg()]")
log_sql("Error: [query_insert.ErrorMsg()]") log_sql("Error: [query_insert.ErrorMsg()]")

View File

@@ -592,7 +592,10 @@ var/list/admin_verbs_mod = list(
message_admins("[key_name_admin(src)] has warned [key_name_admin(C)] - [warn_reason]. They have [MAX_WARNS-D.warns] strikes remaining. And have been warn banned [D.warnbans] [D.warnbans == 1 ? "time" : "times"]") message_admins("[key_name_admin(src)] has warned [key_name_admin(C)] - [warn_reason]. They have [MAX_WARNS-D.warns] strikes remaining. And have been warn banned [D.warnbans] [D.warnbans == 1 ? "time" : "times"]")
else else
message_admins("[key_name_admin(src)] has warned [warned_ckey] (DC) - [warn_reason]. They have [MAX_WARNS-D.warns] strikes remaining. And have been warn banned [D.warnbans] [D.warnbans == 1 ? "time" : "times"]") message_admins("[key_name_admin(src)] has warned [warned_ckey] (DC) - [warn_reason]. They have [MAX_WARNS-D.warns] strikes remaining. And have been warn banned [D.warnbans] [D.warnbans == 1 ? "time" : "times"]")
D.save_preferences_sqlite(C, C.ckey) D.show_warning_next_time = 1
D.last_warned_message = warn_reason
D.warning_admin = ckey
D.save_preferences_sqlite(C, warned_ckey)
feedback_add_details("admin_verb","WARN") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc! feedback_add_details("admin_verb","WARN") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
/client/proc/unwarn(warned_ckey) /client/proc/unwarn(warned_ckey)

View File

@@ -208,6 +208,60 @@
send_resources() send_resources()
var/datum/DBQuery/query = SSdbcore.NewQuery("SELECT id, ckey, ip, computerid, a_ckey, reason, expiration_time, duration, bantime, bantype, unbanned, unbanned_ckey, unbanned_datetime FROM erro_ban WHERE (ckey = :ckey [address ? "OR ip = :address" : ""] [computer_id ? "OR computerid = :computer_id" : ""]) AND unbanned_notification = 0;",
list(
"ckey" = ckey,
"address" = address,
"computer_id" = computer_id,
))
if(!query.Execute())
message_admins("Error: [query.ErrorMsg()]")
log_sql("Error: [query.ErrorMsg()]")
qdel(query)
else
while(query.NextRow())
var/id = query.item[1]
var/pckey = query.item[2]
//var/pip = query.item[3]
//var/pcid = query.item[4]
var/ackey = query.item[5]
var/reason = query.item[6]
var/expiration = query.item[7]
var/duration = query.item[8]
var/bantime = query.item[9]
//var/bantype = query.item[10]
var/unbanned = query.item[11]
var/unbanned_ckey = query.item[12]
var/unbanned_datetime = query.item[13]
if (unbanned && unbanned_ckey && unbanned_datetime)
to_chat(src, "<span class='notice'><b>You, or another user of this ckey ([pckey]) were banned by [ackey] on [bantime] [duration > 0 ? "for [duration] minutes" : "permanently"].</b></span>")
to_chat(src, "<span class='notice'>This ban has been revoked by [unbanned_ckey] at time [unbanned_datetime].</span>")
to_chat(src, "<span class='notice'>The reason was: '[reason]'.</span>")
to_chat(src, "<span class='notice'>For more information, you can ask admins in ahelps or at https://ss13.moe. </span>")
to_chat(src, "<span class='notice'><b>This ban has expired. You can now play the game.</b></span>")
else
to_chat(src, "<span class='notice'><b>You, or another user of this ckey ([pckey]) were banned by [ackey] on [bantime] [duration > 0 ? "for [duration] minutes" : "permanently"].</b></span>")
if (duration > 0)
to_chat(src, "<span class='notice'>This ban expired on [expiration].</span>")
to_chat(src, "<span class='notice'>The reason was: '[reason]'.</span>")
to_chat(src, "<span class='notice'>For more information, you can ask admins in ahelps or at https://ss13.moe. </span>")
to_chat(src, "<span class='notice'><b>This ban has expired. You can now play the game.</b></span>")
var/datum/DBQuery/update_query = SSdbcore.NewQuery("UPDATE erro_ban SET unbanned_notification = 1 WHERE id = [id]")
if(!update_query.Execute())
message_admins("Error: [update_query.ErrorMsg()]")
log_sql("Error: [update_query.ErrorMsg()]")
qdel(update_query)
if (prefs && prefs.show_warning_next_time)
to_chat(src, "<span class='notice'><b>You, or another user of this ckey ([ckey]) were warned by [prefs.warning_admin].</b></span>")
to_chat(src, "<span class='notice'>The reason was: '[prefs.last_warned_message]'.</span>")
to_chat(src, "<span class='notice'>For more information, you can ask admins in ahelps or at https://ss13.moe. </span>")
to_chat(src, "<span class='notice'><b>You can now play the game.</b></span>")
prefs.show_warning_next_time = 0
prefs.save_preferences_sqlite(src, src.ckey)
if(prefs.lastchangelog != changelog_hash) //bolds the changelog button on the interface so we know there are updates. if(prefs.lastchangelog != changelog_hash) //bolds the changelog button on the interface so we know there are updates.
winset(src, "rpane.changelog", "background-color=#eaeaea;font-style=bold") winset(src, "rpane.changelog", "background-color=#eaeaea;font-style=bold")
prefs.SetChangelog(ckey,changelog_hash) prefs.SetChangelog(ckey,changelog_hash)

View File

@@ -96,6 +96,9 @@ var/const/MAX_SAVE_SLOTS = 16
//non-preference stuff //non-preference stuff
var/warns = 0 var/warns = 0
var/show_warning_next_time = 0
var/last_warned_message = ""
var/warning_admin = ""
var/warnbans = 0 var/warnbans = 0
var/muted = 0 var/muted = 0
var/last_ip var/last_ip

View File

@@ -112,6 +112,9 @@
obj_chat_on_map = text2num(preference_list_client["obj_chat_on_map"]) obj_chat_on_map = text2num(preference_list_client["obj_chat_on_map"])
no_goonchat_for_obj = text2num(preference_list_client["no_goonchat_for_obj"]) no_goonchat_for_obj = text2num(preference_list_client["no_goonchat_for_obj"])
tgui_fancy = text2num(preference_list_client["tgui_fancy"]) tgui_fancy = text2num(preference_list_client["tgui_fancy"])
show_warning_next_time = text2num(preference_list_client["show_warning_next_time"])
last_warned_message = preference_list_client["last_warned_message"]
warning_admin = preference_list_client["warning_admin"]
ooccolor = sanitize_hexcolor(ooccolor, initial(ooccolor)) ooccolor = sanitize_hexcolor(ooccolor, initial(ooccolor))
lastchangelog = sanitize_text(lastchangelog, initial(lastchangelog)) lastchangelog = sanitize_text(lastchangelog, initial(lastchangelog))
@@ -147,6 +150,7 @@
obj_chat_on_map = sanitize_integer(obj_chat_on_map, 0, 1, initial(obj_chat_on_map)) obj_chat_on_map = sanitize_integer(obj_chat_on_map, 0, 1, initial(obj_chat_on_map))
no_goonchat_for_obj = sanitize_integer(no_goonchat_for_obj, 0, 1, initial(no_goonchat_for_obj)) no_goonchat_for_obj = sanitize_integer(no_goonchat_for_obj, 0, 1, initial(no_goonchat_for_obj))
tgui_fancy = sanitize_integer(tgui_fancy, 0, 1, initial(tgui_fancy)) tgui_fancy = sanitize_integer(tgui_fancy, 0, 1, initial(tgui_fancy))
show_warning_next_time = sanitize_integer(show_warning_next_time, 0, 1, initial(show_warning_next_time))
initialize_preferences() initialize_preferences()
return 1 return 1
@@ -228,15 +232,15 @@
check.Add("SELECT ckey FROM client WHERE ckey = ?", ckey) check.Add("SELECT ckey FROM client WHERE ckey = ?", ckey)
if(check.Execute(db)) if(check.Execute(db))
if(!check.NextRow()) if(!check.NextRow())
q.Add("INSERT into client (ckey, ooc_color, lastchangelog, UI_style, default_slot, toggles, UI_style_color, UI_style_alpha, warns, warnbans, randomslot, volume, usewmp, special, usenanoui, tooltips, progress_bars, space_parallax, space_dust, parallax_speed, stumble, attack_animation, pulltoggle, credits, jingle, hear_voicesound, hear_instruments, ambience_volume, credits_volume, window_flashing, antag_objectives, typing_indicator, mob_chat_on_map, max_chat_length, obj_chat_on_map, no_goonchat_for_obj, tgui_fancy) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)",\ q.Add("INSERT into client (ckey, ooc_color, lastchangelog, UI_style, default_slot, toggles, UI_style_color, UI_style_alpha, warns, warnbans, randomslot, volume, usewmp, special, usenanoui, tooltips, progress_bars, space_parallax, space_dust, parallax_speed, stumble, attack_animation, pulltoggle, credits, jingle, hear_voicesound, hear_instruments, ambience_volume, credits_volume, window_flashing, antag_objectives, typing_indicator, mob_chat_on_map, max_chat_length, obj_chat_on_map, no_goonchat_for_obj, tgui_fancy, show_warning_next_time, last_warned_message, warning_admin) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)",\
ckey, ooccolor, lastchangelog, UI_style, default_slot, toggles, UI_style_color, UI_style_alpha, warns, warnbans, randomslot, volume, usewmp, special_popup, usenanoui, tooltips, progress_bars, space_parallax, space_dust, parallax_speed, stumble, attack_animation, pulltoggle, credits, jingle, hear_voicesound, hear_instruments, ambience_volume, credits_volume, window_flashing, antag_objectives, typing_indicator, mob_chat_on_map, max_chat_length, obj_chat_on_map, no_goonchat_for_obj) ckey, ooccolor, lastchangelog, UI_style, default_slot, toggles, UI_style_color, UI_style_alpha, warns, warnbans, randomslot, volume, usewmp, special_popup, usenanoui, tooltips, progress_bars, space_parallax, space_dust, parallax_speed, stumble, attack_animation, pulltoggle, credits, jingle, hear_voicesound, hear_instruments, ambience_volume, credits_volume, window_flashing, antag_objectives, typing_indicator, mob_chat_on_map, max_chat_length, obj_chat_on_map, no_goonchat_for_obj, tgui_fancy, show_warning_next_time, last_warned_message, warning_admin)
if(!q.Execute(db)) if(!q.Execute(db))
message_admins("Error in save_preferences_sqlite [__FILE__] ln:[__LINE__] #: [q.Error()] - [q.ErrorMsg()]") message_admins("Error in save_preferences_sqlite [__FILE__] ln:[__LINE__] #: [q.Error()] - [q.ErrorMsg()]")
WARNING("Error in save_preferences_sqlite [__FILE__] ln:[__LINE__] #:[q.Error()] - [q.ErrorMsg()]") WARNING("Error in save_preferences_sqlite [__FILE__] ln:[__LINE__] #:[q.Error()] - [q.ErrorMsg()]")
return 0 return 0
else else
q.Add("UPDATE client SET ooc_color=?,lastchangelog=?,UI_style=?,default_slot=?,toggles=?,UI_style_color=?,UI_style_alpha=?,warns=?,warnbans=?,randomslot=?,volume=?,usewmp=?,special=?,usenanoui=?,tooltips=?,progress_bars=?,space_parallax=?,space_dust=?,parallax_speed=?, stumble=?, attack_animation=?, pulltoggle=?, credits=?, jingle=?, hear_voicesound=?, hear_instruments=?, ambience_volume=?, credits_volume=?, window_flashing=?, antag_objectives=? , typing_indicator=? , mob_chat_on_map=? , max_chat_length=?, obj_chat_on_map=?, no_goonchat_for_obj=?, tgui_fancy=? WHERE ckey = ?",\ q.Add("UPDATE client SET ooc_color=?,lastchangelog=?,UI_style=?,default_slot=?,toggles=?,UI_style_color=?,UI_style_alpha=?,warns=?,warnbans=?,randomslot=?,volume=?,usewmp=?,special=?,usenanoui=?,tooltips=?,progress_bars=?,space_parallax=?,space_dust=?,parallax_speed=?, stumble=?, attack_animation=?, pulltoggle=?, credits=?, jingle=?, hear_voicesound=?, hear_instruments=?, ambience_volume=?, credits_volume=?, window_flashing=?, antag_objectives=? , typing_indicator=? , mob_chat_on_map=? , max_chat_length=?, obj_chat_on_map=?, no_goonchat_for_obj=?, tgui_fancy=?, show_warning_next_time=?, last_warned_message=?, warning_admin=? WHERE ckey = ?",\
ooccolor, lastchangelog, UI_style, default_slot, toggles, UI_style_color, UI_style_alpha, warns, warnbans, randomslot, volume, usewmp, special_popup, usenanoui, tooltips, progress_bars, space_parallax, space_dust, parallax_speed, stumble, attack_animation, pulltoggle, credits, jingle, hear_voicesound, hear_instruments, ambience_volume, credits_volume, window_flashing, antag_objectives, typing_indicator, mob_chat_on_map, max_chat_length, obj_chat_on_map,no_goonchat_for_obj, tgui_fancy, ckey) ooccolor, lastchangelog, UI_style, default_slot, toggles, UI_style_color, UI_style_alpha, warns, warnbans, randomslot, volume, usewmp, special_popup, usenanoui, tooltips, progress_bars, space_parallax, space_dust, parallax_speed, stumble, attack_animation, pulltoggle, credits, jingle, hear_voicesound, hear_instruments, ambience_volume, credits_volume, window_flashing, antag_objectives, typing_indicator, mob_chat_on_map, max_chat_length, obj_chat_on_map,no_goonchat_for_obj, tgui_fancy, show_warning_next_time, last_warned_message, warning_admin, ckey)
if(!q.Execute(db)) if(!q.Execute(db))
message_admins("Error in save_preferences_sqlite [__FILE__] ln:[__LINE__] #: [q.Error()] - [q.ErrorMsg()]") message_admins("Error in save_preferences_sqlite [__FILE__] ln:[__LINE__] #: [q.Error()] - [q.ErrorMsg()]")
WARNING("Error in save_preferences_sqlite [__FILE__] ln:[__LINE__] #:[q.Error()] - [q.ErrorMsg()]") WARNING("Error in save_preferences_sqlite [__FILE__] ln:[__LINE__] #:[q.Error()] - [q.ErrorMsg()]")

View File

@@ -10,7 +10,7 @@
return TRUE return TRUE
/datum/migration/mysql/ss13/_013/down() /datum/migration/mysql/ss13/_014/down()
if(hasColumn("erro_poll_question","createdby_ip")) if(hasColumn("erro_poll_question","createdby_ip"))
return execute("ALTER TABLE erro_poll_question DROP COLUMN `createdby_ip` VARCHAR(32) NULL;"); return execute("ALTER TABLE erro_poll_question DROP COLUMN `createdby_ip` VARCHAR(32) NULL;");
else else

View File

@@ -0,0 +1,21 @@
/datum/migration/mysql/ss13/_015
id = 15
name = "Add unbanned notification for players"
/datum/migration/mysql/ss13/_015/up()
if(!hasColumn("erro_ban","unbanned_notification"))
var/sql1 = execute("ALTER TABLE erro_ban ADD COLUMN `unbanned_notification` int(2) NOT NULL DEFAULT '0';");
var/sql2 = execute("UPDATE erro_ban SET `unbanned_notification` = 1;") // Every previous ban gets an unban notification
return (sql1 && sql2)
else
warning("unbanned_notification column exists. Skipping addition.")
return TRUE
/datum/migration/mysql/ss13/_015/down()
if(hasColumn("erro_ban","unbanned_notification"))
return execute("ALTER TABLE erro_ban DROP COLUMN `unbanned_notification` NOT NULL DEFAULT '0';");
else
warning("unbanned_notification column does not exist. Skipping drop.")
return TRUE

View File

@@ -0,0 +1,27 @@
/datum/migration/sqlite/ss13_prefs/_025
id = 25
name = "Warning notification"
/datum/migration/sqlite/ss13_prefs/_025/up()
var/sql1 = TRUE
var/sql2 = TRUE
var/sql3 = TRUE
if(!hasColumn("client","show_warning_next_time"))
sql1 = execute("ALTER TABLE `client` ADD COLUMN show_warning_next_time INTEGER DEFAULT 0")
if(!hasColumn("client","last_warned_message"))
sql2 = execute("ALTER TABLE `client` ADD COLUMN last_warned_message TEXT DEFAULT ''")
if(!hasColumn("client","warning_admin"))
sql3 = execute("ALTER TABLE `client` ADD COLUMN warning_admin TEXT DEFAULT ''")
return sql1 && sql2 && sql3
/datum/migration/sqlite/ss13_prefs/_025/down()
var/sql1 = TRUE
var/sql2 = TRUE
var/sql3 = TRUE
if(hasColumn("client","show_warning_next_time"))
sql1 = execute("ALTER TABLE `client` DROP COLUMN show_warning_next_time")
if(hasColumn("client","last_warned_message"))
sql2 = execute("ALTER TABLE `client` DROP COLUMN last_warned_message")
if(hasColumn("client","warning_admin"))
sql3 = execute("ALTER TABLE `client` DROP COLUMN warning_admin")
return sql1 && sql2 && sql3

View File

@@ -1639,6 +1639,7 @@
#include "code\modules\migrations\SS13\012-add-customitems-table.dm" #include "code\modules\migrations\SS13\012-add-customitems-table.dm"
#include "code\modules\migrations\SS13\013-add-createdby-ckey-to-polls.dm" #include "code\modules\migrations\SS13\013-add-createdby-ckey-to-polls.dm"
#include "code\modules\migrations\SS13\014-add-createdby-ip-to-polls.dm" #include "code\modules\migrations\SS13\014-add-createdby-ip-to-polls.dm"
#include "code\modules\migrations\SS13\015-unbanned-var.dm"
#include "code\modules\migrations\SS13\_base.dm" #include "code\modules\migrations\SS13\_base.dm"
#include "code\modules\migrations\SS13_Prefs\001-create.dm" #include "code\modules\migrations\SS13_Prefs\001-create.dm"
#include "code\modules\migrations\SS13_Prefs\002-add-progress-bars.dm" #include "code\modules\migrations\SS13_Prefs\002-add-progress-bars.dm"
@@ -1664,6 +1665,7 @@
#include "code\modules\migrations\SS13_Prefs\022-say_bubbles.dm" #include "code\modules\migrations\SS13_Prefs\022-say_bubbles.dm"
#include "code\modules\migrations\SS13_Prefs\023-runechat.dm" #include "code\modules\migrations\SS13_Prefs\023-runechat.dm"
#include "code\modules\migrations\SS13_Prefs\024-add-tgui-fancy.dm" #include "code\modules\migrations\SS13_Prefs\024-add-tgui-fancy.dm"
#include "code\modules\migrations\SS13_Prefs\025-warning_notif.dm"
#include "code\modules\migrations\SS13_Prefs\_base.dm" #include "code\modules\migrations\SS13_Prefs\_base.dm"
#include "code\modules\mining\abandonedcrates.dm" #include "code\modules\mining\abandonedcrates.dm"
#include "code\modules\mining\debug_shit.dm" #include "code\modules\mining\debug_shit.dm"