Parse KICK command and send appropriate event.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 15 Oct 2014 19:37:36 +0000 (21:37 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 15 Oct 2014 19:37:36 +0000 (21:37 +0200)
src/main/java/net/pterodactylus/irc/Connection.java
src/main/java/net/pterodactylus/irc/event/KickedFromChannel.java [new file with mode: 0644]

index fb67fe7..70ac0eb 100644 (file)
@@ -52,6 +52,7 @@ import net.pterodactylus.irc.event.ConnectionEstablished;
 import net.pterodactylus.irc.event.ConnectionFailed;
 import net.pterodactylus.irc.event.DccAcceptReceived;
 import net.pterodactylus.irc.event.DccSendReceived;
+import net.pterodactylus.irc.event.KickedFromChannel;
 import net.pterodactylus.irc.event.MotdReceived;
 import net.pterodactylus.irc.event.NicknameChanged;
 import net.pterodactylus.irc.event.NicknameInUseReceived;
@@ -500,6 +501,9 @@ public class Connection extends AbstractExecutionThreadService implements Servic
                                        eventBus.post(new MotdReceived(this, motd.toString()));
                                        motd.setLength(0);
 
+                               } else if (command.equals("KICK")) {
+                                       eventBus.post(new KickedFromChannel(this, parameters.get(0), reply.source().get(), parameters.get(1), getOptional(parameters, 2)));
+
                                /* okay, everything else. */
                                } else {
                                        eventBus.post(new UnknownReplyReceived(this, reply));
diff --git a/src/main/java/net/pterodactylus/irc/event/KickedFromChannel.java b/src/main/java/net/pterodactylus/irc/event/KickedFromChannel.java
new file mode 100644 (file)
index 0000000..54b4f67
--- /dev/null
@@ -0,0 +1,38 @@
+package net.pterodactylus.irc.event;
+
+import net.pterodactylus.irc.Connection;
+import net.pterodactylus.irc.Source;
+
+import com.google.common.base.Optional;
+
+/**
+ * Event that signals that a client was kicked from a channel.
+ *
+ * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
+public class KickedFromChannel extends AbstractChannelEvent {
+
+       private final Source kicker;
+       private final String kickee;
+       private final Optional<String> reason;
+
+       public KickedFromChannel(Connection connection, String channel, Source kicker, String kickee, Optional<String> reason) {
+               super(connection, channel);
+               this.kicker = kicker;
+               this.kickee = kickee;
+               this.reason = reason;
+       }
+
+       public Source kicker() {
+               return kicker;
+       }
+
+       public String kickee() {
+               return kickee;
+       }
+
+       public Optional<String> reason() {
+               return reason;
+       }
+
+}