Send event when a client parts a channel.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 11 Apr 2013 20:48:34 +0000 (22:48 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 11 Apr 2013 20:48:34 +0000 (22:48 +0200)
src/main/java/net/pterodactylus/irc/Connection.java
src/main/java/net/pterodactylus/irc/event/ChannelLeft.java [new file with mode: 0644]

index c7d5428..15c8ff5 100644 (file)
@@ -39,6 +39,7 @@ import java.util.logging.Logger;
 import javax.net.SocketFactory;
 
 import net.pterodactylus.irc.event.ChannelJoined;
+import net.pterodactylus.irc.event.ChannelLeft;
 import net.pterodactylus.irc.event.ChannelMessageReceived;
 import net.pterodactylus.irc.event.ChannelNicknames;
 import net.pterodactylus.irc.event.ChannelNotJoined;
@@ -388,6 +389,8 @@ public class Connection extends AbstractExecutionThreadService implements Servic
                                } else if (command.equals("366")) {
                                        eventBus.post(new ChannelNicknames(this, parameters.get(1), nicks));
                                        nicks.clear();
+                               } else if (command.equalsIgnoreCase("PART")) {
+                                       eventBus.post(new ChannelLeft(this, parameters.get(0), reply.source().get(), parameters.get(1)));
 
                                /* common channel join errors. */
                                } else if (command.equals("474")) {
diff --git a/src/main/java/net/pterodactylus/irc/event/ChannelLeft.java b/src/main/java/net/pterodactylus/irc/event/ChannelLeft.java
new file mode 100644 (file)
index 0000000..e9c52f3
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+ * XdccDownloader - ChannelLeft.java - Copyright © 2013 David Roden
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package net.pterodactylus.irc.event;
+
+import net.pterodactylus.irc.Connection;
+import net.pterodactylus.irc.Source;
+
+/**
+ * Event that notifies a listener that a client has left a channel.
+ *
+ * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
+public class ChannelLeft extends AbstractChannelEvent {
+
+       /** The parting client. */
+       private final Source client;
+
+       /** The message given by the client. */
+       private final String message;
+
+       /**
+        * Creates a new channel joined event.
+        *
+        * @param connection
+        *              The connection that joined the channel
+        * @param channel
+        *              The channel being left
+        * @param message
+        *              The message given by the client
+        */
+       public ChannelLeft(Connection connection, String channel, Source client, String message) {
+               super(connection, channel);
+               this.client = client;
+               this.message = message;
+       }
+
+       //
+       // ACCESSORS
+       //
+
+       /**
+        * Returns the client that joined the channel.
+        *
+        * @return The client that joined the channel
+        */
+       public Source client() {
+               return client;
+       }
+
+       /**
+        * Returns the message given by the client.
+        *
+        * @return The message given by the client
+        */
+       public String message() {
+               return message;
+       }
+
+}