diff --git a/irclog.py b/irclog.py index a533834..8cdd43d 100644 --- a/irclog.py +++ b/irclog.py @@ -278,6 +278,7 @@ class IRCClientProtocol(asyncio.Protocol): channelsToPart = self.channels - channels channelsToJoin = channels - self.channels self.channels = channels + #TODO Rejoin channels the bot got kicked from? if self.connected: if channelsToPart: @@ -369,6 +370,15 @@ class IRCClientProtocol(asyncio.Protocol): return self._send_join_part(b'JOIN', self.channels) + # Bot getting KICKed + elif line.command == 'KICK' and line.source and self.server.casefold(line.params[1]) == self.server.casefold(self.server.nickname): + self.logger.warning(f'Got kicked from {line.params[0]}') + kickedChannel = self.server.casefold(line.params[0]) + for channel in self.channels: + if self.server.casefold(channel) == kickedChannel: + self.channels.remove(channel) + break + # General fatal ERROR elif line.command == 'ERROR': self.logger.error(f'Server sent ERROR: {message!r}')