From a179ffd83d08f345681d81107af314cb900c1f48 Mon Sep 17 00:00:00 2001 From: void* Date: Thu, 3 Jan 2019 18:11:15 +0100 Subject: [PATCH 1/6] Added Discord Bot functionality --- code/controllers/configuration.dm | 13 +++++++++++++ code/modules/ext_scripts/discord.dm | 6 ++++++ config/example/config.txt | 9 +++++++++ paradise.dme | 1 + 4 files changed, 29 insertions(+) create mode 100644 code/modules/ext_scripts/discord.dm diff --git a/code/controllers/configuration.dm b/code/controllers/configuration.dm index 17f8fcd3865..3b08a1d4be2 100644 --- a/code/controllers/configuration.dm +++ b/code/controllers/configuration.dm @@ -146,6 +146,10 @@ var/admin_notify_irc = "" var/cidrandomizer_irc = "" + var/use_discord_bot = 0 + var/discord_host = "" + var/discord_port = "" + var/default_laws = 0 //Controls what laws the AI spawns with. var/list/station_levels = list(1) // Defines which Z-levels the station exists on. @@ -460,6 +464,9 @@ if("use_irc_bot") use_irc_bot = 1 + if("use_discord_bot") + use_discord_bot = 1 + if("ticklag") Ticklag = text2num(value) @@ -518,6 +525,12 @@ if("cidrandomizer_irc") config.cidrandomizer_irc = value + if("discord_host") + config.discord_host = value + + if("discord_port") + config.discord_port = value + if("python_path") if(value) python_path = value diff --git a/code/modules/ext_scripts/discord.dm b/code/modules/ext_scripts/discord.dm new file mode 100644 index 00000000000..2a13ad16d79 --- /dev/null +++ b/code/modules/ext_scripts/discord.dm @@ -0,0 +1,6 @@ +/hook/startup/proc/discordNotify() + world << "trigger discordNotify()" + if (config.use_discord_bot && config.discord_host && config.discord_port) + world << "http://[config.discord_host]:[config.discord_port]/?command=startup&name=[station_name()]&connect=[world.address]:[world.port]" + world.Export("http://[config.discord_host]:[config.discord_port]/?command=startup&name=[station_name()]&connect=[world.address]:[world.port]") + return 1 \ No newline at end of file diff --git a/config/example/config.txt b/config/example/config.txt index 264cc52fc49..3708d55da73 100644 --- a/config/example/config.txt +++ b/config/example/config.txt @@ -273,6 +273,15 @@ GHOST_INTERACTION ## IRC channel to log CID randomizer blocker hits to. Leave blank to silence #CIDRANDOMIZER_IRC #cidrandomizer +## Uncomment to enable sending data to the Discord bot. +#USE_DISCORD_BOT + +## Host where the Discord bot is hosted. +#DISCORD_HOST 127.0.0.1 + +## Port where the Discord bot is listening. +#DISCORD_PORT 5001 + ## Path to the python2 executable on the system. Leave blank for default. ## Default is "python" on Windows, "/usr/bin/env python2" on UNIX. #PYTHON_PATH pythonw diff --git a/paradise.dme b/paradise.dme index f04d4909f96..eee28fa9a6e 100644 --- a/paradise.dme +++ b/paradise.dme @@ -1425,6 +1425,7 @@ #include "code\modules\examine\descriptions\structures.dm" #include "code\modules\examine\descriptions\turfs.dm" #include "code\modules\examine\descriptions\weapons.dm" +#include "code\modules\ext_scripts\discord.dm" #include "code\modules\ext_scripts\irc.dm" #include "code\modules\ext_scripts\python.dm" #include "code\modules\fancytitle\fancytitle.dm" From 7e32415b4bed8b6a7ad485fafe8cb0883430bfca Mon Sep 17 00:00:00 2001 From: void* Date: Thu, 3 Jan 2019 19:16:09 +0100 Subject: [PATCH 2/6] Removed world logs for discord notification on server startup --- code/modules/ext_scripts/discord.dm | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/code/modules/ext_scripts/discord.dm b/code/modules/ext_scripts/discord.dm index 2a13ad16d79..dca20b0e911 100644 --- a/code/modules/ext_scripts/discord.dm +++ b/code/modules/ext_scripts/discord.dm @@ -1,6 +1,4 @@ /hook/startup/proc/discordNotify() - world << "trigger discordNotify()" if (config.use_discord_bot && config.discord_host && config.discord_port) - world << "http://[config.discord_host]:[config.discord_port]/?command=startup&name=[station_name()]&connect=[world.address]:[world.port]" - world.Export("http://[config.discord_host]:[config.discord_port]/?command=startup&name=[station_name()]&connect=[world.address]:[world.port]") + world.Export("http://[config.discord_host]:[config.discord_port]/?command=startup&name=[station_name()]&connect=[config.server?"[config.server]":"[world.address]:[world.port]"]") return 1 \ No newline at end of file From 4ad407e9b91b7c84298a5ef42d0ca3d449eb6be3 Mon Sep 17 00:00:00 2001 From: void* Date: Thu, 3 Jan 2019 23:31:54 +0100 Subject: [PATCH 3/6] Added hook for roundend to notify the discord bot that round has ended (TODO: add more information to that round, example: survivors, ghost, game mode) --- code/modules/ext_scripts/discord.dm | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/code/modules/ext_scripts/discord.dm b/code/modules/ext_scripts/discord.dm index dca20b0e911..c365d5e9bd9 100644 --- a/code/modules/ext_scripts/discord.dm +++ b/code/modules/ext_scripts/discord.dm @@ -1,4 +1,9 @@ /hook/startup/proc/discordNotify() if (config.use_discord_bot && config.discord_host && config.discord_port) world.Export("http://[config.discord_host]:[config.discord_port]/?command=startup&name=[station_name()]&connect=[config.server?"[config.server]":"[world.address]:[world.port]"]") + return 1 + +/hook/roundend/proc/discordNotify() + if (config.use_discord_bot && config.discord_host && config.discord_port) + world.Export("http://[config.discord_host]:[config.discord_port]/?command=roundend") return 1 \ No newline at end of file From 8b8cfdaadbd7823f11b715c568ebd4a93bf92b21 Mon Sep 17 00:00:00 2001 From: void* Date: Sun, 6 Jan 2019 18:00:28 +0100 Subject: [PATCH 4/6] Reworked discord interface to replace the IRC one completely --- code/_onclick/ai.dm | 4 ++-- code/controllers/configuration.dm | 20 +++++++++++----- code/game/gamemodes/game_mode.dm | 2 +- code/game/gamemodes/gameticker.dm | 2 +- code/modules/admin/DB ban/functions.dm | 2 +- code/modules/admin/verbs/adminhelp.dm | 12 +++++----- code/modules/admin/verbs/adminpm.dm | 2 +- code/modules/client/client procs.dm | 6 ++--- code/modules/ext_scripts/discord.dm | 23 +++++++++++++------ code/modules/ext_scripts/irc.dm | 21 ----------------- code/modules/mob/logout.dm | 2 +- code/modules/power/supermatter/supermatter.dm | 2 +- code/modules/shuttle/emergency.dm | 2 +- config/example/config.txt | 12 +++++++--- paradise.dme | 1 - 15 files changed, 57 insertions(+), 56 deletions(-) delete mode 100644 code/modules/ext_scripts/irc.dm diff --git a/code/_onclick/ai.dm b/code/_onclick/ai.dm index c84a64722c5..237d391ac41 100644 --- a/code/_onclick/ai.dm +++ b/code/_onclick/ai.dm @@ -52,7 +52,7 @@ message_admins("[key_name_admin(src)] might be running a modified client! (failed can_see on AI click of [A]([ADMIN_COORDJMP(pixel_turf)]))") var/message = "[key_name(src)] might be running a modified client! (failed can_see on AI click of [A]([COORD(pixel_turf)]))" log_admin(message) - send2irc_adminless_only("NOCHEAT", "[key_name(src)] might be running a modified client! (failed checkTurfVis on AI click of [A]([COORD(pixel_turf)]))") + send2discord_adminless_only(config.discord_channel_admin, "[key_name(src)] might be running a modified client! (failed checkTurfVis on AI click of [A]([COORD(pixel_turf)]))") var/turf_visible @@ -65,7 +65,7 @@ if(pixel_turf.obscured) log_admin("[key_name_admin(src)] might be running a modified client! (failed checkTurfVis on AI click of [A]([COORD(pixel_turf)])") message_admins("[key_name_admin(src)] might be running a modified client! (failed checkTurfVis on AI click of [A]([ADMIN_COORDJMP(pixel_turf)]))") - send2irc_adminless_only("NOCHEAT", "[key_name(src)] might be running a modified client! (failed checkTurfVis on AI click of [A]([COORD(pixel_turf)]))") + send2discord_adminless_only(config.discord_channel_admin, "[key_name(src)] might be running a modified client! (failed checkTurfVis on AI click of [A]([COORD(pixel_turf)]))") return var/list/modifiers = params2list(params) diff --git a/code/controllers/configuration.dm b/code/controllers/configuration.dm index 3b08a1d4be2..d11603f82da 100644 --- a/code/controllers/configuration.dm +++ b/code/controllers/configuration.dm @@ -148,7 +148,9 @@ var/use_discord_bot = 0 var/discord_host = "" - var/discord_port = "" + var/discord_channel_main = "" + var/discord_channel_admin = "" + var/discord_channel_cidrandomizer = "" var/default_laws = 0 //Controls what laws the AI spawns with. @@ -464,9 +466,6 @@ if("use_irc_bot") use_irc_bot = 1 - if("use_discord_bot") - use_discord_bot = 1 - if("ticklag") Ticklag = text2num(value) @@ -525,11 +524,20 @@ if("cidrandomizer_irc") config.cidrandomizer_irc = value + if("use_discord_bot") + use_discord_bot = 1 + if("discord_host") config.discord_host = value - if("discord_port") - config.discord_port = value + if("discord_channel_main") + config.discord_channel_main = value + + if("discord_channel_admin") + config.discord_channel_admin = value + + if("discord_channel_cidrandomizer") + config.discord_channel_cidrandomizer = value if("python_path") if(value) diff --git a/code/game/gamemodes/game_mode.dm b/code/game/gamemodes/game_mode.dm index 08ab2b54c5d..1681e37a978 100644 --- a/code/game/gamemodes/game_mode.dm +++ b/code/game/gamemodes/game_mode.dm @@ -244,7 +244,7 @@ if(escaped_on_pod_5 > 0) feedback_set("escaped_on_pod_5",escaped_on_pod_5) - send2mainirc("A round of [src.name] has ended - [surviving_total] survivors, [ghosts] ghosts.") + send2maindiscord("A round of [src.name] has ended - [surviving_total] survivors, [ghosts] ghosts.") return 0 diff --git a/code/game/gamemodes/gameticker.dm b/code/game/gamemodes/gameticker.dm index 21abbc89415..cb5da26f0cd 100644 --- a/code/game/gamemodes/gameticker.dm +++ b/code/game/gamemodes/gameticker.dm @@ -219,7 +219,7 @@ var/round_start_time = 0 var/list/admins_number = staff_countup(R_BAN) if(admins_number[1] == 0 && admins_number[3] == 0) - send2irc(config.admin_notify_irc, "Round has started with no admins online.") + send2discord("message", config.discord_channel_admin, "Round has started with no admins online.") auto_toggle_ooc(0) // Turn it off round_start_time = world.time diff --git a/code/modules/admin/DB ban/functions.dm b/code/modules/admin/DB ban/functions.dm index dd46725ff26..188e95087d1 100644 --- a/code/modules/admin/DB ban/functions.dm +++ b/code/modules/admin/DB ban/functions.dm @@ -137,7 +137,7 @@ datum/admins/proc/DB_ban_record(var/bantype, var/mob/banned_mob, var/duration = message_admins("[key_name_admin(usr)] has added a [bantype_str] for [ckey] [(job)?"([job])":""] [(duration > 0)?"([duration] minutes)":""] with the reason: \"[reason]\" to the ban database.",1) if(announceinirc) - send2irc("BAN ALERT","[a_ckey] applied a [bantype_str] on [ckey]") + send2discord("message", config.discord_channel_admin,"BAN ALERT","[a_ckey] applied a [bantype_str] on [ckey]") if(kickbannedckey) if(banned_mob && banned_mob.client && banned_mob.client.ckey == banckey) diff --git a/code/modules/admin/verbs/adminhelp.dm b/code/modules/admin/verbs/adminhelp.dm index e0baebfc775..f43dd59d79c 100644 --- a/code/modules/admin/verbs/adminhelp.dm +++ b/code/modules/admin/verbs/adminhelp.dm @@ -136,15 +136,15 @@ var/list/adminhelp_ignored_words = list("unknown","the","a","an","of","monkey"," log_admin("[selected_type]: [key_name(src)]: [original_msg] - heard by [admin_number_present] non-AFK admins.") if(admin_number_present <= 0) if(!admin_number_afk) - send2adminirc("[selected_type] from [key_name(src)]: [original_msg] - !!No admins online!!") + send2admindiscord("[selected_type] from [key_name(src)]: [original_msg] - !!No admins online!!") else - send2adminirc("[selected_type] from [key_name(src)]: [original_msg] - !!All admins AFK ([admin_number_afk])!!") + send2admindiscord("[selected_type] from [key_name(src)]: [original_msg] - !!All admins AFK ([admin_number_afk])!!") else - send2adminirc("[selected_type] from [key_name(src)]: [original_msg]") + send2admindiscord("[selected_type] from [key_name(src)]: [original_msg]") feedback_add_details("admin_verb","AH") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc! return -/proc/send2irc_adminless_only(source, msg, requiredflags = R_BAN) +/proc/send2discord_adminless_only(source, msg, requiredflags = R_BAN) var/admin_number_total = 0 //Total number of admins var/admin_number_afk = 0 //Holds the number of admins who are afk var/admin_number_ignored = 0 //Holds the number of admins without +BAN (so admins who are not really admins) @@ -166,7 +166,7 @@ var/list/adminhelp_ignored_words = list("unknown","the","a","an","of","monkey"," var/admin_number_present = admin_number_total - admin_number_decrease //Number of admins who are neither afk nor invalid if(admin_number_present <= 0) if(!admin_number_afk && !admin_number_ignored) - send2irc(source, "[msg] - No admins online") + send2discord("message", source, "[msg] - No admins online") else - send2irc(source, "[msg] - All admins AFK ([admin_number_afk]/[admin_number_total]) or skipped ([admin_number_ignored]/[admin_number_total])") + send2discord("message", source, "[msg] - All admins AFK ([admin_number_afk]/[admin_number_total]) or skipped ([admin_number_ignored]/[admin_number_total])") return admin_number_present diff --git a/code/modules/admin/verbs/adminpm.dm b/code/modules/admin/verbs/adminpm.dm index 5303480e905..28835675ede 100644 --- a/code/modules/admin/verbs/adminpm.dm +++ b/code/modules/admin/verbs/adminpm.dm @@ -218,7 +218,7 @@ to_chat(src, "[msg]") return - send2adminirc("PlayerPM from [key_name(src)]: [html_decode(msg)]") + send2admindiscord("PlayerPM from [key_name(src)]: [html_decode(msg)]") to_chat(src, "IRC PM to-IRC-Admins: [msg]") diff --git a/code/modules/client/client procs.dm b/code/modules/client/client procs.dm index 50176f96c5e..2fe2c8e0863 100644 --- a/code/modules/client/client procs.dm +++ b/code/modules/client/client procs.dm @@ -471,7 +471,7 @@ var/watchreason = check_watchlist(ckey) if(watchreason) message_admins("Notice: [key_name_admin(src)] is on the watchlist and has just connected - Reason: [watchreason]") - send2irc(config.admin_notify_irc, "Watchlist - [key_name(src)] is on the watchlist and has just connected - Reason: [watchreason]") + send2discord("message", config.discord_channel_admin, "Watchlist - [key_name(src)] is on the watchlist and has just connected - Reason: [watchreason]") //Just the standard check to see if it's actually a number @@ -570,7 +570,7 @@ if(!cidcheck_failedckeys[ckey]) message_admins("[key_name(src)] has been detected as using a CID randomizer. Connection rejected.") - send2irc(config.cidrandomizer_irc, "[key_name(src)] has been detected as using a CID randomizer. Connection rejected.") + send2discord("message", config.discord_channel_cidrandomizer, "[key_name(src)] has been detected as using a CID randomizer. Connection rejected.") cidcheck_failedckeys[ckey] = TRUE note_randomizer_user() @@ -583,7 +583,7 @@ if(cidcheck_failedckeys[ckey]) // Atonement message_admins("[key_name_admin(src)] has been allowed to connect after showing they removed their cid randomizer") - send2irc(config.cidrandomizer_irc, "[key_name(src)] has been allowed to connect after showing they removed their cid randomizer.") + send2discord("message", config.discord_channel_cidrandomizer, "[key_name(src)] has been allowed to connect after showing they removed their cid randomizer.") cidcheck_failedckeys -= ckey if (cidcheck_spoofckeys[ckey]) message_admins("[key_name_admin(src)] has been allowed to connect after appearing to have attempted to spoof a cid randomizer check because it appears they aren't spoofing one this time") diff --git a/code/modules/ext_scripts/discord.dm b/code/modules/ext_scripts/discord.dm index c365d5e9bd9..f21158e506d 100644 --- a/code/modules/ext_scripts/discord.dm +++ b/code/modules/ext_scripts/discord.dm @@ -1,9 +1,18 @@ -/hook/startup/proc/discordNotify() - if (config.use_discord_bot && config.discord_host && config.discord_port) - world.Export("http://[config.discord_host]:[config.discord_port]/?command=startup&name=[station_name()]&connect=[config.server?"[config.server]":"[world.address]:[world.port]"]") - return 1 +/proc/send2discord(var/command, var/channel, var/message) + if (config.use_discord_bot && config.discord_host) + world.Export("http://[config.discord_host]/?command=[command]&channel=[channel]&message=[paranoid_sanitize(message)]") -/hook/roundend/proc/discordNotify() - if (config.use_discord_bot && config.discord_host && config.discord_port) - world.Export("http://[config.discord_host]:[config.discord_port]/?command=roundend") +/proc/send2maindiscord(var/message) + if(config.discord_channel_main) + send2discord("message", config.discord_channel_main, message) + return + +/proc/send2admindiscord(var/message) + if(config.discord_channel_admin) + send2discord("message", config.discord_channel_admin, message) + return + +/hook/startup/proc/discordNotify() + if(config.discord_channel_main) + send2discord("startup", config.discord_channel_main, "Server starting up on [station_name()]. Connect to: [config.server? "[config.server]" : "[world.address]:[world.port]"]") return 1 \ No newline at end of file diff --git a/code/modules/ext_scripts/irc.dm b/code/modules/ext_scripts/irc.dm deleted file mode 100644 index 3cc29ff39fb..00000000000 --- a/code/modules/ext_scripts/irc.dm +++ /dev/null @@ -1,21 +0,0 @@ -/proc/send2irc(var/channel, var/msg) - if(config.use_irc_bot && config.irc_bot_host.len) - for(var/IP in config.irc_bot_host) - spawn(0) - // I have no means of trusting you, cmd - ext_python("ircbot_message.py", "[config.comms_password] [IP] [channel] [paranoid_sanitize(msg)]") - return - -/proc/send2mainirc(var/msg) - if(config.main_irc) - send2irc(config.main_irc, msg) - return - -/proc/send2adminirc(var/msg) - if(config.admin_irc) - send2irc(config.admin_irc, msg) - return - -/hook/startup/proc/ircNotify() - send2mainirc("Server starting up on [station_name()]. Connect to: [config.server? "[config.server]" : "[world.address]:[world.port]"]") - return 1 diff --git a/code/modules/mob/logout.dm b/code/modules/mob/logout.dm index 762607bd501..a2f491743a1 100644 --- a/code/modules/mob/logout.dm +++ b/code/modules/mob/logout.dm @@ -13,7 +13,7 @@ message_admins("Admin logout: [key_name_admin(src)]") var/list/admincounter = staff_countup(R_BAN) if(admincounter[1] == 0) // No active admins - send2irc(config.admin_notify_irc, "[key_name(src)] logged out - No active admins, [admincounter[2]] non-admin staff, [admincounter[3]] inactive staff.") + send2admindiscord("[key_name(src)] logged out - No active admins, [admincounter[2]] non-admin staff, [admincounter[3]] inactive staff.") ..() diff --git a/code/modules/power/supermatter/supermatter.dm b/code/modules/power/supermatter/supermatter.dm index dfb8da3811d..349abff0032 100644 --- a/code/modules/power/supermatter/supermatter.dm +++ b/code/modules/power/supermatter/supermatter.dm @@ -126,7 +126,7 @@ if(!current_state) log_and_message_admins(message) if(send_to_irc) - send2adminirc(message) + send2admindiscord(message) return TRUE else return FALSE diff --git a/code/modules/shuttle/emergency.dm b/code/modules/shuttle/emergency.dm index 80760e1cb50..b864678be87 100644 --- a/code/modules/shuttle/emergency.dm +++ b/code/modules/shuttle/emergency.dm @@ -233,7 +233,7 @@ return mode = SHUTTLE_DOCKED timer = world.time - send2irc("Server", "The Emergency Shuttle has docked with the station.") + send2maindiscord("The Emergency Shuttle has docked with the station.") emergency_shuttle_docked.Announce("The Emergency Shuttle has docked with the station. You have [timeLeft(600)] minutes to board the Emergency Shuttle.") /* diff --git a/config/example/config.txt b/config/example/config.txt index 3708d55da73..ba896f5448f 100644 --- a/config/example/config.txt +++ b/config/example/config.txt @@ -277,10 +277,16 @@ GHOST_INTERACTION #USE_DISCORD_BOT ## Host where the Discord bot is hosted. -#DISCORD_HOST 127.0.0.1 +#DISCORD_HOST 127.0.0.1:5001 -## Port where the Discord bot is listening. -#DISCORD_PORT 5001 +## Channel ID where the Bot should post its main notifications +#DISCORD_CHANNEL_MAIN 0123456789 + +## Channel ID where the Bot should post its admin notifications +#DISCORD_CHANNEL_ADMIN 0123456789 + +## Channel ID where the bot should post its cidrandomizer notifications +#DISCORD_CHANNEL_CIDRANDOMIZER 0123456789 ## Path to the python2 executable on the system. Leave blank for default. ## Default is "python" on Windows, "/usr/bin/env python2" on UNIX. diff --git a/paradise.dme b/paradise.dme index eee28fa9a6e..1aa7da35139 100644 --- a/paradise.dme +++ b/paradise.dme @@ -1426,7 +1426,6 @@ #include "code\modules\examine\descriptions\turfs.dm" #include "code\modules\examine\descriptions\weapons.dm" #include "code\modules\ext_scripts\discord.dm" -#include "code\modules\ext_scripts\irc.dm" #include "code\modules\ext_scripts\python.dm" #include "code\modules\fancytitle\fancytitle.dm" #include "code\modules\fish\fish_eggs.dm" From 40cd42da85c0c22d0d038a9a19f12932b24e5aea Mon Sep 17 00:00:00 2001 From: void* Date: Sun, 6 Jan 2019 18:03:30 +0100 Subject: [PATCH 5/6] Removed last remaining of irc script --- scripts/ircbot_message.py | 31 ------------------------------- 1 file changed, 31 deletions(-) delete mode 100644 scripts/ircbot_message.py diff --git a/scripts/ircbot_message.py b/scripts/ircbot_message.py deleted file mode 100644 index 4339019e03d..00000000000 --- a/scripts/ircbot_message.py +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env python2 - -# Four arguments, password host channel and message. -# EG: "ircbot_message.py hunter2 example.com #adminchannel ADMINHELP, people are killing me!" - -import sys,cPickle,socket,HTMLParser - -def pack(): - ht = HTMLParser.HTMLParser() - - passwd = sys.argv[1] - ip = sys.argv[3] - try: - data = [] - for in_data in sys.argv[4:]: #The rest of the arguments is data - data += {ht.unescape(in_data)} - except: - data = "NO DATA SPECIFIED" - dictionary = {"ip":ip,"data":[passwd] + data} - pickled = cPickle.dumps(dictionary) - nudge(pickled) -def nudge(data): - HOST = sys.argv[2] - PORT = 45678 - s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - s.connect((HOST,PORT)) - s.send(data) - s.close() - -if __name__ == "__main__" and len(sys.argv) > 1: # If not imported and more than one argument - pack() From ee20733f747169e5ef13aa29c1a8591e44097749 Mon Sep 17 00:00:00 2001 From: void* Date: Mon, 7 Jan 2019 01:40:00 +0100 Subject: [PATCH 6/6] made all changes wanted for PR --- code/controllers/configuration.dm | 33 ++++++----------------------- code/game/gamemodes/gameticker.dm | 2 +- code/modules/ext_scripts/discord.dm | 6 +++--- config/example/config.txt | 25 +++++----------------- 4 files changed, 15 insertions(+), 51 deletions(-) diff --git a/code/controllers/configuration.dm b/code/controllers/configuration.dm index d11603f82da..86ecd93dba2 100644 --- a/code/controllers/configuration.dm +++ b/code/controllers/configuration.dm @@ -139,17 +139,11 @@ var/comms_password = "" - var/use_irc_bot = 0 - var/list/irc_bot_host = list() - var/main_irc = "" - var/admin_irc = "" - var/admin_notify_irc = "" - var/cidrandomizer_irc = "" - - var/use_discord_bot = 0 + var/use_discord_bot = FALSE var/discord_host = "" var/discord_channel_main = "" var/discord_channel_admin = "" + var/discord_channel_admin_notify = "" var/discord_channel_cidrandomizer = "" var/default_laws = 0 //Controls what laws the AI spawns with. @@ -463,9 +457,6 @@ if("allow_holidays") config.allow_holidays = 1 - if("use_irc_bot") - use_irc_bot = 1 - if("ticklag") Ticklag = text2num(value) @@ -509,23 +500,8 @@ if("comms_password") config.comms_password = value - if("irc_bot_host") - config.irc_bot_host = splittext(value, ";") - - if("main_irc") - config.main_irc = value - - if("admin_irc") - config.admin_irc = value - - if("admin_notify_irc") - config.admin_notify_irc = value - - if("cidrandomizer_irc") - config.cidrandomizer_irc = value - if("use_discord_bot") - use_discord_bot = 1 + use_discord_bot = TRUE if("discord_host") config.discord_host = value @@ -536,6 +512,9 @@ if("discord_channel_admin") config.discord_channel_admin = value + if("discord_channel_admin_notify") + config.discord_channel_admin_notify = value + if("discord_channel_cidrandomizer") config.discord_channel_cidrandomizer = value diff --git a/code/game/gamemodes/gameticker.dm b/code/game/gamemodes/gameticker.dm index cb5da26f0cd..e62a2a33f87 100644 --- a/code/game/gamemodes/gameticker.dm +++ b/code/game/gamemodes/gameticker.dm @@ -219,7 +219,7 @@ var/round_start_time = 0 var/list/admins_number = staff_countup(R_BAN) if(admins_number[1] == 0 && admins_number[3] == 0) - send2discord("message", config.discord_channel_admin, "Round has started with no admins online.") + send2discord("message", config.discord_channel_admin_notify, "Round has started with no admins online.") auto_toggle_ooc(0) // Turn it off round_start_time = world.time diff --git a/code/modules/ext_scripts/discord.dm b/code/modules/ext_scripts/discord.dm index f21158e506d..a68954776de 100644 --- a/code/modules/ext_scripts/discord.dm +++ b/code/modules/ext_scripts/discord.dm @@ -1,13 +1,13 @@ -/proc/send2discord(var/command, var/channel, var/message) +/proc/send2discord(command, channel, message) if (config.use_discord_bot && config.discord_host) world.Export("http://[config.discord_host]/?command=[command]&channel=[channel]&message=[paranoid_sanitize(message)]") -/proc/send2maindiscord(var/message) +/proc/send2maindiscord(message) if(config.discord_channel_main) send2discord("message", config.discord_channel_main, message) return -/proc/send2admindiscord(var/message) +/proc/send2admindiscord(message) if(config.discord_channel_admin) send2discord("message", config.discord_channel_admin, message) return diff --git a/config/example/config.txt b/config/example/config.txt index ba896f5448f..1eed03b2b4b 100644 --- a/config/example/config.txt +++ b/config/example/config.txt @@ -252,27 +252,9 @@ ALIEN_PLAYER_RATIO 0.2 ##Remove the # to let ghosts spin chairs GHOST_INTERACTION -## Password used for authorizing ircbot and other external tools. +## Password used for authorizing external tools. #COMMS_PASSWORD -## Uncomment to enable sending data to the IRC bot. -#USE_IRC_BOT - -## Host(s) where the IRC bot is hosted. Seperate IP's by ;. Port 45678 needs to be open. -#IRC_BOT_HOST 127.0.0.1;localhost - -## IRC channel to send information to. Leave blank to disable. -#MAIN_IRC #main - -## IRC channel to send adminhelps to. Leave blank to disable adminhelps-to-irc. -#ADMIN_IRC #admin - -## IRC channel to send direct messages to admins to. Leave blank to disable. -#ADMIN_NOTIFY_IRC #paradiseStaff - -## IRC channel to log CID randomizer blocker hits to. Leave blank to silence -#CIDRANDOMIZER_IRC #cidrandomizer - ## Uncomment to enable sending data to the Discord bot. #USE_DISCORD_BOT @@ -282,9 +264,12 @@ GHOST_INTERACTION ## Channel ID where the Bot should post its main notifications #DISCORD_CHANNEL_MAIN 0123456789 -## Channel ID where the Bot should post its admin notifications +## Channel ID where the Bot should post its admin messages #DISCORD_CHANNEL_ADMIN 0123456789 +## Channel ID where the Bot should post its admin notifications +#DISCORD_CHANNEL_ADMIN_NOTIFY 0123456789 + ## Channel ID where the bot should post its cidrandomizer notifications #DISCORD_CHANNEL_CIDRANDOMIZER 0123456789