add ability to gather help text

pull/38/head
Mallory Hancock 2018-11-02 13:09:34 -07:00
parent 7d0844e156
commit 1af36c86f6
2 changed files with 8 additions and 5 deletions

View File

@ -162,7 +162,7 @@ class Bot(irc.bot.SingleServerIRCBot):
output = None
if cmd in pinhook.plugin.cmds:
try:
output = pinhook.plugin.cmds[cmd](self.Message(
output = pinhook.plugin.cmds[cmd]['run'](self.Message(
channel=chan,
cmd=cmd,
nick_list=nick_list,

View File

@ -30,8 +30,11 @@ def message(msg):
return Output(OutputType.Message, msg)
def _add_plugin(command, func):
cmds[command] = func
def _add_plugin(command, help_text, func):
cmds[command] = {
'run': func,
'help': help_text
}
def _add_listener(name, func):
@ -43,9 +46,9 @@ def clear_plugins():
lstnrs.clear()
def register(command):
def register(command, help_text=None):
def register_for_command(func):
_add_plugin(command, func)
_add_plugin(command, help_text, func)
return func
return register_for_command