-
Notifications
You must be signed in to change notification settings - Fork 1
/
MyBotMain.java
65 lines (48 loc) · 1.48 KB
/
MyBotMain.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
60
61
62
63
64
65
import org.jibble.pircbot.*;
import java.io.*;
public class MyBotMain {
public static void main(String[] args) throws Exception {
// Now start our bot up.
MyBot bot = new MyBot();
// Enable debugging output.
bot.setVerbose(false);
// Connect to the IRC server.
bot.connect("irc.freenode.net");
String password = new String();
try {
BufferedReader reader = new BufferedReader(new FileReader("password.txt"));
password = reader.readLine();
reader.close();
}
catch (Exception e) {
}
//Identify to NickServ
bot.identify(password);
try {
BufferedReader reader = new BufferedReader(new FileReader("channels.txt"));
//this is the header
String line = reader.readLine();
String[] header = line.split(";");
int numChannels = Integer.parseInt(header[1]);
for (int i = 0; i < numChannels; i++) {
line = reader.readLine();
String[] pieces = line.split(";");
Channel channel = new Channel(pieces[0].replace(";",""),Boolean.parseBoolean(pieces[1]));
bot.joinChannel(channel);
bot.channelList.add(channel);
waiting (10);
}
reader.close();
}
catch (Exception e) {
}
}
public static void waiting (int n){
long t0, t1;
t0 = System.currentTimeMillis();
do{
t1 = System.currentTimeMillis();
}
while ((t1 - t0) < (n * 1000));
}
}