+ Optional<Channel> channel = getChannel(network.get(), channelNotJoined.channel());
+ synchronized (syncObject) {
+ syncObject.notifyAll();
+ }
+ if (!channel.isPresent()) {
+ eventBus.post(new GenericMessage(format("Could not join %s but didn’t try to join, either.", channelNotJoined.channel())));
+ return;
+ }
+ channelsBeingJoined.remove(channel.get());
+
+
+ /* 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()));
+
+ channelBanManager.ban(channel.get());
+ if (channelNotJoined.reason() == registeredNicknamesOnly) {
+ eventBus.post(new GenericMessage(
+ format("%s requires nickname registration, suspending join for a day.",
+ channel.get())));
+ } else if (channelNotJoined.reason() == inviteOnly) {
+ eventBus.post(new GenericMessage(
+ format("%s is invite-only, suspending join for a day.",
+ channel.get())));
+ } else if (channelNotJoined.reason() == banned) {
+ eventBus.post(new GenericMessage(
+ format("Banned from %s, suspending join for a day.",
+ channel.get())));
+ } else {
+ eventBus.post(new GenericMessage(
+ format("Could not join %s: %s", channelNotJoined.channel(),
+ channelNotJoined.reason())));
+ }