.help lists aliases
This commit is contained in:
parent
09a4f03f4c
commit
902a57c911
16
bot.py
16
bot.py
|
@ -128,13 +128,15 @@ class Fulvia(irc.IRCClient):
|
|||
for func in callables:
|
||||
if hasattr(func, 'commands'):
|
||||
self._callables[func.__name__] = func
|
||||
for command in func.commands:
|
||||
self.commands[command] = tools.Command(command)
|
||||
self.commands[command]._func_name = func.__name__
|
||||
self.commands[command].priv = func.priv
|
||||
self.commands[command].doc = func._docs
|
||||
if command in func.aliases:
|
||||
self.commands[command].alias = True
|
||||
for cmd in func.commands:
|
||||
self.commands[cmd] = tools.Command(cmd)
|
||||
self.commands[cmd]._func_name = func.__name__
|
||||
self.commands[cmd].priv = func.priv
|
||||
self.commands[cmd].doc = func._docs
|
||||
if cmd in func.aliases:
|
||||
self.commands[cmd].canonical = False
|
||||
aliases = [a for a in func.commands if a != cmd]
|
||||
self.commands[cmd].aliases = aliases
|
||||
|
||||
if func.hook:
|
||||
self._callables[func.__name__] = func
|
||||
|
|
|
@ -16,16 +16,18 @@ def help(bot, trigger):
|
|||
name = name.lower()
|
||||
if name not in bot.commands:
|
||||
return
|
||||
doc = bot.commands[name].doc
|
||||
docstring, examples = doc
|
||||
cmd = bot.commands[name]
|
||||
docstring, examples = cmd.doc
|
||||
if examples:
|
||||
ex = random.choice(examples)
|
||||
|
||||
bot.msg(docstring)
|
||||
if cmd.aliases:
|
||||
bot.msg("Aliases: " + ", ".join(cmd.aliases))
|
||||
if ex[0]:
|
||||
bot.msg("Ex. In: " + ex[0])
|
||||
if ex[1]:
|
||||
bot.msg("Ex. Out: " + ex[1])
|
||||
if ex[1]:
|
||||
bot.msg("Ex. Out: " + ex[1])
|
||||
|
||||
else:
|
||||
if trigger.owner:
|
||||
|
@ -35,7 +37,7 @@ def help(bot, trigger):
|
|||
else:
|
||||
cmds = [cmd for _, cmd in bot.commands.items() if cmd.priv < 5]
|
||||
|
||||
cmds = [cmd.name for cmd in cmds if not cmd.alias]
|
||||
cmds = [cmd.name for cmd in cmds if cmd.canonical]
|
||||
cmds = sorted(cmds)
|
||||
msg = "Available commands: " + ", ".join(cmds)
|
||||
bot.msg(msg)
|
||||
|
|
|
@ -142,7 +142,8 @@ class Command():
|
|||
self._func_name = ""
|
||||
self.priv = 0
|
||||
self.doc = None
|
||||
self.alias = False
|
||||
self.canonical = True
|
||||
self.aliases = []
|
||||
|
||||
|
||||
def configureHostMask(mask):
|
||||
|
|
Loading…
Reference in New Issue
Block a user