add ability to gather help text (#38)

pull/40/head
Mal Hancock 2018-11-02 13:53:04 -07:00 committed by GitHub
parent 7d0844e156
commit 1523cfaf3a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 5 deletions

View File

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

View File

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