mirror of
				https://github.com/jlu5/PyLink.git
				synced 2025-11-04 08:57:25 +01:00 
			
		
		
		
	utils: return the bound function in add_cmd/add_hook
TODO: allow utils.add_cmd/add_hook to be called as a decorator WITH a name argument
This commit is contained in:
		
							parent
							
								
									cecb7f3800
								
							
						
					
					
						commit
						b3ab604b88
					
				
							
								
								
									
										5
									
								
								utils.py
									
									
									
									
									
								
							
							
						
						
									
										5
									
								
								utils.py
									
									
									
									
									
								
							@ -104,15 +104,18 @@ class TS6SIDGenerator():
 | 
			
		||||
        return sid
 | 
			
		||||
 | 
			
		||||
def add_cmd(func, name=None):
 | 
			
		||||
    """Binds a command to the given command name."""
 | 
			
		||||
    if name is None:
 | 
			
		||||
        name = func.__name__
 | 
			
		||||
    name = name.lower()
 | 
			
		||||
    world.commands[name].append(func)
 | 
			
		||||
    return func
 | 
			
		||||
 | 
			
		||||
def add_hook(func, command):
 | 
			
		||||
    """Add a hook <func> for command <command>."""
 | 
			
		||||
    """Binds a hook function to the given command."""
 | 
			
		||||
    command = command.upper()
 | 
			
		||||
    world.hooks[command].append(func)
 | 
			
		||||
    return func
 | 
			
		||||
 | 
			
		||||
def toLower(irc, text):
 | 
			
		||||
    """Returns a lowercase representation of text based on the IRC object's
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user