import net.pterodactylus.irc.event.DccDownloadFailed;
import net.pterodactylus.irc.event.DccDownloadFinished;
import net.pterodactylus.irc.event.DccSendReceived;
+import net.pterodactylus.irc.event.NicknameChanged;
import net.pterodactylus.irc.event.PrivateMessageReceived;
import net.pterodactylus.irc.util.MessageCleaner;
import net.pterodactylus.irc.util.RandomNickname;
}
/**
+ * If the nickname of a bit changes, remove it from the old name and store it
+ * under the new name.
+ *
+ * @param nicknameChanged
+ * The nickname changed event
+ */
+ @Subscribe
+ public void nicknameChanged(NicknameChanged nicknameChanged) {
+ Optional<Network> network = getNetwork(nicknameChanged.connection());
+ if (!network.isPresent()) {
+ return;
+ }
+
+ Bot bot = networkBots.remove(network.get(), nicknameChanged.client().nick().get());
+ if (bot == null) {
+ return;
+ }
+
+ networkBots.put(network.get(), nicknameChanged.newNickname(), bot);
+ }
+
+ /**
* If a message on a channel is received, it is parsed for pack information
* with is then added to a bot.
*