mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2026-08-27 15:01:04 +01:00
Adds a notification system (#4931)
Allows to set up notifications if a specific player connects.
This commit is contained in:
@@ -6,7 +6,8 @@ var/list/admin_verbs_default = list(
|
||||
/client/proc/deadmin_self, /*destroys our own admin datum so we can play as a regular player*/
|
||||
/client/proc/hide_verbs, /*hides all our adminverbs*/
|
||||
/client/proc/hide_most_verbs, /*hides all our hideable adminverbs*/
|
||||
/client/proc/cmd_mentor_check_new_players
|
||||
/client/proc/cmd_mentor_check_new_players,
|
||||
/client/proc/notification_add /*allows everyone to set up player notifications*/
|
||||
)
|
||||
var/list/admin_verbs_admin = list(
|
||||
/client/proc/debug_variables, /*allows us to -see- the variables of any instance in the game.*/
|
||||
|
||||
@@ -102,7 +102,7 @@
|
||||
*/
|
||||
|
||||
/client/verb/warnings_check()
|
||||
set name = "My warnings"
|
||||
set name = "Warnings and Notifications"
|
||||
set category = "OOC"
|
||||
set desc = "Display warnings issued to you."
|
||||
|
||||
@@ -115,7 +115,48 @@
|
||||
alert("Connection to the SQL database lost. Aborting. Please alert an Administrator or a member of staff.")
|
||||
return
|
||||
|
||||
var/dat = "<div align='center'><h3>Warnings received</h3></div><br>"
|
||||
var/dat = ""
|
||||
|
||||
//
|
||||
// Notifications
|
||||
//
|
||||
|
||||
var/DBQuery/notification_query = dbcon.NewQuery({"SELECT
|
||||
id, message, created_by
|
||||
FROM ss13_player_notifications
|
||||
WHERE
|
||||
acked_at IS NULL
|
||||
AND ckey = :ckey:
|
||||
AND type IN ('player_greeting','player_greeting_chat')
|
||||
"})
|
||||
notification_query.Execute(list("ckey" = ckey))
|
||||
|
||||
var/notification_header=0
|
||||
while(notification_query.NextRow())
|
||||
if(!notification_header)
|
||||
notification_header=1
|
||||
dat += "<div align='center'><h3>Pending Notifications</h3></div><br>"
|
||||
dat += "<table width='90%' bgcolor='#e3e3e3' cellpadding='5' cellspacing='0' align='center'>"
|
||||
dat += "<tr>"
|
||||
dat += "<th width='20%'>ADMIN</th>"
|
||||
dat += "<th width='60%'>TEXT</th>"
|
||||
dat += "<th width='20%'>ACKNOWLEDGE</th>"
|
||||
dat += "</tr>"
|
||||
|
||||
dat += "<tr bgcolor='90ee90' align='center'>"
|
||||
dat += "<td>[notification_query.item[3]]</td>"
|
||||
dat += "<td>[notification_query.item[2]]</td>"
|
||||
dat += "<td><b>(<a href='byond://?src=\ref[src];notifacknowledge=[notification_query.item[1]]'>Acknowledge Notification</a>)</b></td>"
|
||||
dat += "</tr>"
|
||||
|
||||
if(notification_header)
|
||||
dat += "</table>"
|
||||
|
||||
//
|
||||
// Warnings
|
||||
//
|
||||
|
||||
dat += "<div align='center'><h3>Warnings Received</h3></div><br>"
|
||||
|
||||
dat += "<table width='90%' bgcolor='#e3e3e3' cellpadding='5' cellspacing='0' align='center'>"
|
||||
dat += "<tr>"
|
||||
@@ -182,6 +223,23 @@
|
||||
|
||||
warnings_check()
|
||||
|
||||
/client/proc/notifications_acknowledge(var/id)
|
||||
if(!id)
|
||||
error("Error: Argument ID for notificaton acknowledgement not supplied.")
|
||||
return
|
||||
|
||||
if (!establish_db_connection(dbcon))
|
||||
error("Error: Unable to establish db connection during notification acknowledgement.")
|
||||
return
|
||||
|
||||
var/DBQuery/query = dbcon.NewQuery({"UPDATE ss13_player_notifications
|
||||
SET acked_by = :ckey:, acked_at = NOW()
|
||||
WHERE id = :id: AND ckey = :ckey:
|
||||
"})
|
||||
query.Execute(list("ckey" = src.ckey, "id" = id))
|
||||
|
||||
warnings_check()
|
||||
|
||||
/*
|
||||
* A proc to gather notifications regarding your warnings.
|
||||
* Called by /datum/preferences/proc/gather_notifications() in preferences.dm
|
||||
@@ -334,6 +392,50 @@
|
||||
usr << browse(dat, "window=lookupwarns;size=900x500")
|
||||
feedback_add_details("admin_verb","WARN-LKUP")
|
||||
|
||||
//Admin Proc to add a new User Notification
|
||||
/client/proc/notification_add()
|
||||
set category = "Admin"
|
||||
set name = "Add Notification"
|
||||
|
||||
if(!check_rights(R_ADMIN|R_MOD|R_DEV|R_CCIAA))
|
||||
return
|
||||
|
||||
if (!establish_db_connection(dbcon))
|
||||
error("Error: Unable to establish db connection while adding a notification.")
|
||||
return
|
||||
|
||||
var/ckey = ckey(input(usr, "What ckey?", "Enter a ckey"))
|
||||
if(!ckey)
|
||||
to_chat(usr,"You need to specify a ckey.")
|
||||
return
|
||||
|
||||
//Validate ckey
|
||||
var/DBQuery/validatequery = dbcon.NewQuery("SELECT id FROM ss13_player WHERE ckey = :ckey:")
|
||||
validatequery.Execute(list("ckey" = ckey))
|
||||
|
||||
if (validatequery.RowCount() == 0)
|
||||
to_chat(usr, "Could not find a player with that ckey.")
|
||||
return
|
||||
else if (validatequery.RowCount() != 1)
|
||||
to_chat(usr, "Found more than one player with this ckey. This should not happen, please inform the server maintainers.")
|
||||
return
|
||||
|
||||
var/list/types=list("player_greeting","player_greeting_chat","admin","ccia")
|
||||
var/type = input(usr, "Which Type?", "Choose a type", "") as null|anything in (types)
|
||||
if(!type)
|
||||
to_chat(usr,"You need to specify a type.")
|
||||
return
|
||||
|
||||
var/message = sanitize(input(usr,"Notification Message", "Specify a notification message"))
|
||||
if(!message)
|
||||
to_chat(usr,"You need to specify a notification message.")
|
||||
return
|
||||
|
||||
var/DBQuery/addquery = dbcon.NewQuery("INSERT INTO ss13_player_notifications (`ckey`, `type`, `message`, `created_by`) VALUES (:ckey:, :type:, :message:, :a_ckey:)")
|
||||
addquery.Execute(list("ckey" = ckey, "type" = type, "message" = message, "a_ckey" = usr.ckey))
|
||||
to_chat(usr,"Notification added.")
|
||||
|
||||
|
||||
/*
|
||||
* A proc for editing and deleting warnings issued
|
||||
*/
|
||||
|
||||
@@ -101,6 +101,10 @@
|
||||
if(href_list["warnacknowledge"])
|
||||
var/queryid = text2num(href_list["warnacknowledge"])
|
||||
warnings_acknowledge(queryid)
|
||||
|
||||
if(href_list["notifacknowledge"])
|
||||
var/queryid = text2num(href_list["notifacknowledge"])
|
||||
notifications_acknowledge(queryid)
|
||||
|
||||
if(href_list["warnview"])
|
||||
warnings_check()
|
||||
|
||||
@@ -153,9 +153,62 @@
|
||||
var/cciaa_actions = count_ccia_actions(user)
|
||||
if (cciaa_actions)
|
||||
new_notification("info", cciaa_actions)
|
||||
|
||||
add_active_notifications(user)
|
||||
|
||||
/datum/preferences/proc/add_active_notifications(var/client/user)
|
||||
if(!user)
|
||||
return null
|
||||
|
||||
if (!establish_db_connection(dbcon))
|
||||
error("Error initiatlizing database connection while getting notifications.")
|
||||
return null
|
||||
|
||||
var/DBQuery/query = dbcon.NewQuery({"SELECT
|
||||
message, type, id
|
||||
FROM ss13_player_notifications
|
||||
WHERE acked_at IS NULL AND ckey = :ckey:
|
||||
"})
|
||||
query.Execute(list("ckey" = user.ckey))
|
||||
|
||||
var/chat_notification=0
|
||||
var/panel_notification=0
|
||||
var/notification_count=0
|
||||
|
||||
while(query.NextRow())
|
||||
var/autoack=0
|
||||
//Lets loop through the results
|
||||
switch(query.item[2])
|
||||
if("player_greeting")
|
||||
panel_notification=1
|
||||
notification_count++
|
||||
if("player_greeting_chat")
|
||||
chat_notification=1
|
||||
panel_notification=1
|
||||
notification_count++
|
||||
if("admin")
|
||||
discord_bot.send_to_admins("Server Notification for [user.ckey]: [query.item[1]]")
|
||||
post_webhook_event(WEBHOOK_ADMIN, list("title"="Server Notification for: [user.ckey]", "message"="Server Notification Triggered for [user.ckey]: [query.item[1]]"))
|
||||
//Immediately ack the notification
|
||||
autoack=1
|
||||
if("ccia")
|
||||
discord_bot.send_to_cciaa("Server Notification for [user.ckey]: [query.item[1]]")
|
||||
post_webhook_event(WEBHOOK_CCIAA_EMERGENCY_MESSAGE, list("title"="Server Notification for: [user.ckey]", "message"="Server Notification Triggered for [user.ckey]: [query.item[1]]"))
|
||||
//Immeidately ack the notification
|
||||
autoack=1
|
||||
if(autoack)
|
||||
var/DBQuery/ackquery = dbcon.NewQuery({"UPDATE ss13_player_notifications
|
||||
SET acked_by = 'autoack-server', acked_at = NOW()
|
||||
WHERE id = :id:
|
||||
"})
|
||||
ackquery.Execute(list("id" = query.item[3]))
|
||||
if(panel_notification)
|
||||
new_notification("warning","You have <b>[notification_count] unread notifications!</b> Click <a href='?JSlink=warnings;notification=:src_ref'>here</a> to review and acknowledge them!")
|
||||
if(chat_notification)
|
||||
to_chat(user,"<font color='red'><BIG><B>You have unacknowledged notifications.</B></BIG><br>Click <a href='?JSlink=warnings;notification=:src_ref'>here</a> to review and acknowledge them!</font>")
|
||||
|
||||
/*
|
||||
* Helper proc for getting a count of active CCIA actions against the player's character.
|
||||
* Helper proc for getting a count of active CCIA actions against the player's characters.
|
||||
*/
|
||||
/datum/preferences/proc/count_ccia_actions(var/client/user)
|
||||
if (!user)
|
||||
|
||||
Reference in New Issue
Block a user