mirror of
				https://github.com/jlu5/PyLink.git
				synced 2025-11-04 00:47:21 +01:00 
			
		
		
		
	ts6: fix the broken mess of a JOIN handler, and 'parse_as' handling in irc.callHooks...
This commit is contained in:
		
							parent
							
								
									1ab8db8069
								
							
						
					
					
						commit
						ddefd38591
					
				
							
								
								
									
										2
									
								
								main.py
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								main.py
									
									
									
									
									
								
							@ -155,9 +155,9 @@ class Irc():
 | 
			
		||||
        # Handlers can return a 'parse_as' key to send their payload to a
 | 
			
		||||
        # different hook. An example of this is "/join 0" being interpreted
 | 
			
		||||
        # as leaving all channels (PART).
 | 
			
		||||
        command = parsed_args.get('parse_as') or command
 | 
			
		||||
        if command in hook_map:
 | 
			
		||||
            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)
 | 
			
		||||
        # Iterate over hooked functions, catching errors accordingly
 | 
			
		||||
        for hook_func in utils.command_hooks[hook_cmd]:
 | 
			
		||||
 | 
			
		||||
@ -342,10 +342,12 @@ def handle_join(irc, numeric, command, args):
 | 
			
		||||
    ts = int(args[0])
 | 
			
		||||
    if args[0] == '0':
 | 
			
		||||
        # /join 0; part the user from all channels
 | 
			
		||||
        oldchans = list(irc.users[numeric].channels)
 | 
			
		||||
        for channel in irc.users[numeric].channels:
 | 
			
		||||
            irc.channels[channel].discard(numeric)
 | 
			
		||||
        irc.users[numeric].channels = set()
 | 
			
		||||
        oldchans = irc.users[numeric].channels.copy()
 | 
			
		||||
        log.debug('(%s) Got /join 0 from %r, channel list is %r',
 | 
			
		||||
                  irc.name, numeric, oldchans)
 | 
			
		||||
        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'}
 | 
			
		||||
    else:
 | 
			
		||||
        channel = args[1].lower()
 | 
			
		||||
@ -356,7 +358,7 @@ def handle_join(irc, numeric, command, args):
 | 
			
		||||
                      irc.name, channel, ts, our_ts)
 | 
			
		||||
            irc.channels[channel].ts = ts
 | 
			
		||||
        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,
 | 
			
		||||
    # for simplicity's sake (with plugins).
 | 
			
		||||
    return {'channel': channel, 'users': [numeric], 'modes':
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user