-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMain.java
59 lines (51 loc) · 1.97 KB
/
Main.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package org.perilouscodpiece.dicebot;
import java.io.*;
import java.util.*;
import org.jibble.pircbot.*;
public class Main {
public static void main(String[] args) {
// read configs
Properties props = new Properties();
try {
props.load(new FileInputStream("dicebot.properties"));
} catch (IOException ioe) {
System.err.println("Could not load dicebot.properties: " +
ioe.getMessage());
System.exit(1);
}
String server = props.getProperty("server");
if (server == null) {
System.err.println("Please set the 'server' property.");
System.exit(1);
}
String channel = props.getProperty("channel");
if (channel == null) {
System.err.println("Please set the 'channel' property.");
System.exit(1);
}
String adminPassword = props.getProperty("adminpassword");
if (adminPassword == null) {
System.err.println("Please set the 'adminpassword' property.");
System.exit(1);
}
String nick = props.getProperty("nick", "dicebot");
String antifloodthreshold = props.getProperty("antifloodthreshold", "30");
// instantiate dicebot
DiceBot bot = new DiceBot(nick, adminPassword);
bot.setVerbose(false);
bot.setAntiFloodThreshold(antifloodthreshold);
// connect
try {
bot.connect(server);
bot.joinChannel("#" + channel);
} catch (IOException ioe) {
System.err.println("Woah! Something exploded trying to connect to " + server + " or joining channel #" + channel + ":" + ioe.getMessage());
ioe.printStackTrace();
System.exit(1);
} catch (IrcException irce) {
System.err.println("IRC exception encountered: " + irce.getMessage());
irce.printStackTrace();
System.exit(1);
}
}
}