From a179ffd83d08f345681d81107af314cb900c1f48 Mon Sep 17 00:00:00 2001 From: void* Date: Thu, 3 Jan 2019 18:11:15 +0100 Subject: [PATCH] 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"