mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-23 21:18:37 +01:00
TGS chat usage cleanup
- Rename send2tgs to sent2adminchat. - Move both chat procs to SSdiscord.dm. - Fix bug when sending to TGS4 non-admin chats. - Add DMdocs - Improve notify command - Store mentions as strings - Disable command if config setting isn't enabled
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user