Remove all bots from a channel if we can’t (re-)join a channel.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Mon, 17 Nov 2014 06:00:38 +0000 (07:00 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Mon, 17 Nov 2014 06:00:38 +0000 (07:00 +0100)
src/main/java/net/pterodactylus/xdcc/core/Core.java

index d4e5155..3414d18 100644 (file)
@@ -577,6 +577,16 @@ public class Core extends AbstractExecutionThreadService {
                        return;
                }
 
+               /* remove all bots for this channel, we might have been kicked. */
+               Collection<Bot> botsToRemove = networkBots.row(network.get())
+                               .values().stream()
+                               .filter(bot -> bot.channel()
+                                               .equalsIgnoreCase(channel.get().name()))
+                               .collect(Collectors.toSet());
+               botsToRemove.stream()
+                               .forEach(bot -> networkBots.row(network.get())
+                                               .remove(bot.name()));
+
                if (channelNotJoined.reason() == registeredNicknamesOnly) {
                        channels.remove(channel.get());
                        eventBus.post(new GenericMessage(