TOPICS = "topics: srv, bot, files, irc, coffee, vpn, list, git, twt, feed. type !help for details" SRV_TOPIC = "srv: uptime disk mem load status net top topmem io conns who logs. type !help srv 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 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 remove. type !help files 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", "remove": "files remove: permanently delete a file by filename. usage: !files remove filename", } IRC_TOPIC = "irc: user net bouncer notice. type !help irc 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 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 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 ls rm. type !help list 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", "ls": "list ls: show latest n archive entries. usage: !list ls or !list ls n", "rm": "list rm: remove a message from the archive. usage: !list rm id", } GIT_TOPIC = "git: list desc hook remove. type !help git 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", } TWF_TOPIC = "twt: last [n] count delete yes no add users rm . type !help twt for details" TWF = { "last": "twt last: show last n twts, most recent first (default 5). usage: !twt last or !twt last n", "count": "twt count: total number of twts. usage: !twt count", "delete": "twt delete: delete the most recent twt, asks for confirmation. usage: !twt delete", "yes": "twt yes or no: confirm or cancel a pending delete. usage: !twt yes or !twt no", "no": "twt yes or no: confirm or cancel a pending delete. usage: !twt yes or !twt no", "add": "twt add: provision a wk.fo/twt user and add their token. usage: !twt add ", "users": "twt users: list all wk.fo/twt users. usage: !twt users", "rm": "twt rm: remove a wk.fo/twt user token (feed files kept). usage: !twt rm ", } FEED_TOPIC = "feed: refresh add list rm read. type !help feed for details" FEED = { "refresh": "feed refresh: regenerate feed.gumx.cc from all followed feeds. usage: !feed refresh", "add": "feed add: follow a feed. usage: !feed add [nick]", "list": "feed list: show all followed feeds. usage: !feed list", "rm": "feed rm: remove a feed by nick or url. usage: !feed rm ", "read": "feed read: set read point and regenerate. items after the date are new, before are old. usage: !feed read or !feed read yyyy-mm-dd", } 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), "twt": (TWF_TOPIC, TWF), "feed": (FEED_TOPIC, FEED), } _ALL = {**SRV, **BOT, **FILES, **IRC, **COFFEE, **VPN, **LIST, **GIT, **TWF, **FEED} 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)