mirror of
https://github.com/jlu5/PyLink.git
synced 2024-11-01 09:19:23 +01:00
protocols: chandata->channeldata for MODE and JOIN hooks
This commit is contained in:
parent
4a80b2ce1e
commit
c5c77eeb97
@ -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.
|
- `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.
|
- 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 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'}`
|
- **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.
|
- `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.
|
- `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.
|
- 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).
|
- `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.
|
- `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.
|
- 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}`
|
- **NICK**: `{'newnick': 'Alakazam', 'oldnick': 'Abracadabra', 'ts': 1234567890}`
|
||||||
|
@ -876,7 +876,7 @@ def handle_join(irc, numeric, command, args):
|
|||||||
|
|
||||||
claim_passed = checkClaim(irc, channel, numeric)
|
claim_passed = checkClaim(irc, channel, numeric)
|
||||||
current_chandata = irc.channels[channel]
|
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: 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: old channel data %s', irc.name, chandata)
|
||||||
log.debug('(%s) relay.handle_join: current channel data %s', irc.name, current_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):
|
if utils.isChannel(target):
|
||||||
# Use the old state of the channel to check for CLAIM access.
|
# 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):
|
if checkClaim(irc, target, numeric, chanobj=oldchan):
|
||||||
remotechan = getRemoteChan(irc, remoteirc, target)
|
remotechan = getRemoteChan(irc, remoteirc, target)
|
||||||
|
@ -560,7 +560,7 @@ class ClientbotWrapperProtocol(Protocol):
|
|||||||
if self.irc.isInternalClient(target):
|
if self.irc.isInternalClient(target):
|
||||||
log.debug('(%s) Suppressing MODE change hook for internal client %s', self.irc.name, target)
|
log.debug('(%s) Suppressing MODE change hook for internal client %s', self.irc.name, target)
|
||||||
return
|
return
|
||||||
return {'target': target, 'modes': changedmodes, 'chandata': oldobj}
|
return {'target': target, 'modes': changedmodes, 'channeldata': oldobj}
|
||||||
|
|
||||||
def handle_nick(self, source, command, args):
|
def handle_nick(self, source, command, args):
|
||||||
"""Handles NICK changes."""
|
"""Handles NICK changes."""
|
||||||
|
@ -556,7 +556,7 @@ class InspIRCdProtocol(TS6BaseProtocol):
|
|||||||
self.updateTS(servernumeric, channel, their_ts, changedmodes)
|
self.updateTS(servernumeric, channel, their_ts, changedmodes)
|
||||||
|
|
||||||
return {'channel': channel, 'users': namelist, 'modes': parsedmodes, 'ts': their_ts,
|
return {'channel': channel, 'users': namelist, 'modes': parsedmodes, 'ts': their_ts,
|
||||||
'chandata': chandata}
|
'channeldata': chandata}
|
||||||
|
|
||||||
def handle_uid(self, numeric, command, args):
|
def handle_uid(self, numeric, command, args):
|
||||||
"""Handles incoming UID commands (user introduction)."""
|
"""Handles incoming UID commands (user introduction)."""
|
||||||
|
@ -1072,7 +1072,7 @@ class P10Protocol(IRCS2SProtocol):
|
|||||||
self.updateTS(source, channel, their_ts, changedmodes)
|
self.updateTS(source, channel, their_ts, changedmodes)
|
||||||
|
|
||||||
return {'channel': channel, 'users': namelist, 'modes': parsedmodes, 'ts': their_ts,
|
return {'channel': channel, 'users': namelist, 'modes': parsedmodes, 'ts': their_ts,
|
||||||
'chandata': chandata}
|
'channeldata': chandata}
|
||||||
|
|
||||||
def handle_join(self, source, command, args):
|
def handle_join(self, source, command, args):
|
||||||
"""Handles incoming JOINs and channel creations."""
|
"""Handles incoming JOINs and channel creations."""
|
||||||
|
@ -467,7 +467,7 @@ class TS6Protocol(TS6BaseProtocol):
|
|||||||
self.updateTS(servernumeric, channel, their_ts, changedmodes)
|
self.updateTS(servernumeric, channel, their_ts, changedmodes)
|
||||||
|
|
||||||
return {'channel': channel, 'users': namelist, 'modes': parsedmodes, 'ts': their_ts,
|
return {'channel': channel, 'users': namelist, 'modes': parsedmodes, 'ts': their_ts,
|
||||||
'chandata': chandata}
|
'channeldata': chandata}
|
||||||
|
|
||||||
def handle_join(self, numeric, command, args):
|
def handle_join(self, numeric, command, args):
|
||||||
"""Handles incoming channel JOINs."""
|
"""Handles incoming channel JOINs."""
|
||||||
|
@ -585,7 +585,7 @@ class UnrealProtocol(TS6BaseProtocol):
|
|||||||
self.updateTS(numeric, channel, their_ts, changedmodes)
|
self.updateTS(numeric, channel, their_ts, changedmodes)
|
||||||
|
|
||||||
return {'channel': channel, 'users': namelist, 'modes': self.irc.channels[channel].modes,
|
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):
|
def handle_nick(self, numeric, command, args):
|
||||||
"""Handles NICK changes, and legacy NICK introductions from pre-4.0 servers."""
|
"""Handles NICK changes, and legacy NICK introductions from pre-4.0 servers."""
|
||||||
@ -662,7 +662,7 @@ class UnrealProtocol(TS6BaseProtocol):
|
|||||||
their_ts = int(args[-1])
|
their_ts = int(args[-1])
|
||||||
if their_ts > 0:
|
if their_ts > 0:
|
||||||
self.updateTS(numeric, channel, their_ts)
|
self.updateTS(numeric, channel, their_ts)
|
||||||
return {'target': channel, 'modes': parsedmodes, 'chandata': oldobj}
|
return {'target': channel, 'modes': parsedmodes, 'channeldata': oldobj}
|
||||||
else:
|
else:
|
||||||
log.warning("(%s) received MODE for non-channel target: %r",
|
log.warning("(%s) received MODE for non-channel target: %r",
|
||||||
self.irc.name, args)
|
self.irc.name, args)
|
||||||
|
Loading…
Reference in New Issue
Block a user