.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:
|
for func in callables:
|
||||||
if hasattr(func, 'commands'):
|
if hasattr(func, 'commands'):
|
||||||
self._callables[func.__name__] = func
|
self._callables[func.__name__] = func
|
||||||
for command in func.commands:
|
for cmd in func.commands:
|
||||||
self.commands[command] = tools.Command(command)
|
self.commands[cmd] = tools.Command(cmd)
|
||||||
self.commands[command]._func_name = func.__name__
|
self.commands[cmd]._func_name = func.__name__
|
||||||
self.commands[command].priv = func.priv
|
self.commands[cmd].priv = func.priv
|
||||||
self.commands[command].doc = func._docs
|
self.commands[cmd].doc = func._docs
|
||||||
if command in func.aliases:
|
if cmd in func.aliases:
|
||||||
self.commands[command].alias = True
|
self.commands[cmd].canonical = False
|
||||||
|
aliases = [a for a in func.commands if a != cmd]
|
||||||
|
self.commands[cmd].aliases = aliases
|
||||||
|
|
||||||
if func.hook:
|
if func.hook:
|
||||||
self._callables[func.__name__] = func
|
self._callables[func.__name__] = func
|
||||||
|
|
|
@ -16,12 +16,14 @@ def help(bot, trigger):
|
||||||
name = name.lower()
|
name = name.lower()
|
||||||
if name not in bot.commands:
|
if name not in bot.commands:
|
||||||
return
|
return
|
||||||
doc = bot.commands[name].doc
|
cmd = bot.commands[name]
|
||||||
docstring, examples = doc
|
docstring, examples = cmd.doc
|
||||||
if examples:
|
if examples:
|
||||||
ex = random.choice(examples)
|
ex = random.choice(examples)
|
||||||
|
|
||||||
bot.msg(docstring)
|
bot.msg(docstring)
|
||||||
|
if cmd.aliases:
|
||||||
|
bot.msg("Aliases: " + ", ".join(cmd.aliases))
|
||||||
if ex[0]:
|
if ex[0]:
|
||||||
bot.msg("Ex. In: " + ex[0])
|
bot.msg("Ex. In: " + ex[0])
|
||||||
if ex[1]:
|
if ex[1]:
|
||||||
|
@ -35,7 +37,7 @@ def help(bot, trigger):
|
||||||
else:
|
else:
|
||||||
cmds = [cmd for _, cmd in bot.commands.items() if cmd.priv < 5]
|
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)
|
cmds = sorted(cmds)
|
||||||
msg = "Available commands: " + ", ".join(cmds)
|
msg = "Available commands: " + ", ".join(cmds)
|
||||||
bot.msg(msg)
|
bot.msg(msg)
|
||||||
|
|
|
@ -142,7 +142,8 @@ class Command():
|
||||||
self._func_name = ""
|
self._func_name = ""
|
||||||
self.priv = 0
|
self.priv = 0
|
||||||
self.doc = None
|
self.doc = None
|
||||||
self.alias = False
|
self.canonical = True
|
||||||
|
self.aliases = []
|
||||||
|
|
||||||
|
|
||||||
def configureHostMask(mask):
|
def configureHostMask(mask):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user