diff options
author | snowleo <schneeleo@gmail.com> | 2011-10-12 03:14:07 +0200 |
---|---|---|
committer | snowleo <schneeleo@gmail.com> | 2011-10-12 03:14:26 +0200 |
commit | ea192ddd6d5b538e0bd0f6f1721890eb3c25de30 (patch) | |
tree | 344d5ad4eec389eedc6a72dbfb1bdfba1047a447 /EssentialsUpdate/src/f00f/net/irc/martyr/commands/TopicCommand.java | |
parent | 1b34ed40736b03f440352f8193f24b6b0525868a (diff) | |
download | Essentials-ea192ddd6d5b538e0bd0f6f1721890eb3c25de30.tar Essentials-ea192ddd6d5b538e0bd0f6f1721890eb3c25de30.tar.gz Essentials-ea192ddd6d5b538e0bd0f6f1721890eb3c25de30.tar.lz Essentials-ea192ddd6d5b538e0bd0f6f1721890eb3c25de30.tar.xz Essentials-ea192ddd6d5b538e0bd0f6f1721890eb3c25de30.zip |
EssentialsUpdate WIP
Diffstat (limited to 'EssentialsUpdate/src/f00f/net/irc/martyr/commands/TopicCommand.java')
-rw-r--r-- | EssentialsUpdate/src/f00f/net/irc/martyr/commands/TopicCommand.java | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/EssentialsUpdate/src/f00f/net/irc/martyr/commands/TopicCommand.java b/EssentialsUpdate/src/f00f/net/irc/martyr/commands/TopicCommand.java new file mode 100644 index 000000000..42e3d0421 --- /dev/null +++ b/EssentialsUpdate/src/f00f/net/irc/martyr/commands/TopicCommand.java @@ -0,0 +1,80 @@ +package f00f.net.irc.martyr.commands; + +import java.util.Date; + +import f00f.net.irc.martyr.CommandRegister; +import f00f.net.irc.martyr.InCommand; +import f00f.net.irc.martyr.clientstate.Channel; +import f00f.net.irc.martyr.clientstate.ClientState; + +public class TopicCommand extends AbstractCommand +{ + //static Logger log = Logger.getLogger(TopicCommand.class); + + private String channel; + private String topic; + + public static final String IDENTIFIER_PRIMARY = "TOPIC"; + public static final String IDENTIFIER_SECONDARY = "332"; + + public TopicCommand() + { + this( null, null ); + } + + public TopicCommand( String channel, String topic ) + { + this.channel = channel; + this.topic = topic; + } + + public String getIrcIdentifier() + { + // + // This command uses "TOPIC" on outgoing, so that is why we use + // "TOPIC" here instead of "332". + // + return IDENTIFIER_PRIMARY; + } + + public void selfRegister( CommandRegister commandRegister ) + { + commandRegister.addCommand( IDENTIFIER_PRIMARY, this ); + commandRegister.addCommand( IDENTIFIER_SECONDARY, this ); + } + + public InCommand parse( String prefix, String identifier, String params ) + { + // when the command is used as a reply, the nick is parameter 0. + if( identifier.equals( IDENTIFIER_SECONDARY ) ) + return new TopicCommand( getParameter(params, 1), getParameter(params, 2) ); + else + return new TopicCommand( getParameter(params, 0), getParameter(params, 1) ); + } + + public String renderParams() + { + return getChannel() + " :" + getTopic(); + } + + public String getTopic() + { + return topic; + } + + public String getChannel() + { + return channel; + } + + public boolean updateClientState( ClientState state ) + { + //log.debug("Topic: Channel: " + channel); + Channel chan = state.getChannel( channel ); + chan.setTopic( topic ); + chan.setTopicDate( new Date() ); + return true; + } + +} + |