Remove all bots from a channel if we can’t (re-)join a channel.
[xudocci.git] / 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(