diff --git a/config.json b/config.json index 2ca5cb0..963f9fb 100644 --- a/config.json +++ b/config.json @@ -2,5 +2,5 @@ "serverAddr": "rany.irc.bnet.eu.org", "serverPort": 6667, "nickname": "bottyng", - "channels": "#bot,#tlang" + "channels": ["#bot", "#tlang"] } diff --git a/source/botty/app.d b/source/botty/app.d index 2c6be1d..74c5f3f 100644 --- a/source/botty/app.d +++ b/source/botty/app.d @@ -37,11 +37,9 @@ void main(string[] args) // // Set the fakelag to 1 second // connInfo.setFakeLag(1); - - // Extract the channels to connect to - string[] channels = split(config.channels, ","); - Bot botty = new Bot(connInfo, channels); + + Bot botty = new Bot(connInfo, config); // Start the bot botty.start(); diff --git a/source/botty/bot.d b/source/botty/bot.d index a53c194..79c6700 100644 --- a/source/botty/bot.d +++ b/source/botty/bot.d @@ -5,17 +5,17 @@ import lumars; import std.conv : to; import core.thread : Thread, dur; import botty.mod : Mod; - +import botty.config : Config; public class Bot : Client { - private string[] channels; + private Config config; private Mod[] modules; - this(ConnectionInfo info, string[] channels) + this(ConnectionInfo info, Config config) { super(info); - this.channels = channels; + this.config = config; // TODO: testing addTestModules addTestModules(); @@ -51,7 +51,7 @@ public class Bot : Client Thread.sleep(dur!("seconds")(2)); // Join channels requested - joinChannel(channels); + joinChannel(config.channels); } public override void onChannelMessage(Message fullMessage, string channel, string msgBody) diff --git a/source/botty/config.d b/source/botty/config.d index d525caa..a95a2e3 100644 --- a/source/botty/config.d +++ b/source/botty/config.d @@ -21,9 +21,9 @@ public struct Config string nickname; /** - * Channels to join (in CSV format (for now)) + * Channels to join */ - string channels; + string[] channels; } public Config getConfig(string configPath)