Bot refresh - Light cleanup of bot code, allows the bot to ping a role when rebooting (#4085)

This commit is contained in:
deathride58
2022-05-20 12:36:22 -07:00
committed by GitHub
parent 08d78f7887
commit f2c73b43eb
6 changed files with 83 additions and 2 deletions
+61
View File
@@ -0,0 +1,61 @@
/*
Here's how to use the chat system with configs
send2adminchat is a simple function that broadcasts to admin channels
send2chat is a bit verbose but can be very specific
The second parameter is a string, this string should be read from a config.
What this does is dictacte which TGS4 channels can be sent to.
For example if you have the following channels in tgs4 set up
- Channel 1, Tag: asdf
- Channel 2, Tag: bombay,asdf
- Channel 3, Tag: Hello my name is asdf
- Channel 4, No Tag
- Channel 5, Tag: butts
and you make the call:
send2chat("I sniff butts", CONFIG_GET(string/where_to_send_sniff_butts))
and the config option is set like:
WHERE_TO_SEND_SNIFF_BUTTS asdf
It will be sent to channels 1 and 2
Alternatively if you set the config option to just:
WHERE_TO_SEND_SNIFF_BUTTS
it will be sent to all connected chats.
In TGS3 it will always be sent to all connected designated game chats.
*/
/**
* 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 (Delimited by ','s).
*/
/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
var/list/applicable_tags = splittext(channel.custom_tag, ",")
if(channel_tag in applicable_tags)
channels_to_use += channel
if(channels_to_use.len)
world.TgsChatBroadcast(message, channels_to_use)
+1 -1
View File
@@ -1560,7 +1560,7 @@ GLOBAL_DATUM_INIT(dview_mob, /mob/dview, new)
//Sender is optional
/proc/admin_chat_message(var/message = "Debug Message", var/color = "#FFFFFF", var/sender)
if(message) //Adds TGS3 integration to those fancy verbose round event messages
world.TgsTargetedChatBroadcast(message, TRUE)
send2irc("Event", message)
if (!config_legacy.chat_webhook_url || !message)
return
spawn(0)
@@ -0,0 +1,3 @@
/datum/config_entry/string/chat_reboot_role
/datum/config_entry/string/chat_roundend_notice_tag
+5 -1
View File
@@ -462,7 +462,11 @@ SUBSYSTEM_DEF(ticker)
blackbox.save_all_data_to_sql()
send2irc("Server", "A round of [mode.name] just ended.")
world.TgsTargetedChatBroadcast("The round has ended.", FALSE)
if(CONFIG_GET(string/chat_roundend_notice_tag))
var/broadcastmessage = "The round has ended."
if(CONFIG_GET(string/chat_reboot_role))
broadcastmessage += "\n\n<@&[CONFIG_GET(string/chat_reboot_role)]>, the server will reboot shortly!"
send2chat(broadcastmessage, CONFIG_GET(string/chat_roundend_notice_tag))
SSpersistence.SavePersistence()
ready_for_reboot = TRUE
+11
View File
@@ -0,0 +1,11 @@
## Chat Announce Options
## Various messages to be sent to game chats
## Uncommenting these will enable them, by default they will be broadcast to Game chat channels on TGS3 or non-admin channels on TGS4
## If using TGS4, the string option can be set as a chat channel tag to limit the message to channels of that tag type (case-sensitive)
## i.e. CHAT_ANNOUNCE_NEW_GAME chat_channel_tag
## Announcements for when the round ends, pending server reboot.
#CHAT_ROUNDEND_NOTICE_TAG
## Role ID that, when present, will be pinged every round end.
#CHAT_REBOOT_ROLE
+2
View File
@@ -185,6 +185,7 @@
#include "code\__HELPERS\_logging.dm"
#include "code\__HELPERS\areas.dm"
#include "code\__HELPERS\atom_movables.dm"
#include "code\__HELPERS\chat.dm"
#include "code\__HELPERS\events.dm"
#include "code\__HELPERS\files.dm"
#include "code\__HELPERS\filters.dm"
@@ -314,6 +315,7 @@
#include "code\controllers\verbs.dm"
#include "code\controllers\configuration\config_entry.dm"
#include "code\controllers\configuration\configuration.dm"
#include "code\controllers\configuration\entries\bot.dm"
#include "code\controllers\configuration\entries\comms.dm"
#include "code\controllers\configuration\entries\dbconfig.dm"
#include "code\controllers\configuration\entries\fail2topic.dm"