Skip to content

Commit 6eb4ce8

Browse files
Client Leave/Join is now published to discord with redis magic (ParadiseSS13#17393)
1 parent 8a1f976 commit 6eb4ce8

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

code/modules/client/client_procs.dm

+51
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,9 @@
249249

250250
log_client_to_db(tdata) // Make sure our client exists in the DB
251251

252+
// We have a holder. Inform the relevant places
253+
INVOKE_ASYNC(src, .proc/announce_join)
254+
252255
pai_save = new(src)
253256

254257
// This is where we load all of the clients stuff from the DB
@@ -411,6 +414,7 @@
411414
return ..()
412415

413416
/client/Destroy()
417+
announce_leave() // Do not put this below
414418
if(holder)
415419
holder.owner = null
416420
GLOB.admins -= src
@@ -428,6 +432,53 @@
428432
return QDEL_HINT_HARDDEL_NOW
429433

430434

435+
/client/proc/announce_join()
436+
if(holder.rights & R_MENTOR)
437+
if(SSredis.connected)
438+
var/list/mentorcounter = staff_countup(R_MENTOR)
439+
var/msg = "**[ckey]** logged in. **[mentorcounter[1]]** mentor[mentorcounter[1] == 1 ? "" : "s"] online."
440+
var/list/data = list()
441+
data["author"] = "alice"
442+
data["source"] = GLOB.configuration.system.instance_id
443+
data["message"] = msg
444+
SSredis.publish("byond.msay.out", json_encode(data))
445+
446+
else if(holder.rights & R_BAN)
447+
if(SSredis.connected)
448+
var/list/admincounter = staff_countup(R_BAN)
449+
var/msg = "**[ckey]** logged in. **[admincounter[1]]** admin[admincounter[1] == 1 ? "" : "s"] online."
450+
var/list/data = list()
451+
data["author"] = "alice"
452+
data["source"] = GLOB.configuration.system.instance_id
453+
data["message"] = msg
454+
SSredis.publish("byond.asay.out", json_encode(data))
455+
456+
/client/proc/announce_leave()
457+
if(holder.rights & R_MENTOR)
458+
if(SSredis.connected)
459+
var/list/mentorcounter = staff_countup(R_MENTOR)
460+
var/mentor_count = mentorcounter[1]
461+
mentor_count-- // Exclude ourself
462+
var/msg = "**[ckey]** logged out. **[mentor_count]** mentor[mentor_count == 1 ? "" : "s"] online."
463+
var/list/data = list()
464+
data["author"] = "alice"
465+
data["source"] = GLOB.configuration.system.instance_id
466+
data["message"] = msg
467+
SSredis.publish("byond.msay.out", json_encode(data))
468+
469+
else if(holder.rights & R_BAN)
470+
if(SSredis.connected)
471+
var/list/admincounter = staff_countup(R_BAN)
472+
var/admin_count = admincounter[1]
473+
admin_count-- // Exclude ourself
474+
var/msg = "**[ckey]** logged out. **[admin_count]** admin[admin_count == 1 ? "" : "s"] online."
475+
var/list/data = list()
476+
data["author"] = "alice"
477+
data["source"] = GLOB.configuration.system.instance_id
478+
data["message"] = msg
479+
SSredis.publish("byond.asay.out", json_encode(data))
480+
481+
431482
/client/proc/donor_loadout_points()
432483
if(donator_level > 0 && prefs)
433484
prefs.max_gear_slots = GLOB.configuration.general.base_loadout_points + 5

0 commit comments

Comments
 (0)