Browse Source

Add support for INVITE after getting KICKed from a channel

master
JustAnotherArchivist 2 years ago
parent
commit
a27bc20340
1 changed files with 13 additions and 0 deletions
  1. +13
    -0
      http2irc.py

+ 13
- 0
http2irc.py View File

@@ -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


Loading…
Cancel
Save