3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-01 01:09:22 +01:00

protocols: return an "oldchan" IrcChannel object with the previous state of a channel when processing channel mode changes

This allows plugins to check for op statuses, etc. before the mode change is processed.
This commit is contained in:
James Lu 2015-09-13 13:47:18 -07:00
parent a28715c2c6
commit c82a0a771c
2 changed files with 6 additions and 2 deletions

View File

@ -466,11 +466,13 @@ class InspIRCdProtocol(TS6BaseProtocol):
"""Handles the FMODE command, used for channel mode changes."""
# <- :70MAAAAAA FMODE #chat 1433653462 +hhT 70MAAAAAA 70MAAAAAD
channel = utils.toLower(self.irc, args[0])
oldobj = self.irc.channels[channel].deepcopy()
modes = args[2:]
changedmodes = utils.parseModes(self.irc, channel, modes)
utils.applyModes(self.irc, channel, changedmodes)
ts = int(args[1])
return {'target': channel, 'modes': changedmodes, 'ts': ts}
return {'target': channel, 'modes': changedmodes, 'ts': ts,
'oldchan': oldobj}
def handle_mode(self, numeric, command, args):
"""Handles incoming user mode changes."""

View File

@ -603,11 +603,13 @@ class TS6Protocol(TS6BaseProtocol):
"""Handles incoming TMODE commands (channel mode change)."""
# <- :42XAAAAAB TMODE 1437450768 #endlessvoid -c+lkC 3 agte4
channel = utils.toLower(self.irc, args[1])
oldobj = self.irc.channels[channel].deepcopy()
modes = args[2:]
changedmodes = utils.parseModes(self.irc, channel, modes)
utils.applyModes(self.irc, channel, changedmodes)
ts = int(args[0])
return {'target': channel, 'modes': changedmodes, 'ts': ts}
return {'target': channel, 'modes': changedmodes, 'ts': ts,
'oldchan': oldobj}
def handle_mode(self, numeric, command, args):
"""Handles incoming user mode changes."""