Compare commits

...

2 Commits

Author SHA1 Message Date
Tristan B. Velloza Kildaire 2e94ecef69 Config
- Switched to array-based channels list

Config

- Use `channels` array instead of string

App

- Pass in `Config` to `Bot` constructor

Bot

- Constructor now takes in `Config` instance and then will extract the channels to join after authentication from said `Config` struct
2023-06-24 21:48:24 +02:00
Tristan B. Velloza Kildaire dd253b6292 Dub
- Upgraded to `jstruct` version `0.2.11`
2023-06-24 21:47:12 +02:00
5 changed files with 11 additions and 13 deletions

View File

@ -2,5 +2,5 @@
"serverAddr": "rany.irc.bnet.eu.org",
"serverPort": 6667,
"nickname": "bottyng",
"channels": "#bot,#tlang"
"channels": ["#bot", "#tlang"]
}

View File

@ -6,7 +6,7 @@
"dependencies": {
"birchwood": ">=2.0.1-beta.1",
"eskomcalendar4d": ">=0.1.3",
"jstruct": ">=0.1.3",
"jstruct": ">=0.2.11",
"lumars": ">=1.11.0"
},
"description": "IRC bot for the BonoboNET IRC network",

View File

@ -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();

View File

@ -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)

View File

@ -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)