aboutsummaryrefslogtreecommitdiffstats
path: root/alfred/helpstrings.py
blob: 90c7dbb37ce074652aac8f1fa8d9292e26e259f8 (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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
TOPICS = "topics: srv, bot, files, irc, coffee, vpn, list, git. type !help <topic> for details"

SRV_TOPIC = "srv: uptime disk mem load status net top topmem io conns who logs. type !help srv <cmd> for details"
SRV = {
    "uptime": "srv uptime: system uptime and load averages. usage: !srv uptime",
    "disk":   "srv disk: disk usage for root. usage: !srv disk",
    "mem":    "srv mem: RAM and swap usage. usage: !srv mem",
    "load":   "srv load: 1 5 15 min load averages and process count. usage: !srv load",
    "status": "srv status: rc-service status, all or one. usage: !srv status or !srv status service",
    "net":    "srv net: RX TX bytes for a network interface. usage: !srv net or !srv net iface",
    "top":    "srv top: top n processes by CPU. usage: !srv top or !srv top n",
    "topmem": "srv topmem: top n processes by memory. usage: !srv topmem or !srv topmem n",
    "io":     "srv io: disk read write stats for the main block device. usage: !srv io",
    "conns":  "srv conns: TCP connection summary. usage: !srv conns",
    "who":    "srv who: currently logged-in users. usage: !srv who",
    "logs":   "srv logs: last n lines from a service log. usage: !srv logs service or !srv logs service n",
}

BOT_TOPIC = "bot: list, all, name start stop restart status. type !help bot <cmd> for details"
BOT = {
    "list": "bot list: show all managed bots and their running state. usage: !bot list",
    "all":  "bot all: control all bots at once. usage: !bot all start or stop or restart",
}
BOT_NAME = "bot name: control or check a specific bot. usage: !bot name start or stop or restart or status"

FILES_TOPIC = "files: stats list shorten mirror prune vscan remove. type !help files <cmd> for details"
FILES = {
    "stats":   "files stats: live permanent removed count and total size. usage: !files stats",
    "list":    "files list: last n uploads with name size and expiry. usage: !files list or !files list n",
    "shorten": "files shorten: shorten a URL. usage: !files shorten url or !files shorten url wkfo or gumx",
    "mirror":  "files mirror: mirror a remote URL into this instance. usage: !files mirror url or !files mirror url wkfo or gumx",
    "prune":   "files prune: delete all expired files from disk. usage: !files prune",
    "vscan":   "files vscan: run ClamAV scan on all stored files. usage: !files vscan",
    "remove":  "files remove: permanently delete a file by filename. usage: !files remove filename",
}

IRC_TOPIC = "irc: user net bouncer notice. type !help irc <cmd> for details"
IRC = {
    "user":    "irc user: list, add nick pass, remove nick, passwd nick pass, enable nick, disable nick. usage: !irc user sub",
    "net":     "irc net: list user, status user, add user name, add user name addr, remove user name, quote user net cmd, presets. usage: !irc net sub",
    "bouncer": "irc bouncer: show bouncer-wide stats and status. usage: !irc bouncer",
    "notice":  "irc notice: broadcast a notice to all bouncer users. usage: !irc notice message",
}

COFFEE_TOPIC = "coffee: stats n +n -n yes no. type !help coffee <cmd> for details"
COFFEE = {
    "stats": "coffee stats: today cups, 7-day chart, streak, all-time average. usage: !coffee stats",
    "n":     "coffee n: set cup count for today or a past date. usage: !coffee n or !coffee n yyyy-mm-dd",
    "+n":    "coffee +n: add cups, warns if over 5. usage: !coffee +n or !coffee +n yyyy-mm-dd",
    "-n":    "coffee -n: remove cups, warns if hitting 0. usage: !coffee -n or !coffee -n yyyy-mm-dd",
    "yes":   "coffee yes or no: confirm or cancel a pending change. usage: !coffee yes or !coffee no",
    "no":    "coffee yes or no: confirm or cancel a pending change. usage: !coffee yes or !coffee no",
}

VPN_TOPIC = "vpn: pubkey list add remove. type !help vpn <cmd> for details"
VPN = {
    "pubkey": "vpn pubkey: print the WireGuard server public key. usage: !vpn pubkey",
    "list":   "vpn list: list all peers with IP and pubkey. usage: !vpn list",
    "add":    "vpn add: add a peer, returns assigned IP and client config URL. usage: !vpn add name pubkey",
    "remove": "vpn remove: remove a peer live and from wg0.conf. usage: !vpn remove name",
}

LIST_TOPIC = "list: members subscribe unsubscribe send. type !help list <cmd> for details"
LIST = {
    "members":     "list members: show all subscribers. usage: !list members",
    "subscribe":   "list subscribe: subscribe an address. usage: !list subscribe email",
    "unsubscribe": "list unsubscribe: unsubscribe an address. usage: !list unsubscribe email",
    "send":        "list send: send a message to the list. usage: !list send message",
}

GIT_TOPIC = "git: list desc hook remove. type !help git <cmd> for details"
GIT = {
    "list":   "git list: list all repos with last commit time and description. usage: !git list",
    "desc":   "git desc: set a repo description. usage: !git desc repo text",
    "hook":   "git hook: install a post-receive hook template. usage: !git hook repo type",
    "remove": "git remove: remove a repo, prompts for confirmation. usage: !git remove repo",
}

TOPIC_MAP = {
    "srv":    (SRV_TOPIC,    SRV),
    "bot":    (BOT_TOPIC,    BOT),
    "files":  (FILES_TOPIC,  FILES),
    "irc":    (IRC_TOPIC,    IRC),
    "coffee": (COFFEE_TOPIC, COFFEE),
    "vpn":    (VPN_TOPIC,    VPN),
    "list":   (LIST_TOPIC,   LIST),
    "git":    (GIT_TOPIC,    GIT),
}

_ALL = {**SRV, **BOT, **FILES, **IRC, **COFFEE, **VPN, **LIST, **GIT}


def lookup(args):
    if not args:
        return TOPICS
    first = args[0].lower()
    if first in TOPIC_MAP:
        if len(args) == 1:
            return TOPIC_MAP[first][0]
        cmd    = args[1].lower()
        result = TOPIC_MAP[first][1].get(cmd)
        if result is None and first == "bot":
            return BOT_NAME
        return result
    return _ALL.get(first)