rendered paste bodyimport java.io.*;
import java.net.*;
class IRC
{
private Socket clientSocket;
private boolean isConnected; /* May be unneccesary. */
/* Communications Elements */
private PrintWriter out;
private BufferedReader in;
public IRC(String Server)
{
try {
clientSocket = new Socket(Server, 6667); /* Create socket object */
} catch(Exception e) {
System.out.println("Unknown Host or connection failed. Kyle should learn to code.");
}
try {
out = new PrintWriter(clientSocket.getOutputStream(), true);
in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
} catch (IOException e) {
System.out.println("IOException!");
}
}
/* Send initialization sequence */
public boolean Init(String Nick)
{
out.println("NICK " + Nick);
out.println("USER " + Nick + " 0 * :" + Nick);
return true;
}
/* Return a line from our BufferedReader */
public String readLine()
{
String thisLine = "";
try {
thisLine = in.readLine();
} catch(IOException e) { System.out.println("IOException while reading line"); return null; }
return thisLine;
}
/* parseLine() work in progress */
public String[] parseLine(String in)
{
String[] temp = in.split(" ", 4);
return temp;
}
public boolean close()
{
try
{
clientSocket.close();
} catch (IOException e)
{
return false;
}
return true;
}
}