aboutsummaryrefslogtreecommitdiffstats
path: root/osterman/help.py
blob: fdc94c0cc81ad804cbcd1feca834fc6fd9cc3696 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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}")