cac.java

来自「this is a sample of a java bot. use to e」· Java 代码 · 共 63 行

JAVA
63
字号
class CAC extends Thread {

	private IRCSocket ircSocket;
	private CommandInterpreter commandInterpreter;

	private String[] controllers;

	public CAC(IRCSocket ircSocket) {
		this.ircSocket = ircSocket;
		this.controllers = this.ircSocket.getConfig().getControllers();
	}

	public void run() {
		this.commandInterpreter = new CommandInterpreter(this);
		Debug.print("Command interpreter instantiated... \n");
		while(true) {
			this.process();
			try {
				this.sleep(30000);
			} catch(InterruptedException ie) {
			}
		}
	}

	public void process() {
		this.ircSocket.init();
		Debug.print("IRC socket initiated... \n");
		while(this.ircSocket.connected()) {
			try {
				String line = this.ircSocket.getIRC().readLine();
				if(line == null) {
					continue;
				} else if(line != null & !line.equals("null")) {
					Debug.print("SERVER: " + line + "\n");
					if(line.startsWith("PING ")) {
						this.ircSocket.getIRC().sendRaw(line.replace("PING", "PONG"));
					} else if(line.indexOf(":Closing Link:") > 0 && line.indexOf(this.ircSocket.getNick()) > 0) {
						this.ircSocket.disconnect();
						break;
					} else {
						this.commandInterpreter.line(line);
					}
				}
				this.sleep(10);
			} catch(InterruptedException ie) {
			}
		}
	}

	public IRCSocket getIRCSocket() {
		return this.ircSocket;
	}

	public boolean isController(String nick) {
		for(int i = 0; i < this.controllers.length; i++) {
			if(controllers[i].equals(nick)) {
				return true;
			}
		}
		return false;
	}

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?