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

ts6: fix the broken mess of a JOIN handler, and 'parse_as' handling in irc.callHooks...

This commit is contained in:
James Lu 2015-07-25 20:43:26 -07:00
parent 1ab8db8069
commit ddefd38591
2 changed files with 8 additions and 6 deletions

View File

@ -155,9 +155,9 @@ class Irc():
# Handlers can return a 'parse_as' key to send their payload to a # Handlers can return a 'parse_as' key to send their payload to a
# different hook. An example of this is "/join 0" being interpreted # different hook. An example of this is "/join 0" being interpreted
# as leaving all channels (PART). # as leaving all channels (PART).
command = parsed_args.get('parse_as') or command
if command in hook_map: if command in hook_map:
hook_cmd = hook_map[command] hook_cmd = hook_map[command]
hook_cmd = parsed_args.get('parse_as') or hook_cmd
log.debug('Parsed args %r received from %s handler (calling hook %s)', parsed_args, command, hook_cmd) log.debug('Parsed args %r received from %s handler (calling hook %s)', parsed_args, command, hook_cmd)
# Iterate over hooked functions, catching errors accordingly # Iterate over hooked functions, catching errors accordingly
for hook_func in utils.command_hooks[hook_cmd]: for hook_func in utils.command_hooks[hook_cmd]:

View File

@ -342,10 +342,12 @@ def handle_join(irc, numeric, command, args):
ts = int(args[0]) ts = int(args[0])
if args[0] == '0': if args[0] == '0':
# /join 0; part the user from all channels # /join 0; part the user from all channels
oldchans = list(irc.users[numeric].channels) oldchans = irc.users[numeric].channels.copy()
for channel in irc.users[numeric].channels: log.debug('(%s) Got /join 0 from %r, channel list is %r',
irc.channels[channel].discard(numeric) irc.name, numeric, oldchans)
irc.users[numeric].channels = set() for channel in oldchans:
irc.channels[channel].users.discard(numeric)
irc.users[numeric].channels.discard(channel)
return {'channels': oldchans, 'text': 'Left all channels.', 'parse_as': 'PART'} return {'channels': oldchans, 'text': 'Left all channels.', 'parse_as': 'PART'}
else: else:
channel = args[1].lower() channel = args[1].lower()
@ -356,7 +358,7 @@ def handle_join(irc, numeric, command, args):
irc.name, channel, ts, our_ts) irc.name, channel, ts, our_ts)
irc.channels[channel].ts = ts irc.channels[channel].ts = ts
irc.channels[channel].users.add(numeric) irc.channels[channel].users.add(numeric)
irc.users[numeric].channels.add(numeric) irc.users[numeric].channels.add(channel)
# We send users and modes here because SJOIN and JOIN both use one hook, # We send users and modes here because SJOIN and JOIN both use one hook,
# for simplicity's sake (with plugins). # for simplicity's sake (with plugins).
return {'channel': channel, 'users': [numeric], 'modes': return {'channel': channel, 'users': [numeric], 'modes':