1 18 package org.drftpd.plugins; 19 20 import net.sf.drftpd.event.irc.IRCPluginInterface; 21 import f00f.net.irc.martyr.GenericAutoService; 22 import f00f.net.irc.martyr.IRCConnection; 23 import f00f.net.irc.martyr.InCommand; 24 import f00f.net.irc.martyr.State; 25 import f00f.net.irc.martyr.commands.JoinCommand; 26 import f00f.net.irc.martyr.commands.RawCommand; 27 import f00f.net.irc.martyr.commands.WelcomeCommand; 28 import f00f.net.irc.martyr.errors.ChannelBannedError; 29 import f00f.net.irc.martyr.errors.ChannelInviteOnlyError; 30 import f00f.net.irc.martyr.errors.ChannelLimitError; 31 import f00f.net.irc.martyr.errors.ChannelWrongKeyError; 32 33 37 public class OnConnect extends GenericAutoService implements IRCPluginInterface { 38 private State _state; 39 40 public OnConnect(SiteBot sitebot) { 41 super(sitebot.getIRCConnection()); 42 IRCConnection connection = sitebot.getIRCConnection(); 43 44 updateState( connection.getState() ); 45 _state = connection.getState(); 46 } 47 48 protected void updateState(State state) {} 49 50 protected void updateCommand(InCommand command) { 51 if(command.getState() != _state && command.getState() == State.REGISTERED && command instanceof WelcomeCommand) { 52 onConnect((WelcomeCommand)command); 53 } 54 _state = command.getState(); 55 56 if(command instanceof JoinCommand) { 57 onJoin((JoinCommand)command); 58 } 59 else if(command instanceof ChannelInviteOnlyError) { 60 needInvite((ChannelInviteOnlyError)command); 61 } 62 else if(command instanceof ChannelWrongKeyError) { 63 needKey((ChannelWrongKeyError)command); 64 } 65 else if(command instanceof ChannelBannedError) { 66 needUnban((ChannelBannedError)command); 67 } 68 else if(command instanceof ChannelLimitError) { 69 needLimit((ChannelLimitError)command); 70 } 71 } 73 74 private void onJoin(JoinCommand command) { 75 } 76 77 private void needLimit(ChannelLimitError error) { 78 } 79 80 private void needUnban(ChannelBannedError error) { 81 } 82 83 private void needKey(ChannelWrongKeyError error) { 84 } 85 86 private void needInvite(ChannelInviteOnlyError error) { 87 } 88 89 private void onConnect(WelcomeCommand command) { 90 getConnection().sendCommand(new RawCommand("MODE "+command.getNick()+" :+i")); 91 } 92 93 public String getCommands() { 94 return null; 95 } 96 } 97 | Popular Tags |