diff options
Diffstat (limited to 'osterman/helpstrings.py')
| -rw-r--r-- | osterman/helpstrings.py | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/osterman/helpstrings.py b/osterman/helpstrings.py new file mode 100644 index 0000000..31ee7d1 --- /dev/null +++ b/osterman/helpstrings.py @@ -0,0 +1,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) |
