aboutsummaryrefslogtreecommitdiffstats
path: root/alfred/help.py
blob: 606c8dd3517ecde08c13b77e964a2fe41126fb5f (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
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)