forked from zifnab06/JavaBot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcore.java
More file actions
83 lines (80 loc) · 2.62 KB
/
core.java
File metadata and controls
83 lines (80 loc) · 2.62 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import java.net.Socket;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ArrayBlockingQueue;
import java.io.BufferedReader;
import java.io.PrintWriter;
import java.io.InputStreamReader;
import java.io.IOException;
class core {
public static void main(String args[]){
Socket s;
BlockingQueue<String> readQ;
BufferedReader in;
PrintWriter out;
String current;
try {
s = new Socket("irc.andirc.net", 6667);
in = new BufferedReader(new InputStreamReader(s.getInputStream()));
out = new PrintWriter(s.getOutputStream(), true);
System.out.println(in.readLine());
System.out.println(in.readLine());
System.out.println(in.readLine());
System.out.println(in.readLine());
out.println("USER Ewok krypton.zifnab06.net AndIRC :Doesn't Own Pants");
out.println("NICK Siri");
Thread.sleep(1000);
out.println("MODE siri -x");
out.println("JOIN #thunderbolt");
out.println("JOIN #gnexus");
Thread.sleep(1000);
out.println("JOIN #bionic");
out.println("JOIN #rezound");
Thread.sleep(1000);
out.println("JOIN #charge");
out.println("JOIN #hideout");
run(s,in,out);
} catch (Exception e){e.printStackTrace();}
}
public static void run(Socket s, BufferedReader in, PrintWriter out){
String current;
while (true) {
try {
current = in.readLine();
if (current == null) System.exit(0);
System.out.println(current);
switch(current.split(" ")[0]){
case "PING":
System.out.println("PONG sent");
out.println("PONG " + current.split(" ")[1]);
break;
default:
switch(current.split(" ")[1]){
//$nick PRIVMSG $channel :$msg
//$nick PRIVMSG $channel :Siri, command excess
case "PRIVMSG":
if(current.toLowerCase().split(" ")[3].contains("siri")){
switch(current.toLowerCase().split(" ")[4]){
case "google":
String searchTerms = "";
searchTerms = current.toLowerCase().split("google ")[1];
if(!searchTerms.equals(""))
out.println("PRIVMSG #" + current.toLowerCase().split("#")[1].split(" ")[0] + " :" + google.search(searchTerms)[1]);
break;
case "join":
out.println("JOIN " + current.toLowerCase().split("join ")[1]);
break;
case "source":
out.println("PRIVMSG #" + current.toLowerCase().split("#")[1].split(" ")[0] + " :http://github.com/zifnab06/JavaBot");
break;
}
}
break;
default:
break;
}
break;
}
} catch (Exception e){e.printStackTrace();}
}
}
}