From: David ‘Bombe’ Roden Date: Thu, 11 Apr 2013 20:48:34 +0000 (+0200) Subject: Send event when a client parts a channel. X-Git-Url: https://git.pterodactylus.net/?p=xudocci.git;a=commitdiff_plain;h=5cc5fd2f2cc010e77448ca044c7679739add966f Send event when a client parts a channel. --- diff --git a/src/main/java/net/pterodactylus/irc/Connection.java b/src/main/java/net/pterodactylus/irc/Connection.java index c7d5428..15c8ff5 100644 --- a/src/main/java/net/pterodactylus/irc/Connection.java +++ b/src/main/java/net/pterodactylus/irc/Connection.java @@ -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 index 0000000..e9c52f3 --- /dev/null +++ b/src/main/java/net/pterodactylus/irc/event/ChannelLeft.java @@ -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 . + */ + +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 David ‘Bombe’ Roden + */ +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; + } + +}