package ysitd.ircbot.java.plugin;

import ysitd.ircbot.java.api.*;

public class Main extends JIRCBOTPlugin implements JIRCBOTListener{
	
	static {
		JIRCBOTPlugin.registerAnmain(new Main());
	}
	
	@Override
	public void onEnable(){
		System.out.println("Plugin Enabled!");
		registerAnCommand(this);
		registerAnEvent(this);
	}
	@Override
	public void onDisable(){
		System.out.println("Plugin Disabled!");
	}
	@Override
	public String getName(){
		final String name="ping";
		return name;
	}
	@Override
	public boolean onCommand(String username , String prefix , String command , String[] argument){
		if(argument[0].equals("ping")){
			say("pong", getChannel());
		}
		return false;	
	}
	//感覺像是Override但實際上才不是呢 >_< XDD
	public void reciveEvent(reciveMessageEvent e){
		if(e.getALine().startsWith("PING")){
			getWriter().println("PONG " + e.getALine().substring(6));
			getWriter().flush();
		}
		else if( e.getSay().startsWith("ping") ){
			say( "pong" , getChannel() );
		}
		System.out.println(e.getALine());
	}
}

@@ -28,16 +28,69 @@
 lugin;%0A%0A
+import java.util.Timer;%0Aimport java.util.TimerTask;%0A%0A
 import y
@@ -113,16 +113,16 @@
 .api.*;%0A
-
 %0Apublic 
@@ -184,16 +184,38 @@
 ener%7B%0A%09%0A
+%09boolean reachPING;%0A%09%0A
 %09static 
@@ -838,16 +838,43 @@
 ent e)%7B%0A
+%09%09/*%0A%09%09 * %E6%AF%8F60%E7%A7%92PONG%E4%B8%80%E6%AC%A1%0A%09%09 */%0A
 %09%09if(e.g
@@ -905,95 +905,424 @@
 NG%22)
-)%7B%0A%09%09%09getWriter().println(%22PONG %22 + e.getALine().substring(6));%0A%09%09%09getWriter().flush();
+ && reachPING)%7B%0A%09%09%09final String pingIP=e.getALine().substring(6);%0A%09%09%09Thread timepong=new Thread(new Runnable()%7B%0A%09%09%09%09@Override%0A%09%09%09%09public void run()%7B%0A%09%09%09%09%09Timer permin=new Timer();%0A%09%09%09%09%09permin.schedule(new TimerTask()%7B%0A%09%09%09%09%09%09@Override%0A%09%09%09%09%09%09public void run() %7B%0A%09%09%09%09%09%09%09getWriter().println(%22PONG %22 + pingIP);%0A%09%09%09%09%09%09%09getWriter().flush();%0A%09%09%09%09%09%09%7D%0A%09%09%09%09%09%7D, 60);%0A%09%09%09%09%7D%0A%09%09%09%09%0A%09%09%09%7D);%0A%09%09%09timepong.start();%0A%09%09%09reachPING=true;%0A%09%09%09
 %0A%09%09%7D

add pong server per 60sec