return networkConnections.entrySet().stream().map((entry) -> {
Network network = entry.getKey();
Collection<Bot> bots = networkBots.row(network).values();
- int packCount = bots.stream().mapToInt((bot) -> bot.packs().size()).reduce((a, b) -> a + b).getAsInt();
+ int packCount = bots.stream().mapToInt((bot) -> bot.packs().size()).reduce((a, b) -> a + b).orElse(0);
return new ConnectedNetwork(network, entry.getValue().hostname(),
entry.getValue().port(), entry.getValue().nickname(),
channels.stream()
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(
Bot bot;
synchronized (networkBots) {
if (!networkBots.contains(network.get(), channelMessageReceived.source().nick().get())) {
- bot = new Bot(network.get(), channelMessageReceived.source().nick().get());
+ bot = new Bot(network.get(), channelMessageReceived.channel(),
+ channelMessageReceived.source().nick().get());
networkBots.put(network.get(), channelMessageReceived.source().nick().get(), bot);
eventBus.post(new BotAdded(bot));
} else {