aboutsummaryrefslogtreecommitdiffstats
path: root/osterman/help.py
diff options
context:
space:
mode:
Diffstat (limited to 'osterman/help.py')
-rw-r--r--osterman/help.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/osterman/help.py b/osterman/help.py
new file mode 100644
index 0000000..fdc94c0
--- /dev/null
+++ b/osterman/help.py
@@ -0,0 +1,30 @@
+"""
+Sopel plugin: osterman help system
+
+ !help list topics
+ !help <topic> list commands for a topic
+ !help <topic> <cmd> description and usage for a command
+ !help <cmd> description and usage (topic not required)
+"""
+
+import os as _os, sys as _sys
+_osterman_dir = _os.path.dirname(_os.path.abspath(__file__))
+if _osterman_dir not in _sys.path:
+ _sys.path.insert(0, _osterman_dir)
+import helpstrings as h
+
+from sopel import plugin
+
+
+def _notice(bot, nick, text):
+ bot.notice(text, nick)
+
+
+@plugin.command("help", "h")
+def cmd_help(bot, trigger):
+ args = (trigger.group(2) or "").split()
+ result = h.lookup(args)
+ if result:
+ _notice(bot, trigger.nick, result)
+ else:
+ _notice(bot, trigger.nick, f"no help for '{' '.join(args)}'. {h.TOPICS}")