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
|
TOPICS = (
"topics (commands): "
"mod (kick, bankick, tempban, ban, unban, mute, unmute, voice, devoice, op, deop, halfop, dehalfop, lock, unlock), "
"config (autoop, autovoice, autohalfop, acl, whitelist, blacklist, except, filter, badword, set, config), "
"track (seen, info, log), "
"idle (idle, afk), "
"admin (join, part, chans). "
"type !help <topic> or !help <cmd> to know more"
)
MOD_TOPIC = "mod: kick, bankick, tempban, ban, unban, mute, unmute, voice, devoice, op, deop, halfop, dehalfop, lock, unlock. type !help <cmd> for usage"
CONFIG_TOPIC = "config: autoop, autovoice, autohalfop, acl, whitelist, blacklist, except, filter, badword, set, config. type !help <cmd> for usage"
TRACK_TOPIC = "track: seen, info, log. type !help <cmd> for usage"
IDLE_TOPIC = "idle: idle, afk. type !help <cmd> for usage"
ADMIN_TOPIC = "admin: join, part, chans. type !help <cmd> for usage"
MOD = {
"kick": "kick a user. usage: !kick <nick> [reason]",
"bankick": "ban and kick a user. usage: !bankick <nick|mask> [reason]",
"tempban": "timed ban and kick. usage: !tempban <nick|mask> <minutes> [reason]",
"ban": "ban and kick, or list bans. usage: !ban <nick|mask> [reason] | !ban list",
"unban": "remove a ban. usage: !unban <nick|mask>",
"mute": "silence a user (+q). usage: !mute <nick|mask>",
"unmute": "remove silence (-q). usage: !unmute <nick|mask>",
"voice": "give voice. usage: !voice <nick>",
"devoice": "remove voice. usage: !devoice <nick>",
"op": "give op. usage: !op <nick>",
"deop": "remove op. usage: !deop <nick>",
"halfop": "give halfop. usage: !halfop <nick>",
"dehalfop": "remove halfop. usage: !dehalfop <nick>",
"lock": "lock the channel. usage: !lock [m|i] (default: +mi)",
"unlock": "unlock the channel. usage: !unlock [m|i] (default: -mi)",
}
CONFIG = {
"autoop": "manage auto-op list for this channel. usage: !autoop <add|del|list> [nick|mask]",
"autovoice": "manage auto-voice list for this channel. usage: !autovoice <add|del|list> [nick|mask]",
"autohalfop": "manage auto-halfop list for this channel. usage: !autohalfop <add|del|list> [nick|mask]",
"acl": "manage trusted nicks (global). usage: !acl <add|del|list> [nick]",
"whitelist": "manage global protection bypass list. usage: !whitelist <add|del|list> [mask]",
"blacklist": "manage global ban list. usage: !blacklist <add|del|list> [nick|mask]",
"except": "manage per-channel protection bypass list. usage: !except <add|del|list> [mask]",
"filter": "manage regex content filters. usage: !filter <add|del|list> [pattern] (del uses index from list)",
"badword": "manage word block list. usage: !badword <add|del|list> [word] (del uses index from list)",
"set": "set a config key. usage: !set <key> <value> (in channel: per-channel; in PM: global)",
"config": "show channel config. usage: !config [#channel]",
}
TRACK = {
"seen": "show when a nick was last seen. usage: !seen <nick>",
"info": "show nick summary. usage: !info <nick>",
"log": "show recent events for a nick (ACL/owner only). usage: !log <nick> [limit]",
}
IDLE = {
"idle": "show idle time or toggle idle checking. usage: !idle <nick> | !idle <on|off>",
"afk": "reset your idle timer. usage: !afk",
}
ADMIN = {
"join": "join a channel. usage: !join <#channel>",
"part": "leave a channel. usage: !part [#channel]",
"chans": "list channels the bot is in. usage: !chans",
}
_ALL = {**MOD, **CONFIG, **TRACK, **IDLE, **ADMIN}
TOPIC_MAP = {
"mod": (MOD_TOPIC, MOD),
"config": (CONFIG_TOPIC, CONFIG),
"track": (TRACK_TOPIC, TRACK),
"idle": (IDLE_TOPIC, IDLE),
"admin": (ADMIN_TOPIC, ADMIN),
}
def lookup(args):
"""Return a help string for args (list of strings) or None if not found.
lookup([]) -> TOPICS
lookup(["mod"]) -> MOD_TOPIC
lookup(["kick"]) -> MOD["kick"]
lookup(["mod","kick"]) -> MOD["kick"]
"""
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()
return TOPIC_MAP[first][1].get(cmd)
return _ALL.get(first)
|