[Cherbot-commit] SF.net SVN: cherbot: [110] trunk/src/net/sf/cherbot/IRCConnection.java
Status: Alpha
Brought to you by:
christianhujer
|
From: <chr...@us...> - 2007-06-30 19:48:15
|
Revision: 110
http://svn.sourceforge.net/cherbot/?rev=110&view=rev
Author: christianhujer
Date: 2007-06-30 12:48:13 -0700 (Sat, 30 Jun 2007)
Log Message:
-----------
Implemented more IRC commands: INVITE, JOIN, MODE.
Modified Paths:
--------------
trunk/src/net/sf/cherbot/IRCConnection.java
Modified: trunk/src/net/sf/cherbot/IRCConnection.java
===================================================================
--- trunk/src/net/sf/cherbot/IRCConnection.java 2007-06-30 19:17:43 UTC (rev 109)
+++ trunk/src/net/sf/cherbot/IRCConnection.java 2007-06-30 19:48:13 UTC (rev 110)
@@ -115,6 +115,7 @@
}
final PatternDelegator delegator = new PatternDelegator(this);
for (String line; (line = in.readLine()) != null;) {
+ System.out.print("> ");
System.out.println(line);
delegator.process(line);
}
@@ -124,6 +125,54 @@
}
}
+ /** Processes an INVITE irc message.
+ * @param actor Actor of this JOIN.
+ * @param actorIdentity Identity of the actor.
+ * @param target Target of the invitation.
+ * @param channel Channel to join.
+ */
+ @Patterns({"^:([^!]+)!([^ ]+) INVITE ([^ ]+) :(.*)$"})
+ public void processINVITE(@NotNull final String actor, @NotNull final String actorIdentity, @NotNull final String target, @NotNull final String channel) {
+ System.err.println("Received invitation to " + target + " at " + channel + " by " + actor + " (" + actorIdentity + ")");
+ join(channel);
+ }
+
+ /** Processes a JOIN irc message.
+ * @param actor Actor of this JOIN.
+ * @param actorIdentity Identity of the actor.
+ * @param channel Channel to join.
+ */
+ @Patterns({"^:([^!]+)!([^ ]+) JOIN :(.*)$"})
+ public void processJOIN(@NotNull final String actor, @NotNull final String actorIdentity, @NotNull final String channel) {
+ System.err.println("Joined channel " + channel);
+ // Nothing to do for a JOIN.
+ }
+
+ /** 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.
+ */
+ @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) {
+ System.err.println("Mode change at " + channel + ": " + change + " on " + target + " by " + actor + " (" + actorIdentity + ")");
+ // Nothing to do for a MODE.
+ }
+
+ /** Processes a PING irc message.
+ * @param server Server that requests a PONG.
+ */
+ @Patterns({"^PING :(.*)$"})
+ public void processPING(@NotNull final String server) {
+ final PrintWriter out = this.out;
+ if (out != null) {
+ out.println("PONG " + server);
+ out.flush();
+ }
+ }
+
/** Processes a PRIVMSG irc message.
* @param actor Actor of this message.
* @param actorIdentity Identity of the actor.
@@ -141,18 +190,6 @@
System.out.println(channel);
}
- /** Processes a PING irc message.
- * @param server Server that requests a PONG.
- */
- @Patterns({"^PING :(.*)$"})
- public void processPING(@NotNull final String server) {
- final PrintWriter out = this.out;
- if (out != null) {
- out.println("PONG " + server);
- out.flush();
- }
- }
-
/** Joins an IRC channel.
* @param rawChannelName name of the channel to join.
* @return The channel that was just joined.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|