Remove a bot when it quits.
[xudocci.git] / src / main / java / net / pterodactylus / xdcc / core / Core.java
index 4d1e1ac..64fdbec 100644 (file)
@@ -36,6 +36,7 @@ import net.pterodactylus.irc.DccReceiver;
 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;
@@ -344,6 +345,22 @@ public class Core extends AbstractIdleService {
        }
 
        /**
+        * 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.
         *