mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2026-08-22 20:43:10 +01:00
Adds a notification system (#4931)
Allows to set up notifications if a specific player connects.
This commit is contained in:
@@ -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