package bot;

import java.io.IOException;
import java.io.PrintStream;
import java.net.Socket;
import java.util.Scanner;

public class Server {
	
	// Fields
	public Scanner in;
	public PrintStream out;
	private Socket socket;
	
	
	public void connectTo(String address, int port){
		if(socket != null){
			try {
				socket.close();
				
			} 
			catch (IOException e) {
				e.printStackTrace();
			}
		}
		try{
			socket = new Socket(address, port);
			in = new Scanner(socket.getInputStream());
			out = new PrintStream(socket.getOutputStream());
		}
		catch(Exception e){
			e.printStackTrace();
		}
	}
	
	public void send(String s){
		out.println(s + "\r\n");
		out.flush();
	}
	
	public void pm(String target, String message){
		send(String.format("PRIVMSG %s :%s", target, message));
	}
	
	public void notice(String target, String message){
		send(String.format("NOTICE %s :%s", target, message));
	}
}

@@ -218,18 +218,48 @@
 socket;%0A
+%09private boolean isConnected;%0A
 %09%0A
-
 %09%0A%09publi
@@ -569,16 +569,39 @@
 eam());%0A
+%09%09%09isConnected = true;%0A
 %09%09%7D%0A%09%09ca
@@ -680,16 +680,54 @@
 ing s)%7B%0A
+%09%09System.out.println(%22sending %22 + s);%0A
 %09%09out.pr
@@ -920,32 +920,32 @@
 tring message)%7B%0A
-
 %09%09send(String.fo
@@ -988,10 +988,66 @@
 e));%0A%09%7D%0A
+%09public boolean isConnected()%7B%0A%09%09return isConnected;%0A%09%7D%0A
 %7D%0A

add an isConnected debugging method