import net.pterodactylus.irc.event.ChannelNotJoined;
import net.pterodactylus.irc.event.ChannelNotJoined.Reason;
import net.pterodactylus.irc.event.ChannelTopic;
+import net.pterodactylus.irc.event.ClientQuit;
import net.pterodactylus.irc.event.ConnectionEstablished;
import net.pterodactylus.irc.event.ConnectionFailed;
import net.pterodactylus.irc.event.DccSendReceived;
nicks.clear();
} else if (command.equalsIgnoreCase("PART")) {
eventBus.post(new ChannelLeft(this, parameters.get(0), reply.source().get(), parameters.get(1)));
+ } else if (command.equalsIgnoreCase("QUIT")) {
+ eventBus.post(new ClientQuit(this, reply.source().get(), parameters.get(0)));
/* common channel join errors. */
} else if (command.equals("474")) {
--- /dev/null
+/*
+ * XdccDownloader - ClientQuit.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;
+
+/**
+ * Notifies a listener that a client has quit.
+ *
+ * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
+public class ClientQuit extends AbstractConnectionEvent {
+
+ /** The client that quit. */
+ private final Source client;
+
+ /** The message given by the client. */
+ private final String message;
+
+ /**
+ * Creates a new client quit event.
+ *
+ * @param connection
+ * The connection on which the event occured
+ * @param client
+ * The client that quit
+ * @param message
+ * The message given by the client
+ */
+ public ClientQuit(Connection connection, Source client, String message) {
+ super(connection);
+ this.client = client;
+ this.message = message;
+ }
+
+ //
+ // ACCESSORS
+ //
+
+ /**
+ * Returns the client that quit.
+ *
+ * @return The client that quit
+ */
+ public Source client() {
+ return client;
+ }
+
+ /**
+ * Returns the message given by the client.
+ *
+ * @return The message given by the client
+ */
+ public String message() {
+ return message;
+ }
+
+}
import net.pterodactylus.irc.event.ChannelJoined;
import net.pterodactylus.irc.event.ChannelLeft;
import net.pterodactylus.irc.event.ChannelMessageReceived;
+import net.pterodactylus.irc.event.ClientQuit;
import net.pterodactylus.irc.event.ConnectionEstablished;
import net.pterodactylus.irc.event.DccDownloadFailed;
import net.pterodactylus.irc.event.DccDownloadFinished;
}
/**
+ * Removes a client (which may be a bot) from the table of known bots.
+ *
+ * @param clientQuit
+ * The client quit event
+ */
+ @Subscribe
+ public void clientQuit(ClientQuit clientQuit) {
+ Optional<Network> network = getNetwork(clientQuit.connection());
+ if (!network.isPresent()) {
+ return;
+ }
+
+ networkBots.remove(network.get(), clientQuit.client().nick().get());
+ }
+
+ /**
* If a message on a channel is received, it is parsed for pack information
* with is then added to a bot.
*