package net.pterodactylus.xdcc.core;
+import static java.lang.String.format;
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;
import net.pterodactylus.irc.event.DccDownloadFailed;
import net.pterodactylus.irc.event.DccDownloadFinished;
import net.pterodactylus.irc.event.DccSendReceived;
+import net.pterodactylus.irc.event.KickedFromChannel;
import net.pterodactylus.irc.event.NicknameChanged;
import net.pterodactylus.irc.event.PrivateMessageReceived;
import net.pterodactylus.irc.event.PrivateNoticeReceived;
networkBots.remove(network.get(), channelLeft.client().nick().get());
}
+ @Subscribe
+ public void kickedFromChannel(KickedFromChannel kickedFromChannel) {
+ Optional<Network> network = getNetwork(kickedFromChannel.connection());
+ if (!network.isPresent()) {
+ return;
+ }
+
+ /* have we been kicked? */
+ if (nicknameMatchesConnection(kickedFromChannel.connection(), kickedFromChannel.kickee())) {
+ eventBus.post(new GenericMessage(format(
+ "Kicked from %s/%s by %s: %s",
+ kickedFromChannel.channel(), network.get(),
+ kickedFromChannel.kicker(),
+ kickedFromChannel.reason().or("<unknown>")
+ )));
+ }
+ }
+
+ private boolean nicknameMatchesConnection(Connection connection, String nickname) {
+ return connection.nickname().equalsIgnoreCase(nickname);
+ }
+
/**
* Removes a client (which may be a bot) from the table of known bots.
*