mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2025-12-21 15:42:35 +00:00
This implements UDP Logging with GELF. It will allow full text search over all the logs and attributes sent over GELF to the log server.
71 lines
2.2 KiB
Plaintext
71 lines
2.2 KiB
Plaintext
var/global/ntnrc_uid = 0
|
|
|
|
/datum/ntnet_conversation/
|
|
var/id = null
|
|
var/title = "Untitled Conversation"
|
|
var/datum/computer_file/program/chatclient/operator // "Administrator" of this channel. Creator starts as channel's operator,
|
|
var/list/messages = list()
|
|
var/list/clients = list()
|
|
var/password
|
|
|
|
/datum/ntnet_conversation/New()
|
|
id = ntnrc_uid
|
|
ntnrc_uid++
|
|
if(ntnet_global)
|
|
ntnet_global.chat_channels.Add(src)
|
|
..()
|
|
|
|
/datum/ntnet_conversation/proc/add_message(var/message, var/username, var/mob/user)
|
|
log_ntirc("[user.client.ckey]/([username]) : [message]",ckey=key_name(user),conversation=title)
|
|
|
|
message = "[worldtime2text()] [username]: [message]"
|
|
messages.Add(message)
|
|
trim_message_list()
|
|
|
|
/datum/ntnet_conversation/proc/add_status_message(var/message)
|
|
messages.Add("[worldtime2text()] -!- [message]")
|
|
trim_message_list()
|
|
|
|
/datum/ntnet_conversation/proc/trim_message_list()
|
|
if(messages.len <= 50)
|
|
return
|
|
for(var/message in messages)
|
|
messages -= message
|
|
if(messages.len <= 50)
|
|
return
|
|
|
|
/datum/ntnet_conversation/proc/add_client(var/datum/computer_file/program/chatclient/C)
|
|
if(!istype(C))
|
|
return
|
|
clients.Add(C)
|
|
add_status_message("[C.username] has joined the channel.")
|
|
// No operator, so we assume the channel was empty. Assign this user as operator.
|
|
if(!operator)
|
|
changeop(C)
|
|
|
|
/datum/ntnet_conversation/proc/remove_client(var/datum/computer_file/program/chatclient/C)
|
|
if(!istype(C) || !(C in clients))
|
|
return
|
|
clients.Remove(C)
|
|
add_status_message("[C.username] has left the channel.")
|
|
|
|
// Channel operator left, pick new operator
|
|
if(C == operator)
|
|
operator = null
|
|
if(clients.len)
|
|
var/datum/computer_file/program/chatclient/newop = pick(clients)
|
|
changeop(newop)
|
|
|
|
|
|
/datum/ntnet_conversation/proc/changeop(var/datum/computer_file/program/chatclient/newop)
|
|
if(istype(newop))
|
|
operator = newop
|
|
add_status_message("Channel operator status transferred to [newop.username].")
|
|
|
|
/datum/ntnet_conversation/proc/change_title(var/newtitle, var/datum/computer_file/program/chatclient/client)
|
|
if(operator != client)
|
|
return 0 // Not Authorised
|
|
|
|
add_status_message("[client.username] has changed channel title from [title] to [newtitle]")
|
|
title = newtitle
|