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

protocols: chandata->channeldata for MODE and JOIN hooks

This commit is contained in:
James Lu 2016-09-02 17:52:19 -07:00
parent 4a80b2ce1e
commit c5c77eeb97
7 changed files with 11 additions and 11 deletions

View File

@ -67,7 +67,7 @@ The following hooks represent regular IRC commands sent between servers.
- `modes` returns a list of parsed modes: `(mode character, mode argument)` tuples, where the mode argument is either `None` (for modes without arguments), or a string.
- The sender of this hook payload is IRCd-dependent, and is determined by whether the command was originally a SJOIN or regular JOIN - SJOIN is only sent by servers, and JOIN is only sent by users.
- For IRCds that support joining multiple channels in one command (`/join #channel1,#channel2`), consecutive JOIN hook payloads of this format will be sent (one per channel).
- For SJOIN, the `chandata` key may also be sent, with a copy of the `IrcChannel` object BEFORE any mode changes from this burst command were processed.
- For SJOIN, the `channeldata` key may also be sent, with a copy of the `IrcChannel` object BEFORE any mode changes from this burst command were processed.
- **KICK**: `{'channel': '#channel', 'target': 'UID1', 'text': 'some reason'}`
- `text` refers to the kick reason. The `target` and `channel` fields send the target's UID and the channel they were kicked from, and the sender of the hook payload is the kicker.
@ -76,10 +76,10 @@ The following hooks represent regular IRC commands sent between servers.
- `text` refers to the kill reason. `target` is the target's UID.
- The `userdata` key may include an `IrcUser` instance, depending on the IRCd. On IRCds where QUITs are explicitly sent (InspIRCd), `userdata` will be `None`. Other IRCds do not explicitly send QUIT messages for KILLed clients, so the daemon must assume that they've quit, and deliver their last state to plugins that require this info.
- **MODE**: `{'target': '#channel', 'modes': [('+m', None), ('+i', None), ('+t', None), ('+l', '3'), ('-o', 'person')], 'chandata': IrcChannel(...)}`
- **MODE**: `{'target': '#channel', 'modes': [('+m', None), ('+i', None), ('+t', None), ('+l', '3'), ('-o', 'person')], 'channeldata': IrcChannel(...)}`
- `target` is the target the mode is being set on: it may be either a channel (for channel modes) OR a UID (for user modes).
- `modes` is a list of prefixed parsed modes: `(mode character, mode argument)` tuples, but with `+/-` prefixes to denote whether each mode is being set or unset.
- For channels, the `chandata` key is also sent, with a copy of the `IrcChannel` BEFORE this MODE hook was processed.
- For channels, the `channeldata` key is also sent, with a copy of the `IrcChannel` BEFORE this MODE hook was processed.
- One use for this is to prevent oper-override hacks: checks for whether a sender is opped have to be done before the MODE is processed; otherwise, someone can simply op themselves and circumvent this detection.
- **NICK**: `{'newnick': 'Alakazam', 'oldnick': 'Abracadabra', 'ts': 1234567890}`

View File

@ -876,7 +876,7 @@ def handle_join(irc, numeric, command, args):
claim_passed = checkClaim(irc, channel, numeric)
current_chandata = irc.channels[channel]
chandata = args.get('chandata')
chandata = args.get('channeldata')
log.debug('(%s) relay.handle_join: claim for %s on %s: %s', irc.name, numeric, channel, claim_passed)
log.debug('(%s) relay.handle_join: old channel data %s', irc.name, chandata)
log.debug('(%s) relay.handle_join: current channel data %s', irc.name, current_chandata)
@ -1266,7 +1266,7 @@ def handle_mode(irc, numeric, command, args):
if utils.isChannel(target):
# Use the old state of the channel to check for CLAIM access.
oldchan = args.get('chandata')
oldchan = args.get('channeldata')
if checkClaim(irc, target, numeric, chanobj=oldchan):
remotechan = getRemoteChan(irc, remoteirc, target)

View File

@ -560,7 +560,7 @@ class ClientbotWrapperProtocol(Protocol):
if self.irc.isInternalClient(target):
log.debug('(%s) Suppressing MODE change hook for internal client %s', self.irc.name, target)
return
return {'target': target, 'modes': changedmodes, 'chandata': oldobj}
return {'target': target, 'modes': changedmodes, 'channeldata': oldobj}
def handle_nick(self, source, command, args):
"""Handles NICK changes."""

View File

@ -556,7 +556,7 @@ class InspIRCdProtocol(TS6BaseProtocol):
self.updateTS(servernumeric, channel, their_ts, changedmodes)
return {'channel': channel, 'users': namelist, 'modes': parsedmodes, 'ts': their_ts,
'chandata': chandata}
'channeldata': chandata}
def handle_uid(self, numeric, command, args):
"""Handles incoming UID commands (user introduction)."""

View File

@ -1072,7 +1072,7 @@ class P10Protocol(IRCS2SProtocol):
self.updateTS(source, channel, their_ts, changedmodes)
return {'channel': channel, 'users': namelist, 'modes': parsedmodes, 'ts': their_ts,
'chandata': chandata}
'channeldata': chandata}
def handle_join(self, source, command, args):
"""Handles incoming JOINs and channel creations."""

View File

@ -467,7 +467,7 @@ class TS6Protocol(TS6BaseProtocol):
self.updateTS(servernumeric, channel, their_ts, changedmodes)
return {'channel': channel, 'users': namelist, 'modes': parsedmodes, 'ts': their_ts,
'chandata': chandata}
'channeldata': chandata}
def handle_join(self, numeric, command, args):
"""Handles incoming channel JOINs."""

View File

@ -585,7 +585,7 @@ class UnrealProtocol(TS6BaseProtocol):
self.updateTS(numeric, channel, their_ts, changedmodes)
return {'channel': channel, 'users': namelist, 'modes': self.irc.channels[channel].modes,
'ts': their_ts, 'chandata': chandata}
'ts': their_ts, 'channeldata': chandata}
def handle_nick(self, numeric, command, args):
"""Handles NICK changes, and legacy NICK introductions from pre-4.0 servers."""
@ -662,7 +662,7 @@ class UnrealProtocol(TS6BaseProtocol):
their_ts = int(args[-1])
if their_ts > 0:
self.updateTS(numeric, channel, their_ts)
return {'target': channel, 'modes': parsedmodes, 'chandata': oldobj}
return {'target': channel, 'modes': parsedmodes, 'channeldata': oldobj}
else:
log.warning("(%s) received MODE for non-channel target: %r",
self.irc.name, args)