1 18 package net.sf.drftpd.event.irc; 19 20 import net.sf.drftpd.master.ConnectionManager; 21 import net.sf.drftpd.slave.SlaveStatus; 22 import net.sf.drftpd.util.ReplacerUtils; 23 24 import org.drftpd.plugins.SiteBot; 25 import org.tanesha.replacer.ReplacerEnvironment; 26 27 import f00f.net.irc.martyr.GenericCommandAutoService; 28 import f00f.net.irc.martyr.InCommand; 29 import f00f.net.irc.martyr.commands.MessageCommand; 30 31 35 36 public class Diskfree 37 extends GenericCommandAutoService 38 implements IRCPluginInterface { 39 40 private SiteBot _listener; 41 42 private ConnectionManager getConnectionManager() { 43 return _listener.getConnectionManager(); 44 } 45 46 public Diskfree(SiteBot listener) { 47 super(listener.getIRCConnection()); 48 _listener = listener; 49 } 50 51 public String getCommands() { 52 return "!df"; 53 } 54 55 protected void updateCommand(InCommand command) { 56 if (!(command instanceof MessageCommand)) 57 return; 58 MessageCommand msgc = (MessageCommand) command; 59 String msg = msgc.getMessage(); 60 if (msgc.isPrivateToUs(_listener.getIRCConnection().getClientState())) 61 return; 62 if (msg.equals("!df")) { 63 SlaveStatus status = 64 getConnectionManager().getSlaveManager().getAllStatus(); 65 ReplacerEnvironment env = 66 new ReplacerEnvironment(SiteBot.GLOBAL_ENV); 67 68 SiteBot.fillEnvSlaveStatus(env, status, _listener.getSlaveManager()); 69 _listener.sayChannel(msgc.getDest(), ReplacerUtils.jprintf("diskfree", env, SiteBot.class)); 70 } 71 } 72 } | Popular Tags |