diff --git a/code/_helpers/text.dm b/code/_helpers/text.dm index d4fa4a74bb..cc0eab059d 100644 --- a/code/_helpers/text.dm +++ b/code/_helpers/text.dm @@ -139,6 +139,10 @@ /proc/sanitize_old(var/t,var/list/repl_chars = list("\n"="#","\t"="#")) return html_encode(replace_characters(t,repl_chars)) +/proc/paranoid_sanitize(t) + var/regex/alphanum_only = regex("\[^a-zA-Z0-9# ,.?!:;()]", "g") + return alphanum_only.Replace(t, "#") + /* * Text searches */ diff --git a/code/modules/ext_scripts/irc.dm b/code/modules/ext_scripts/irc.dm index 4b125a9604..955f24400c 100644 --- a/code/modules/ext_scripts/irc.dm +++ b/code/modules/ext_scripts/irc.dm @@ -1,25 +1,10 @@ /proc/send2irc(var/channel, var/msg) - if (config.use_irc_bot) - if (config.use_node_bot) - shell("node bridge.js -h \"[config.irc_bot_host]\" -p \"[config.irc_bot_port]\" -c \"[channel]\" -m \"[msg]\"") - else - if (config.irc_bot_host) - if(config.irc_bot_export) - spawn(-1) // spawn here prevents hanging in the case that the bot isn't reachable - world.Export("http://[config.irc_bot_host]:45678?[list2params(list(pwd=config.comms_password, chan=channel, mesg=msg))]") - else - if(config.use_lib_nudge) - var/nudge_lib - if(world.system_type == MS_WINDOWS) - nudge_lib = "lib\\nudge.dll" - else - nudge_lib = "lib/nudge.so" - - spawn(0) - call(nudge_lib, "nudge")("[config.comms_password]","[config.irc_bot_host]","[channel]","[msg]") - else - spawn(0) - ext_python("ircbot_message.py", "[config.comms_password] [config.irc_bot_host] [channel] [msg]") + if(config.use_irc_bot && config.irc_bot_host) + for(var/IP in config.irc_bot_host) + spawn(0) + log_debug("send2irc: Sending [msg] to [channel]") + paranoid_sanitize(msg) + ext_python("ircbot_message.py", "[config.comms_password] [IP] [channel] [dbcon.Quote(msg)]") return /proc/send2mainirc(var/msg) @@ -28,12 +13,11 @@ return /proc/send2adminirc(var/msg) - if(config.admin_irc) - send2irc(config.admin_irc, msg) + var/queuedmsg = "ADMIN - [msg]" + + send2irc(config.admin_irc, queuedmsg) return - /hook/startup/proc/ircNotify() - send2mainirc("Server starting up on byond://[config.serverurl ? config.serverurl : (config.server ? config.server : "[world.address]:[world.port]")]") + send2mainirc("Server starting up on [config.server? "byond://[config.server]" : "byond://[world.address]:[world.port]"]") return 1 -