mirror of
https://github.com/VOREStation/VOREStation.git
synced 2026-08-22 11:38:12 +01:00
Adds 'age' command to world.Topic, for the IRC bot. Also runs all keys through ckey() before using them, to avoid easily-fixed errors
This commit is contained in:
@@ -177,6 +177,25 @@
|
||||
return ..()
|
||||
|
||||
|
||||
// here because it's similar to below
|
||||
|
||||
// Returns null if no DB connection can be established, or -1 if the requested key was not found in the database
|
||||
|
||||
/proc/get_player_age(key)
|
||||
establish_db_connection()
|
||||
if(!dbcon.IsConnected())
|
||||
return null
|
||||
|
||||
var/sql_ckey = sql_sanitize_text(ckey(key))
|
||||
|
||||
var/DBQuery/query = dbcon.NewQuery("SELECT datediff(Now(),firstseen) as age FROM erro_player WHERE ckey = '[sql_ckey]'")
|
||||
query.Execute()
|
||||
|
||||
if(query.NextRow())
|
||||
return text2num(query.item[1])
|
||||
else
|
||||
return -1
|
||||
|
||||
|
||||
/client/proc/log_client_to_db()
|
||||
|
||||
|
||||
+21
-2
@@ -156,9 +156,10 @@ var/world_topic_spam_protect_time = world.timeofday
|
||||
return "Bad Key"
|
||||
|
||||
var/client/C
|
||||
var/req_ckey = ckey(input["adminmsg"])
|
||||
|
||||
for(var/client/K in clients)
|
||||
if(K.ckey == input["adminmsg"])
|
||||
if(K.ckey == req_ckey)
|
||||
C = K
|
||||
break
|
||||
if(!C)
|
||||
@@ -199,10 +200,28 @@ var/world_topic_spam_protect_time = world.timeofday
|
||||
world_topic_spam_protect_ip = addr
|
||||
return "Bad Key"
|
||||
|
||||
return show_player_info_irc(input["notes"])
|
||||
return show_player_info_irc(ckey(input["notes"]))
|
||||
|
||||
else if(copytext(T,1,4) == "age")
|
||||
var/input[] = params2list(T)
|
||||
if(input["key"] != config.comms_password)
|
||||
if(world_topic_spam_protect_ip == addr && abs(world_topic_spam_protect_time - world.time) < 50)
|
||||
spawn(50)
|
||||
world_topic_spam_protect_time = world.time
|
||||
return "Bad Key (Throttled)"
|
||||
|
||||
world_topic_spam_protect_time = world.time
|
||||
world_topic_spam_protect_ip = addr
|
||||
return "Bad Key"
|
||||
|
||||
var/age = get_player_age(input["age"])
|
||||
if(isnum(age))
|
||||
if(age >= 0)
|
||||
return "[age]"
|
||||
else
|
||||
return "Ckey not found"
|
||||
else
|
||||
return "Database connection failed or not set up"
|
||||
|
||||
|
||||
/world/Reboot(var/reason)
|
||||
|
||||
Reference in New Issue
Block a user