From 82114c4c1f2f03a082b5a3d450653df2839c069e Mon Sep 17 00:00:00 2001 From: Raeschen Date: Thu, 15 Feb 2024 21:00:18 +0100 Subject: [PATCH] Expand the fax --> discord with config settings (#7755) --- code/controllers/configuration_ch.dm | 41 ++++++++++++- config/example/config.txt | 22 +++++++ .../code/modules/paperwork/faxmachine.dm | 58 +++++++++++++++++-- 3 files changed, 116 insertions(+), 5 deletions(-) diff --git a/code/controllers/configuration_ch.dm b/code/controllers/configuration_ch.dm index 905d1c350f..f7f09f5f3c 100644 --- a/code/controllers/configuration_ch.dm +++ b/code/controllers/configuration_ch.dm @@ -11,7 +11,23 @@ var/nodebot_enabled = 0 //So, nodebot is a supplement to the TGS discord bot pretty much. For things likes faxes and the manifest it's very helpful because it's able to render html into an image and post it. var/nodebot_location //We need to print the manifest to this location so nodebot can render it to chat. //NOTE: TO BE REPLACED BY BETTER CODE FOR FETCHING MANIFEST - var/ahelp_channel_tag //This is for tgs4 channels, if you're not running on tgs4, this won't work anyways. If it's not set, it will default to the admin channel. + + //These are for tgs4 channels, for discord chatbots used in TGS. + var/ahelp_channel_tag + var/fax_channel_tag + var/role_request_channel_tag + + //These are for the role request TGS discord bot. Role IDs to ping. + var/role_request_id_command + var/role_request_id_security + var/role_request_id_engineering + var/role_request_id_medical + var/role_request_id_research + var/role_request_id_supply + var/role_request_id_service + var/role_request_id_expedition + var/role_request_id_silicon + var/discord_faxes_autoprint = 0 //Only turn this on if you're not using the nodebot. var/discord_faxes_disabled = 0 //Turn this off if you don't want the TGS bot sending you messages whenever a fax is sent to central. var/discord_ahelps_disabled = 0 //Turn this off if you don't want the TGS bot sending you messages whenever an ahelp ticket is created. @@ -64,6 +80,29 @@ config.nodebot_location = value if ("ahelp_channel_tag") config.ahelp_channel_tag = value + if ("fax_channel_tag") + config.fax_channel_tag = value + if ("role_request_channel_tag") + config.role_request_channel_tag = value + if ("role_request_id_command") + config.role_request_id_command = value + if ("role_request_id_security") + config.role_request_id_security = value + if ("role_request_id_engineering") + config.role_request_id_engineering = value + if ("role_request_id_medical") + config.role_request_id_medical = value + if ("role_request_id_research") + config.role_request_id_research = value + if ("role_request_id_supply") + config.role_request_id_supply = value + if ("role_request_id_service") + config.role_request_id_service = value + if ("role_request_id_expedition") + config.role_request_id_expedition = value + if ("role_request_id_silicon") + config.role_request_id_silicon = value + var/list/ip_whitelist_lines = file2list("config/ip_whitelist.txt") var/increment = 1 diff --git a/config/example/config.txt b/config/example/config.txt index 2c5785c6b3..c0f3584a7b 100644 --- a/config/example/config.txt +++ b/config/example/config.txt @@ -441,6 +441,28 @@ ITEMS_SURVIVE_DIGESTION # The secret API key to authenticate to the webhook. #CHAT_WEBHOOK_KEY some_password_here +# Nodebot settings +#NODEBOT_ENABLED +#NODEBOT_LOCATION /nodebot/ + +# TGS Discord bot settings and tags +#DISCORD_FAXES_AUTOPRINT +#DISCORD_AHELPS_ALL +#AHELP_CHANNEL_TAG ahelps +#FAX_CHANNEL_TAG fax +#ROLE_REQUEST_CHANNEL_TAG rolerequest + +# The discord role IDs for pinging roles using the role request function of the TGS chatbot +#ROLE_REQUEST_ID_COMMAND +#ROLE_REQUEST_ID_SECURITY +#ROLE_REQUEST_ID_ENGINEERING +#ROLE_REQUEST_ID_MEDICAL +#ROLE_REQUEST_ID_RESEARCH +#ROLE_REQUEST_ID_SUPPLY +#ROLE_REQUEST_ID_SERVICE +#ROLE_REQUEST_ID_EXPEDITION +#ROLE_REQUEST_ID_SILICON + # Path to the folder that BYOND should export faxes into so they are readable on the web. #FAX_EXPORT_DIR data/faxes diff --git a/modular_chomp/code/modules/paperwork/faxmachine.dm b/modular_chomp/code/modules/paperwork/faxmachine.dm index 26582de487..b27e233428 100644 --- a/modular_chomp/code/modules/paperwork/faxmachine.dm +++ b/modular_chomp/code/modules/paperwork/faxmachine.dm @@ -1,5 +1,8 @@ /proc/get_role_request_channel() - var/channel_tag = "rolerequest" + var/channel_tag + if(config.role_request_channel_tag) + channel_tag = config.role_request_channel_tag + var/datum/tgs_api/v5/api = TGS_READ_GLOBAL(tgs) if(istype(api) && channel_tag) for(var/datum/tgs_chat_channel/channel in api.chat_channels) @@ -15,7 +18,10 @@ world.TgsChatBroadcast(message,channel) /proc/get_fax_channel() - var/channel_tag = "fax" + var/channel_tag + if(config.fax_channel_tag) + channel_tag = config.fax_channel_tag + var/datum/tgs_api/v5/api = TGS_READ_GLOBAL(tgs) if(istype(api) && channel_tag) for(var/datum/tgs_chat_channel/channel in api.chat_channels) @@ -30,11 +36,55 @@ if(channel) world.TgsChatBroadcast(message,channel) +/proc/get_discord_role_id_from_department(var/department) + switch(department) + if("Command") + if(config.role_request_id_command) + return config.role_request_id_command + + if("Security") + if(config.role_request_id_security) + return config.role_request_id_security + + if("Engineering") + if(config.role_request_id_engineering) + return config.role_request_id_engineering + + if("Medical") + if(config.role_request_id_medical) + return config.role_request_id_medical + + if("Research") + if(config.role_request_id_research) + return config.role_request_id_research + + if("Supply") + if(config.role_request_id_supply) + return config.role_request_id_supply + + if("Service") + if(config.role_request_id_service) + return config.role_request_id_service + + if("Expedition") + if(config.role_request_id_expedition) + return config.role_request_id_expedition + + if("Silicon") + if(config.role_request_id_silicon) + return config.role_request_id_silicon + + return FALSE /obj/machinery/photocopier/faxmachine/message_chat_admins(var/mob/sender, var/faxname, var/obj/item/sent, var/faxid, font_colour="#006100") - fax_discord_message("A fax; '[faxname]' was sent.\nSender: [sender.name]\nFax name:\n[sent.name]\nFax ID: **[faxid]**") + fax_discord_message("A fax; '[faxname]' was sent.\nSender: [sender.name]\nFax name: [sent.name]\nFax ID: **[faxid]**") /obj/machinery/photocopier/faxmachine/message_chat_rolerequest(var/font_colour="#006100", var/role_to_ping, var/reason, var/jobname) - role_request_discord_message("An automated request for crew has been made.\nJob: [jobname]\nReason: [reason]\n\n@[role_to_ping]") \ No newline at end of file + var/roleid = get_discord_role_id_from_department(role_to_ping) + + if(roleid) + role_request_discord_message("An automated request for crew has been made.\nJob: [jobname]\nReason: [reason]\n\n<@&[roleid]>") + else + role_request_discord_message("An automated request for crew has been made.\nJob: [jobname]\nReason: [reason]") \ No newline at end of file