Don’t try to join channels that require a registration anymore.
[xudocci.git] / src / main / java / net / pterodactylus / xdcc / core / Core.java
index 509d30e..1ea95a9 100644 (file)
@@ -18,6 +18,7 @@
 package net.pterodactylus.xdcc.core;
 
 import static java.lang.String.format;
+import static net.pterodactylus.irc.event.ChannelNotJoined.Reason.registeredNicknamesOnly;
 import static net.pterodactylus.irc.util.MessageCleaner.getDefaultInstance;
 import static net.pterodactylus.xdcc.data.Channel.TO_NETWORK;
 import static net.pterodactylus.xdcc.data.Download.FILTER_RUNNING;
@@ -545,9 +546,18 @@ public class Core extends AbstractExecutionThreadService {
                        return;
                }
 
+               if (channelNotJoined.reason() == registeredNicknamesOnly) {
+                       Optional<Channel> channel = getChannel(network.get(), channelNotJoined.channel());
+                       if (channel.isPresent()) {
+                               eventBus.post(new GenericMessage(format("Not trying to join %s anymore.", channel.get())));
+                               channels.remove(channel.get());
+                       }
+                       return;
+               }
+
                eventBus.post(new GenericMessage(
-                               format("Could not join %s/%s: %s", channelNotJoined.channel(),
-                                               network.get(), channelNotJoined.reason())));
+                               format("Could not join %s: %s", channelNotJoined.channel(),
+                                               channelNotJoined.reason())));
        }
 
        /**
@@ -613,8 +623,8 @@ public class Core extends AbstractExecutionThreadService {
                                channels.remove(channel.get());
                        }
                        eventBus.post(new GenericMessage(format(
-                                       "Kicked from %s/%s by %s: %s",
-                                       kickedFromChannel.channel(), network.get(),
+                                       "Kicked from %s by %s: %s",
+                                       kickedFromChannel.channel(),
                                        kickedFromChannel.kicker(),
                                        kickedFromChannel.reason().or("<unknown>")
                        )));