diff options
Diffstat (limited to 'alfred/help.py')
| -rw-r--r-- | alfred/help.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/alfred/help.py b/alfred/help.py new file mode 100644 index 0000000..606c8dd --- /dev/null +++ b/alfred/help.py @@ -0,0 +1,31 @@ +""" +Sopel plugin: help system for alfred + + !help - list topics + !help <topic> - list commands for a topic + !help <topic> <cmd> - description and usage for a command + +Topics: srv, bot, files, irc, coffee +""" + +from sopel import plugin +import os as _os, sys as _sys +_alfred_dir = _os.path.dirname(_os.path.abspath(__file__)) +if _alfred_dir not in _sys.path: + _sys.path.insert(0, _alfred_dir) +import helpstrings as h + +def _is_owner(bot, trigger): + return trigger.nick == bot.settings.core.owner + + +@plugin.command("help") +def cmd_help(bot, trigger): + if not _is_owner(bot, trigger): + return + args = (trigger.group(2) or "").split() + result = h.lookup(args) + if result: + bot.notice(result, trigger.nick) + else: + bot.notice(f"no help for '{' '.join(args)}'. {h.TOPICS}", trigger.nick) |
