Skip to content

anonymous /Bot.java
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
package ircbotgui;
import java.io.*;
import java.net.*;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* @author Malte Schuetze aka Boreeas
*/
public class BaseBot extends Thread {
public boolean noPass = true;
public String server, nick, password, lastReceived;
public int port = 0;
public String[] oper, voice, channels;
public int opIndex = 0, vIndex = 0, chanIndex = 0;
public BufferedReader reader;
public BufferedWriter writer;
public Socket socket;
private GUI gui = Instances.getGuiInstance();
public void connect(String server, int port, String nick, String pass) {
try {
socket = new Socket(server, port);
this.nick = nick;
this.password = pass;
this.noPass = false;
run();
} catch (UnknownHostException ex) {
} catch (IOException ex) {
Logger.getLogger(BaseBot.class.getName()).log(Level.SEVERE, null, ex);
}
}
public void connect(String server, int port, String nick, boolean noPass) {
try {
socket = new Socket(server, port);
this.nick = nick;
this.noPass = noPass;
run();
} catch (UnknownHostException ex) {
} catch (IOException ex) {
Logger.getLogger(BaseBot.class.getName()).log(Level.SEVERE, null, ex);
}
}
public void connect(String server, int port) {
try {
socket = new Socket(server, port);
run();
} catch (UnknownHostException ex) {
} catch (IOException ex) {
Logger.getLogger(BaseBot.class.getName()).log(Level.SEVERE, null, ex);
}
}
public void connect() {
try {
socket = new Socket(server, port);
run();
} catch (UnknownHostException ex) {
} catch (IOException ex) {
Logger.getLogger(BaseBot.class.getName()).log(Level.SEVERE, null, ex);
}
}
@Override
public void run() {
read();
}
public void read(){
try {
reader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
writer = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
while (true) {
String line;
if ((line = reader.readLine()) != null) {
System.out.println(line);
gui.appendRaw(line);
}
}
} catch (IOException e) {
gui.logError(e);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.