Skip to content

Commit

Permalink
Properly track channel permissions on join
Browse files Browse the repository at this point in the history
  • Loading branch information
johnmaguire committed Feb 14, 2024
1 parent 5dd01fc commit 01f08c8
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions cardinal/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ def joined(self, channel):
if self.channels:
self.channels.add(channel)

# Request the channel modes for this channel
self.sendLine("MODE {}".format(channel))
# Request the channel modes for this channel
self.send("MODE {}".format(channel))

def irc_RPL_CHANNELMODEIS(self, prefix, params):
channel, modes, args = params[1], params[2], params[3:]
Expand Down Expand Up @@ -366,6 +366,22 @@ def irc_MODE(self, prefix, params):
# Trigger events
self.event_manager.fire("irc.mode", user, channel, mode)

def irc_RPL_CHANNELMODEIS(self, prefix, params):
"""Called when we get a MODE reply"""

channel, modes, args = params[1], params[2], params[3:]
if modes[0] not in "-+":
modes = "+" + modes

# Update channel in memory
if channel != self.nickname:
self.channels.set_modes(channel, modes, args)

mode = (modes + ' ' + ' '.join(args)).strip()

self.logger.debug(
"Channel %s has mode %s" % (channel, mode))

def irc_JOIN(self, prefix, params):
"""Called when a user joins a channel"""
super().irc_JOIN(prefix, params)
Expand Down Expand Up @@ -505,7 +521,7 @@ def who(self, channel):
# Send the actual WHO command to the server. irc_RPL_WHOREPLY will
# receive a response when the server sends one.
self.logger.info("Making WHO request to server")
self.sendLine("WHO %s" % channel)
self.send("WHO %s" % channel)
else:
self._who_deferreds[channel].append(d)

Expand Down

0 comments on commit 01f08c8

Please sign in to comment.