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 or !help to know more" ) MOD_TOPIC = "mod: kick, bankick, tempban, ban, unban, mute, unmute, voice, devoice, op, deop, halfop, dehalfop, lock, unlock. type !help for usage" CONFIG_TOPIC = "config: autoop, autovoice, autohalfop, acl, whitelist, blacklist, except, filter, badword, set, config. type !help for usage" TRACK_TOPIC = "track: seen, info, log. type !help for usage" IDLE_TOPIC = "idle: idle, afk. type !help for usage" ADMIN_TOPIC = "admin: join, part, chans. type !help for usage" MOD = { "kick": "kick a user. usage: !kick [reason]", "bankick": "ban and kick a user. usage: !bankick [reason]", "tempban": "timed ban and kick. usage: !tempban [reason]", "ban": "ban and kick, or list bans. usage: !ban [reason] | !ban list", "unban": "remove a ban. usage: !unban ", "mute": "silence a user (+q). usage: !mute ", "unmute": "remove silence (-q). usage: !unmute ", "voice": "give voice. usage: !voice ", "devoice": "remove voice. usage: !devoice ", "op": "give op. usage: !op ", "deop": "remove op. usage: !deop ", "halfop": "give halfop. usage: !halfop ", "dehalfop": "remove halfop. usage: !dehalfop ", "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 [nick|mask]", "autovoice": "manage auto-voice list for this channel. usage: !autovoice [nick|mask]", "autohalfop": "manage auto-halfop list for this channel. usage: !autohalfop [nick|mask]", "acl": "manage trusted nicks (global). usage: !acl [nick]", "whitelist": "manage global protection bypass list. usage: !whitelist [mask]", "blacklist": "manage global ban list. usage: !blacklist [nick|mask]", "except": "manage per-channel protection bypass list. usage: !except [mask]", "filter": "manage regex content filters. usage: !filter [pattern] (del uses index from list)", "badword": "manage word block list. usage: !badword [word] (del uses index from list)", "set": "set a config key. usage: !set (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 ", "info": "show nick summary. usage: !info ", "log": "show recent events for a nick (ACL/owner only). usage: !log [limit]", } IDLE = { "idle": "show idle time or toggle idle checking. usage: !idle | !idle ", "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)