[Cherbot-commit] SF.net SVN: cherbot:[149] trunk/src/prj/net/sf/cherbot
Status: Alpha
Brought to you by:
christianhujer
|
From: <chr...@us...> - 2009-02-17 20:18:26
|
Revision: 149
http://cherbot.svn.sourceforge.net/cherbot/?rev=149&view=rev
Author: christianhujer
Date: 2009-02-17 20:18:19 +0000 (Tue, 17 Feb 2009)
Log Message:
-----------
Improved documentation, implemented KICK and NOTICE irc commands.
Modified Paths:
--------------
trunk/src/prj/net/sf/cherbot/connection/IRCConnection.java
Added Paths:
-----------
trunk/src/prj/net/sf/cherbot/CommandDispatcher.java
trunk/src/prj/net/sf/cherbot/ui/
trunk/src/prj/net/sf/cherbot/ui/package-info.java
Added: trunk/src/prj/net/sf/cherbot/CommandDispatcher.java
===================================================================
--- trunk/src/prj/net/sf/cherbot/CommandDispatcher.java (rev 0)
+++ trunk/src/prj/net/sf/cherbot/CommandDispatcher.java 2009-02-17 20:18:19 UTC (rev 149)
@@ -0,0 +1,16 @@
+package net.sf.cherbot;
+
+import net.sf.cherbot.connection.Channel;
+import org.jetbrains.annotations.NotNull;
+
+/** An implementation of this interface is capable of dispatching commands.
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
+ */
+public interface CommandDispatcher {
+
+ /** Dispatch a command.
+ * @param command Command to dispatch.
+ * @param channel Channel from which this command is received.
+ */
+ void dispatch(@NotNull String command, @NotNull Channel channel);
+}
Property changes on: trunk/src/prj/net/sf/cherbot/CommandDispatcher.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ LF
Modified: trunk/src/prj/net/sf/cherbot/connection/IRCConnection.java
===================================================================
--- trunk/src/prj/net/sf/cherbot/connection/IRCConnection.java 2008-12-15 01:09:25 UTC (rev 148)
+++ trunk/src/prj/net/sf/cherbot/connection/IRCConnection.java 2009-02-17 20:18:19 UTC (rev 149)
@@ -23,8 +23,32 @@
import org.jetbrains.annotations.Nullable;
/** An IRCConnection represents a connection to an IRC server.
+ *
+ * Message BNF:
+ * <pre><![CDATA[
+ * message = [ ":" prefix SPACE ] command [ params ] crlf
+ * prefix = servername / ( nickname [ [ "!" user ] "@" host ] )
+ * command = 1*letter / 3digit
+ * params = *14( SPACE middle ) [ SPACE ":" trailing ]
+ * =/ 14( SPACE middle ) [ SPACE [ ":" ] trailing ]
+ * nospcrlfcl = %x01-09 / %x0B-0C / %x0E-1F / %x21-39 / %x3B-FF
+ * ; any octet except NUL, CR, LF, " " and ":"
+ * middle = nospcrlfcl *( ":" / nospcrlfcl )
+ * trailing = *( ":" / " " / nospcrlfcl )
+ * SPACE = %x20 ; space character
+ * crlf = %x0D %x0A ; "carriage return" "linefeed"
+ * ]]></pre>
+ *
+ * Message regex based on that BNF:
+ * <pre><![CDATA[
+ * message = (:$prefix )?$command$params
+ * prefix = ($servername|$nick((!$user)?(@$host))?)
+ * command = ([A-Za-z]+|\d\d\d)
+ * ]]></pre>
+ *
* @author <a href="mailto:ch...@ri...">Christian Hujer</a>
- * @see <a href="ftp://ftp.rfc-editor.org/in-notes/rfc2812.txt">RFC 2812: Internet Relay Chat: Client Protocol</a>
+ * @see <a href="http://www.ietf.org/rfc/rfc2812.txt">RFC 2812: Internet Relay Chat: Client Protocol</a>
+ * @see <a href="http://www.irchelp.org/irchelp/rfc/ctcpspec.html">The Client-To-Client Protocol (CTCP)</a> (Not yet supported by CherBot)
*/
public class IRCConnection extends AbstractNetworkConnection {
@@ -134,10 +158,11 @@
}
/** Processes an INVITE irc message.
- * @param actor Actor of this JOIN.
+ * @param actor Actor of this INVITE.
* @param actorIdentity Identity of the actor.
* @param target Target of the invitation.
* @param channel Channel to join.
+ * @see <a href="http://www.ietf.org/rfc/rfc2812.txt">RFC 2812: Internet Relay Chat: Client Protocol</a> 3.2.7 Invite message
*/
@Patterns({"^:([^!]+)!([^ ]+) INVITE ([^ ]+) :(.*)$"})
public void processINVITE(@NotNull final String actor, @NotNull final String actorIdentity, @NotNull final String target, @NotNull final String channel) {
@@ -149,6 +174,7 @@
* @param actor Actor of this JOIN.
* @param actorIdentity Identity of the actor.
* @param channel Channel to join.
+ * @see <a href="http://www.ietf.org/rfc/rfc2812.txt">RFC 2812: Internet Relay Chat: Client Protocol</a> 3.2.1 Join message
*/
@Patterns({"^:([^!]+)!([^ ]+) JOIN :(.*)$"})
public void processJOIN(@NotNull final String actor, @NotNull final String actorIdentity, @NotNull final String channel) {
@@ -156,12 +182,27 @@
// Nothing to do for a JOIN.
}
+ /** Process a KICK irc message.
+ * @param actor Actor of this MODE.
+ * @param actorIdentity Identity of the actor.
+ * @param channel Channel of the mode change.
+ * @param change Mode change.
+ * @param target Target of the mode change.
+ * @see <a href="http://www.ietf.org/rfc/rfc2812.txt">RFC 2812: Internet Relay Chat: Client Protocol</a> 3.2.8 Kick command
+ */
+ @Patterns({"^:([^!]+)!([^ ]+) KICK ([^ ]+) ([^ ]+) (.*?) ?$"})
+ public void processKICK(@NotNull final String actor, @NotNull final String actorIdentity, @NotNull final String channel, @NotNull final String change, @NotNull final String target) {
+ System.err.println("Kicked from " + channel + ": " + change + " on " + target + " by " + actor + " (" + actorIdentity + ")");
+ // Nothing to do for a KICK.
+ }
+
/** Process a MODE irc message.
* @param actor Actor of this MODE.
* @param actorIdentity Identity of the actor.
* @param channel Channel of the mode change.
* @param change Mode change.
* @param target Target of the mode change.
+ * @see <a href="http://www.ietf.org/rfc/rfc2812.txt">RFC 2812: Internet Relay Chat: Client Protocol</a> 3.2.3 Channel mode message
*/
@Patterns({"^:([^!]+)!([^ ]+) MODE ([^ ]+) ([^ ]+) (.*?) ?$"})
public void processMODE(@NotNull final String actor, @NotNull final String actorIdentity, @NotNull final String channel, @NotNull final String change, @NotNull final String target) {
@@ -169,6 +210,19 @@
// Nothing to do for a MODE.
}
+ /** Processes a NOTICE irc message.
+ * @param actor Actor of this message.
+ * @param actorIdentity Identity of the actor.
+ * @param channelName Name of the channel.
+ * @param message Message text.
+ * @see <a href="http://www.ietf.org/rfc/rfc2812.txt">RFC 2812: Internet Relay Chat: Client Protocol</a> 3.3.2 Notice
+ */
+ @Patterns({"^:([^!]+)!([^ ]+) NOTICE ([^ ]+) :(.*)$"})
+ public void processNOTICE(@NotNull final String actor, @NotNull final String actorIdentity, @NotNull final String channelName, @NotNull final String message) {
+ final Channel channel = getOrCreateChannel(channelName);
+ // TODO:cher:Process message.
+ }
+
/** Processes a PING irc message.
* @param server Server that requests a PONG.
*/
@@ -186,6 +240,7 @@
* @param actorIdentity Identity of the actor.
* @param channelName Name of the channel.
* @param message Message text.
+ * @see <a href="http://www.ietf.org/rfc/rfc2812.txt">RFC 2812: Internet Relay Chat: Client Protocol</a> 3.3.1 Private messages
*/
@Patterns({"^:([^!]+)!([^ ]+) PRIVMSG ([^ ]+) :(.*)$"})
public void processPRIVMSG(@NotNull final String actor, @NotNull final String actorIdentity, @NotNull final String channelName, @NotNull final String message) {
Added: trunk/src/prj/net/sf/cherbot/ui/package-info.java
===================================================================
--- trunk/src/prj/net/sf/cherbot/ui/package-info.java (rev 0)
+++ trunk/src/prj/net/sf/cherbot/ui/package-info.java 2009-02-17 20:18:19 UTC (rev 149)
@@ -0,0 +1,6 @@
+/** This package contains a graphical user interface for CherBot.
+ * It is useful for debugging.
+ * Of course CherBot also runs without GUI.
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
+ */
+package net.sf.cherbot.ui;
Property changes on: trunk/src/prj/net/sf/cherbot/ui/package-info.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ LF
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|