From bf5c410d06c7a354017ebcd321e365b9cd767081 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Wed, 15 Oct 2014 21:37:36 +0200 Subject: [PATCH] Parse KICK command and send appropriate event. --- .../java/net/pterodactylus/irc/Connection.java | 4 +++ .../pterodactylus/irc/event/KickedFromChannel.java | 38 ++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 src/main/java/net/pterodactylus/irc/event/KickedFromChannel.java diff --git a/src/main/java/net/pterodactylus/irc/Connection.java b/src/main/java/net/pterodactylus/irc/Connection.java index fb67fe7..70ac0eb 100644 --- a/src/main/java/net/pterodactylus/irc/Connection.java +++ b/src/main/java/net/pterodactylus/irc/Connection.java @@ -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 index 0000000..54b4f67 --- /dev/null +++ b/src/main/java/net/pterodactylus/irc/event/KickedFromChannel.java @@ -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 David ‘Bombe’ Roden + */ +public class KickedFromChannel extends AbstractChannelEvent { + + private final Source kicker; + private final String kickee; + private final Optional reason; + + public KickedFromChannel(Connection connection, String channel, Source kicker, String kickee, Optional 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 reason() { + return reason; + } + +} -- 2.7.4