KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > drftpd > event > irc > Diskfree


1 /*
2  * This file is part of DrFTPD, Distributed FTP Daemon.
3  *
4  * DrFTPD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * DrFTPD is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with DrFTPD; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  */

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 /**
32  * @author zubov
33  * @version $Id: Diskfree.java,v 1.6 2004/05/12 00:45:04 mog Exp $
34  */

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 JavaDoc 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 JavaDoc 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