diff --git a/code/__HELPERS/roundend.dm b/code/__HELPERS/roundend.dm index 121acf332ff..48eddc22266 100644 --- a/code/__HELPERS/roundend.dm +++ b/code/__HELPERS/roundend.dm @@ -239,7 +239,7 @@ //Set news report and mode result mode.set_round_result() - send2tgs("Server", "Round just ended.") + send2adminchat("Server", "Round just ended.") if(length(CONFIG_GET(keyed_list/cross_server))) send_news_report() diff --git a/code/__HELPERS/unsorted.dm b/code/__HELPERS/unsorted.dm index f9a13a575a0..1d0708a4674 100644 --- a/code/__HELPERS/unsorted.dm +++ b/code/__HELPERS/unsorted.dm @@ -1518,28 +1518,6 @@ GLOBAL_DATUM_INIT(dview_mob, /mob/dview, new) for(var/i in 1 to items_list[each_item]) new each_item(where_to) -//sends a message to chat -//config_setting should be one of the following -//null - noop -//empty string - use TgsTargetBroadcast with admin_only = FALSE -//other string - use TgsChatBroadcast with the tag that matches config_setting, only works with TGS4, if using TGS3 the above method is used -/proc/send2chat(message, config_setting) - if(config_setting == null || !world.TgsAvailable()) - return - - var/datum/tgs_version/version = world.TgsVersion() - if(config_setting == "" || version.suite == 3) - world.TgsTargetedChatBroadcast(message, FALSE) - return - - var/list/channels_to_use = list() - for(var/I in world.TgsChatChannelInfo()) - var/datum/tgs_chat_channel/channel = I - if(channel.tag == config_setting) - channels_to_use += channel - - if(channels_to_use.len) - world.TgsChatBroadcast() /proc/num2sign(numeric) if(numeric > 0) diff --git a/code/controllers/subsystem/discord.dm b/code/controllers/subsystem/discord.dm index 87f8a761355..a605f2a60f2 100644 --- a/code/controllers/subsystem/discord.dm +++ b/code/controllers/subsystem/discord.dm @@ -56,12 +56,9 @@ SUBSYSTEM_DEF(discord) people_to_notify = json_decode(file2text(notify_file)) catch pass() // The list can just stay as its default (blank). Pass() exists because it needs a catch - var/notifymsg = "" - for(var/id in people_to_notify) - // I would use jointext here, but I dont think you can two-side glue with it, and I would have to strip characters otherwise - notifymsg += "<@[id]> " // 22 charaters per notify, 90 notifies per message, so I am not making a failsafe because 90 people arent going to notify at once + var/notifymsg = jointext(people_to_notify, ", ") if(notifymsg) - send2chat("[notifymsg]", CONFIG_GET(string/chat_announce_new_game)) // Sends the message to the discord, using same config option as the roundstart notification + send2chat(trim(notifymsg), CONFIG_GET(string/chat_announce_new_game)) // Sends the message to the discord, using same config option as the roundstart notification fdel(notify_file) // Deletes the file return ..() @@ -136,3 +133,38 @@ SUBSYSTEM_DEF(discord) var/datum/http_response/res = req.into_response() WRITE_LOG(GLOB.discord_api_log, "PUT [url] returned [res.status_code] [res.body]") + +/** + * Sends a message to TGS chat channels. + * + * message - The message to send. + * channel_tag - Required. If "", the message with be sent to all connected (Game-type for TGS3) channels. Otherwise, it will be sent to TGS4 channels with that tag. + */ +/proc/send2chat(message, channel_tag) + if(channel_tag == null || !world.TgsAvailable()) + return + + var/datum/tgs_version/version = world.TgsVersion() + if(channel_tag == "" || version.suite == 3) + world.TgsTargetedChatBroadcast(message, FALSE) + return + + var/list/channels_to_use = list() + for(var/I in world.TgsChatChannelInfo()) + var/datum/tgs_chat_channel/channel = I + if(channel.tag == channel_tag) + channels_to_use += channel + + if(channels_to_use.len) + world.TgsChatBroadcast(message, channels_to_use) + +/** + * Sends a message to TGS admin chat channels. + * + * category - The category of the mssage. + * message - The message to send. + */ +/proc/send2adminchat(category, message) + category = replacetext(replacetext(category, "\proper", ""), "\improper", "") + message = replacetext(replacetext(message, "\proper", ""), "\improper", "") + world.TgsTargetedChatBroadcast("[category] | [message]", TRUE) diff --git a/code/controllers/subsystem/ticker.dm b/code/controllers/subsystem/ticker.dm index 56f89abdcb9..80f870af075 100755 --- a/code/controllers/subsystem/ticker.dm +++ b/code/controllers/subsystem/ticker.dm @@ -312,7 +312,7 @@ SUBSYSTEM_DEF(ticker) var/list/adm = get_admin_counts() var/list/allmins = adm["present"] - send2tgs("Server", "Round [GLOB.round_id ? "#[GLOB.round_id]:" : "of"] [hide_mode ? "secret":"[mode.name]"] has started[allmins.len ? ".":" with no active admins online!"]") + send2adminchat("Server", "Round [GLOB.round_id ? "#[GLOB.round_id]:" : "of"] [hide_mode ? "secret":"[mode.name]"] has started[allmins.len ? ".":" with no active admins online!"]") setup_done = TRUE for(var/i in GLOB.start_landmarks_list) diff --git a/code/modules/admin/sql_ban_system.dm b/code/modules/admin/sql_ban_system.dm index 733e8f06ebc..2f4c825bfdd 100644 --- a/code/modules/admin/sql_ban_system.dm +++ b/code/modules/admin/sql_ban_system.dm @@ -490,7 +490,7 @@ log_admin_private("[kn] [msg][roles_to_ban[1] == "Server" ? "" : " Roles: [roles_to_ban.Join(", ")]"] Reason: [reason]") message_admins("[kna] [msg][roles_to_ban[1] == "Server" ? "" : " Roles: [roles_to_ban.Join("\n")]"]\nReason: [reason]") if(applies_to_admins) - send2tgs("BAN ALERT","[kn] [msg]") + send2adminchat("BAN ALERT","[kn] [msg]") if(player_ckey) create_message("note", player_ckey, admin_ckey, note_reason, null, null, 0, 0, null, 0, severity) var/client/C = GLOB.directory[player_ckey] @@ -727,7 +727,7 @@ log_admin_private("[kn] has edited the [changes_keys_text] of a ban for [old_key ? "[old_key]" : "[old_ip]-[old_cid]"].") //if a ban doesn't have a key it must have an ip and/or a cid to have reached this point normally message_admins("[kna] has edited the [changes_keys_text] of a ban for [old_key ? "[old_key]" : "[old_ip]-[old_cid]"].") if(changes["Applies to admins"]) - send2tgs("BAN ALERT","[kn] has edited a ban for [old_key ? "[old_key]" : "[old_ip]-[old_cid]"] to [applies_to_admins ? "" : "not"]affect admins") + send2adminchat("BAN ALERT","[kn] has edited a ban for [old_key ? "[old_key]" : "[old_ip]-[old_cid]"] to [applies_to_admins ? "" : "not"]affect admins") var/client/C = GLOB.directory[old_key] if(C) build_ban_cache(C) diff --git a/code/modules/admin/verbs/adminhelp.dm b/code/modules/admin/verbs/adminhelp.dm index e3584566443..72e2bd31ffc 100644 --- a/code/modules/admin/verbs/adminhelp.dm +++ b/code/modules/admin/verbs/adminhelp.dm @@ -214,7 +214,7 @@ GLOBAL_DATUM_INIT(ahelp_tickets, /datum/admin_help_tickets, new) /datum/admin_help/proc/AddInteraction(formatted_message) if(heard_by_no_admins && usr && usr.ckey != initiator_ckey) heard_by_no_admins = FALSE - send2tgs(initiator_ckey, "Ticket #[id]: Answered by [key_name(usr)]") + send2adminchat(initiator_ckey, "Ticket #[id]: Answered by [key_name(usr)]") _interactions += "[time_stamp()]: [formatted_message]" //Removes the ahelp verb and returns it after 2 minutes @@ -576,15 +576,9 @@ GLOBAL_DATUM_INIT(ahelp_tickets, /datum/admin_help_tickets, new) final = "[msg] - No admins online" else final = "[msg] - All admins stealthed\[[english_list(stealthmins)]\], AFK\[[english_list(afkmins)]\], or lacks +BAN\[[english_list(powerlessmins)]\]! Total: [allmins.len] " - send2tgs(source,final) + send2adminchat(source,final) send2otherserver(source,final) - -/proc/send2tgs(msg,msg2) - msg = replacetext(replacetext(msg, "\proper", ""), "\improper", "") - msg2 = replacetext(replacetext(msg2, "\proper", ""), "\improper", "") - world.TgsTargetedChatBroadcast("[msg] | [msg2]", TRUE) - // /proc/send2otherserver(source,msg,type = "Ahelp",target_servers) var/comms_key = CONFIG_GET(string/comms_key) diff --git a/code/modules/admin/verbs/adminpm.dm b/code/modules/admin/verbs/adminpm.dm index 62afb826c90..64cbdc2a05e 100644 --- a/code/modules/admin/verbs/adminpm.dm +++ b/code/modules/admin/verbs/adminpm.dm @@ -147,7 +147,7 @@ to_chat(src, "PM to-Admins: [rawmsg]", confidential = TRUE) var/datum/admin_help/AH = admin_ticket_log(src, "Reply PM from-[key_name(src, TRUE, TRUE)] to External: [keywordparsedmsg]") externalreplyamount-- - send2tgs("[AH ? "#[AH.id] " : ""]Reply: [ckey]", rawmsg) + send2adminchat("[AH ? "#[AH.id] " : ""]Reply: [ckey]", rawmsg) else if(recipient.holder) if(holder) //both are admins diff --git a/code/modules/client/client_procs.dm b/code/modules/client/client_procs.dm index b21a91ff759..cc6c1f9a5fe 100644 --- a/code/modules/client/client_procs.dm +++ b/code/modules/client/client_procs.dm @@ -486,7 +486,7 @@ GLOBAL_LIST_EMPTY(external_rsc_urls) "Forever alone :("\ ) - send2tgs("Server", "[cheesy_message] (No admins online)") + send2adminchat("Server", "[cheesy_message] (No admins online)") QDEL_LIST_ASSOC_VAL(char_render_holders) if(movingmob != null) movingmob.client_mobs_in_contents -= mob diff --git a/code/modules/discord/tgs_commands.dm b/code/modules/discord/tgs_commands.dm index e2a0e8263f4..cb876b473ff 100644 --- a/code/modules/discord/tgs_commands.dm +++ b/code/modules/discord/tgs_commands.dm @@ -4,13 +4,16 @@ help_text = "Pings the invoker when the round ends" /datum/tgs_chat_command/notify/Run(datum/tgs_chat_user/sender, params) + if(!CONFIG_GET(string/chat_announce_new_game)) + return "Notifcations are currently disabled" + for(var/member in SSdiscord.notify_members) // If they are in the list, take them out - if(member == "[sender.mention]") - SSdiscord.notify_members -= "[SSdiscord.id_clean(sender.mention)]" // The list uses strings because BYOND cannot handle a 17 digit integer + if(member == sender.mention) + SSdiscord.notify_members -= sender.mention return "You will no longer be notified when the server restarts" // If we got here, they arent in the list. Chuck 'em in! - SSdiscord.notify_members += "[SSdiscord.id_clean(sender.mention)]" // The list uses strings because BYOND cannot handle a 17 digit integer + SSdiscord.notify_members += sender.mention return "You will now be notified when the server restarts" // Verify @@ -40,4 +43,4 @@ /datum/tgs_chat_command/myuserid/Run(datum/tgs_chat_user/sender, params) var/discordid = SSdiscord.id_clean(sender.mention) return "<@[discordid]> Your Discord UserID is [discordid]" - + diff --git a/code/modules/shuttle/emergency.dm b/code/modules/shuttle/emergency.dm index 648f0bf4b71..465f90a70e9 100644 --- a/code/modules/shuttle/emergency.dm +++ b/code/modules/shuttle/emergency.dm @@ -315,7 +315,7 @@ return mode = SHUTTLE_DOCKED setTimer(SSshuttle.emergencyDockTime) - send2tgs("Server", "The Emergency Shuttle has docked with the station.") + send2adminchat("Server", "The Emergency Shuttle has docked with the station.") priority_announce("[SSshuttle.emergency] has docked with the station. You have [timeLeft(600)] minutes to board the Emergency Shuttle.", null, 'sound/ai/shuttledock.ogg', "Priority") ShuttleDBStuff()