Skip to content
This repository was archived by the owner on Jan 19, 2018. It is now read-only.

Commit 2d69cb6

Browse files
committed
Made the configuration include the trigger
I have made the trigger configurable as well
1 parent 60ad7c9 commit 2d69cb6

File tree

5 files changed

+11
-6
lines changed

5 files changed

+11
-6
lines changed

src/main/java/uk/co/unitycoders/pircbotx/Bot.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ public class Bot
4242
{
4343
public static void main(String[] args) throws Exception
4444
{
45-
CommandProcessor processor = new CommandProcessor('&');
45+
// Bot Configuration
46+
Configuration config = ConfigurationManager.loadJsonConfig();
47+
48+
CommandProcessor processor = new CommandProcessor(config.trigger);
4649

4750
ProfileManager profiles = new ProfileManager(DBConnection.getProfileModel());
4851
DateTimeCommand dtCmd = new DateTimeCommand();
@@ -72,9 +75,6 @@ public static void main(String[] args) throws Exception
7275
bot.setAutoReconnect(true);
7376
bot.setAutoReconnectChannels(true);
7477

75-
// Bot Configuration
76-
Configuration config = ConfigurationManager.loadJsonConfig();
77-
7878
try
7979
{
8080
bot.setName(config.nick);

src/main/java/uk/co/unitycoders/pircbotx/Configuration.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,5 @@ public class Configuration {
3030
public int port;
3131
public Boolean ssl;
3232
public String[] channels;
33+
public char trigger;
3334
}

src/main/java/uk/co/unitycoders/pircbotx/ConfigurationManager.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public class ConfigurationManager {
4141
public static final String DEFAULT_PORT = "6697";
4242
public static final String DEFAULT_SSL = "true";
4343
public static final String DEFAULT_CHANS = "#unity-coders";
44+
public static final String DEFAULT_TRIGGER = "&";
4445

4546
private static Reader getFileReader(String file) throws IOException {
4647
return new FileReader(file);
@@ -57,6 +58,7 @@ public static Configuration loadConfig() throws IOException {
5758
config.port = Integer.parseInt(properties.getProperty("port", DEFAULT_PORT));
5859
config.nick = properties.getProperty("nick", DEFAULT_BOT_NAME);
5960
config.ssl = Boolean.parseBoolean(properties.getProperty("ssl", DEFAULT_SSL));
61+
config.trigger = properties.getProperty("trigger", DEFAULT_TRIGGER).charAt(0);
6062

6163
//work out what channels to connect to
6264
String channelStr = properties.getProperty("channels",DEFAULT_CHANS);

src/main/resources/uc_pircbotx.json.example

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
{
2-
"nick": "uc_pircbotx",
2+
"nick": "uc_pircbotx2",
33
"host": "irc.freenode.net",
44
"port": 6697,
55
"ssl": true,
6+
"trigger": "&",
67
"channels": [
78
"#unity-coders",
89
"#unity-coders-bots"

src/main/resources/uc_pircbotx.properties.example

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ host = irc.freenode.net
88
port = 6697
99
ssl = true
1010

11-
# Channel settings
11+
# Bot settings
12+
trigger = &
1213
channels = #unity-coders,#unity-coders-bots

0 commit comments

Comments
 (0)