mirror of
				https://github.com/jlu5/PyLink.git
				synced 2025-10-31 15:07:25 +01:00 
			
		
		
		
	ServiceBot: implement short form help for featured command lists
Suggestion from @cooper.
This commit is contained in:
		
							parent
							
								
									91a663d5c7
								
							
						
					
					
						commit
						d2b5fd7b6e
					
				
							
								
								
									
										15
									
								
								utils.py
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								utils.py
									
									
									
									
									
								
							| @ -255,7 +255,7 @@ class ServiceBot(): | ||||
|         self.commands[name].append(func) | ||||
|         return func | ||||
| 
 | ||||
|     def _show_command_help(self, irc, command, private=False): | ||||
|     def _show_command_help(self, irc, command, private=False, shortform=False): | ||||
|         """ | ||||
|         Shows help for the given command. | ||||
|         """ | ||||
| @ -281,9 +281,13 @@ class ServiceBot(): | ||||
|                     # Bold the first line, which usually just tells you what | ||||
|                     # arguments the command takes. | ||||
|                     lines[0] = '\x02%s %s\x02' % (command, lines[0]) | ||||
|                     for line in lines: | ||||
|                         # Then, just output the rest of the docstring to IRC. | ||||
|                         _reply(line.strip()) | ||||
| 
 | ||||
|                     if shortform:  # Short form is just the command name + args. | ||||
|                         _reply(lines[0].strip()) | ||||
|                     else: | ||||
|                         for line in lines: | ||||
|                             # Otherwise, just output the rest of the docstring to IRC. | ||||
|                             _reply(line.strip()) | ||||
|                 else: | ||||
|                     _reply("Error: Command %r doesn't offer any help." % command) | ||||
|                     return | ||||
| @ -336,8 +340,7 @@ class ServiceBot(): | ||||
|                     # Only show featured commands that are both defined and loaded. | ||||
|                     # TODO: perhaps plugin unload should remove unused featured command | ||||
|                     # definitions automatically? | ||||
|                     self.reply(irc, " ", private=True) | ||||
|                     self._show_command_help(irc, cmd, private=True) | ||||
|                     self._show_command_help(irc, cmd, private=True, shortform=True) | ||||
| 
 | ||||
| def registerService(name, *args, **kwargs): | ||||
|     """Registers a service bot.""" | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 James Lu
						James Lu