Browse Source

Handle getting kicked

master
JustAnotherArchivist 3 years ago
parent
commit
7c1d40d3ff
1 changed files with 10 additions and 0 deletions
  1. +10
    -0
      irclog.py

+ 10
- 0
irclog.py View File

@@ -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}')


Loading…
Cancel
Save