aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar JustAnotherArchivist2021-12-08 01:52:45 +0000
committerGravatar JustAnotherArchivist2021-12-08 01:52:45 +0000
commita27bc2034097c0a52d11472b21b61201c2bc6c84 (patch)
tree6c7b2332704509764532cc5282e2eef047c5623d
parentFix NameError crash on quitting (diff)
signature
Add support for INVITE after getting KICKed from a channel
-rw-r--r--http2irc.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/http2irc.py b/http2irc.py
index d6cce6c..85a7d1c 100644
--- a/http2irc.py
+++ b/http2irc.py
@@ -360,6 +360,7 @@ class IRCClientProtocol(asyncio.Protocol):
self.buffer = b''
self.connected = False
self.channels = channels # Currently joined/supposed-to-be-joined channels; set(str)
+ self.kickedChannels = set() # Channels the bot got KICKed from (for re-INVITE purposes; reset on config reloading)
self.unconfirmedMessages = []
self.pongReceivedEvent = asyncio.Event()
self.sasl = bool(self.config['irc']['certfile'] and self.config['irc']['certkeyfile'])
@@ -432,6 +433,7 @@ class IRCClientProtocol(asyncio.Protocol):
channelsToPart = self.channels - channels
channelsToJoin = channels - self.channels
self.channels = channels
+ self.kickedChannels = set()
if self.connected:
if channelsToPart:
@@ -710,6 +712,17 @@ class IRCClientProtocol(asyncio.Protocol):
for channel in self.channels:
if self.server.casefold(channel) == kickedChannel:
self.channels.remove(channel)
+ self.kickedChannels.add(channel) # Non-folded version so the set comparison in update_channels doesn't break.
+ break
+
+ # Bot getting INVITEd after a KICK
+ elif line.command == 'INVITE' and line.source and self.server.casefold(line.params[0]) == self.server.casefold(self.server.nickname):
+ invitedChannel = self.server.casefold(line.params[1])
+ for channel in self.kickedChannels:
+ if self.server.casefold(channel) == invitedChannel:
+ self.channels.add(channel)
+ self.kickedChannels.remove(channel)
+ self._send_join_part(b'JOIN', {channel})
break
# WHOX on successful JOIN if supported to fetch account information