diff options
author | snowleo <schneeleo@gmail.com> | 2011-10-12 05:00:36 +0200 |
---|---|---|
committer | snowleo <schneeleo@gmail.com> | 2011-10-12 05:00:36 +0200 |
commit | d187c58f30b2ec2a1a1fa50208f7724a69f78390 (patch) | |
tree | 7340c417f82803f23869667fc1562ef9f61095d6 /EssentialsUpdate/src/f00f/net/irc/martyr/services/AutoResponder.java | |
parent | ea192ddd6d5b538e0bd0f6f1721890eb3c25de30 (diff) | |
download | Essentials-d187c58f30b2ec2a1a1fa50208f7724a69f78390.tar Essentials-d187c58f30b2ec2a1a1fa50208f7724a69f78390.tar.gz Essentials-d187c58f30b2ec2a1a1fa50208f7724a69f78390.tar.lz Essentials-d187c58f30b2ec2a1a1fa50208f7724a69f78390.tar.xz Essentials-d187c58f30b2ec2a1a1fa50208f7724a69f78390.zip |
Replacing martyr with Pircbot 1.5
Diffstat (limited to 'EssentialsUpdate/src/f00f/net/irc/martyr/services/AutoResponder.java')
-rw-r--r-- | EssentialsUpdate/src/f00f/net/irc/martyr/services/AutoResponder.java | 82 |
1 files changed, 0 insertions, 82 deletions
diff --git a/EssentialsUpdate/src/f00f/net/irc/martyr/services/AutoResponder.java b/EssentialsUpdate/src/f00f/net/irc/martyr/services/AutoResponder.java deleted file mode 100644 index 08f3a7f29..000000000 --- a/EssentialsUpdate/src/f00f/net/irc/martyr/services/AutoResponder.java +++ /dev/null @@ -1,82 +0,0 @@ -package f00f.net.irc.martyr.services; - -import java.util.Observable; -import java.util.Observer; - -import f00f.net.irc.martyr.IRCConnection; -import f00f.net.irc.martyr.commands.ChannelModeCommand; -import f00f.net.irc.martyr.commands.JoinCommand; -import f00f.net.irc.martyr.commands.PingCommand; -import f00f.net.irc.martyr.commands.PongCommand; - -/** - * AutoResponder is where commands that should be auto-responded (such - * as PING-PONG) should go. - */ -public class AutoResponder implements Observer -{ - - private IRCConnection connection; - private boolean enabled = false; - - public AutoResponder( IRCConnection connection ) - { - this.connection = connection; - enable(); - } - - public void enable() - { - if( enabled ) - return; - - connection.addCommandObserver( this ); - enabled = true; - } - - public void disable() - { - if( !enabled ) - return; - - connection.removeCommandObserver( this ); - enabled = false; - } - - /** - * Does the work of figuring out what to respond to. - * If a PING is received, send a PONG. If we JOIN a channel, send a - * request for modes. - * */ - public void update( Observable observer, Object updated ) - { - - if( updated instanceof PingCommand ) - { - // We need to do some pongin'! - PingCommand ping = (PingCommand)updated; - - String response = ping.getPingSource(); - - connection.sendCommand( new PongCommand( response ) ); - } - else if( updated instanceof JoinCommand ) - { - // Determine if we joined, and if we did, trigger a MODE discovery - // request. - JoinCommand join = (JoinCommand)updated; - - if( join.weJoined( connection.getClientState() ) ) - { - connection.sendCommand( - new ChannelModeCommand( join.getChannel() ) ); - } - } - } - - // END AutoResponder -} - - - - |