001: /*
002: * This file is part of DrFTPD, Distributed FTP Daemon.
003: *
004: * DrFTPD is free software; you can redistribute it and/or modify
005: * it under the terms of the GNU General Public License as published by
006: * the Free Software Foundation; either version 2 of the License, or
007: * (at your option) any later version.
008: *
009: * DrFTPD is distributed in the hope that it will be useful,
010: * but WITHOUT ANY WARRANTY; without even the implied warranty of
011: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
012: * GNU General Public License for more details.
013: *
014: * You should have received a copy of the GNU General Public License
015: * along with DrFTPD; if not, write to the Free Software
016: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
017: */
018: package org.drftpd.sitebot;
019:
020: import org.drftpd.plugins.SiteBot;
021: import org.drftpd.usermanager.User;
022:
023: import f00f.net.irc.martyr.GenericAutoService;
024: import f00f.net.irc.martyr.IRCConnection;
025: import f00f.net.irc.martyr.InCommand;
026: import f00f.net.irc.martyr.State;
027: import f00f.net.irc.martyr.commands.JoinCommand;
028: import f00f.net.irc.martyr.commands.RawCommand;
029: import f00f.net.irc.martyr.commands.WelcomeCommand;
030: import f00f.net.irc.martyr.errors.ChannelBannedError;
031: import f00f.net.irc.martyr.errors.ChannelInviteOnlyError;
032: import f00f.net.irc.martyr.errors.ChannelLimitError;
033: import f00f.net.irc.martyr.errors.ChannelWrongKeyError;
034:
035: /**
036: * @author mog
037: * @version $Id: OnConnect.java 1513 2006-10-13 22:41:08Z tdsoul $
038: */
039: public class OnConnect extends GenericAutoService {
040: private State _state;
041:
042: public OnConnect(SiteBot sitebot) {
043: super (sitebot.getIRCConnection());
044:
045: IRCConnection connection = sitebot.getIRCConnection();
046:
047: updateState(connection.getState());
048: _state = connection.getState();
049: }
050:
051: protected void updateState(State state) {
052: }
053:
054: protected void updateCommand(InCommand command) {
055: if ((command.getState() != _state)
056: && (command.getState() == State.REGISTERED)
057: && command instanceof WelcomeCommand) {
058: onConnect((WelcomeCommand) command);
059: }
060:
061: _state = command.getState();
062:
063: if (command instanceof JoinCommand) {
064: onJoin((JoinCommand) command);
065: } else if (command instanceof ChannelInviteOnlyError) {
066: needInvite((ChannelInviteOnlyError) command);
067: } else if (command instanceof ChannelWrongKeyError) {
068: needKey((ChannelWrongKeyError) command);
069: } else if (command instanceof ChannelBannedError) {
070: needUnban((ChannelBannedError) command);
071: } else if (command instanceof ChannelLimitError) {
072: needLimit((ChannelLimitError) command);
073: }
074:
075: //TODO need-op?
076: }
077:
078: private void onJoin(JoinCommand command) {
079: }
080:
081: private void needLimit(ChannelLimitError error) {
082: }
083:
084: private void needUnban(ChannelBannedError error) {
085: }
086:
087: private void needKey(ChannelWrongKeyError error) {
088: }
089:
090: private void needInvite(ChannelInviteOnlyError error) {
091: }
092:
093: private void onConnect(WelcomeCommand command) {
094: getConnection().sendCommand(
095: new RawCommand("MODE " + command.getNick() + " :+i"));
096: }
097:
098: public String getCommands() {
099: return null;
100: }
101:
102: public String getCommandsHelp(User user) {
103: return "";
104: }
105:
106: }
|