!7 concept Config { new L bots; // contains program IDs } static new L> bots; // pair(program ID, main class) p { db(); loadBots(); botSleep(); } svoid loadBots { cleanUpAndClear(bots); for (S bot : config().bots) bots.add(pair(bot, runSubBot(bot))); } answer { lock dbLock(); if "add bot *" { S id = formatSnippetID($1); config().bots.remove(id); config().bots.add(0, id); loadBots(); ret "OK"; } if "remove bot *" { S id = formatSnippetID($1); config().bots.remove(id); loadBots(); ret "OK"; } if "list bots" ret structForUser(config().bots); try answer scanMultipleBots(map(f second, bots), s); } static Config config() { ret uniq_sync(Config); } static Class runSubBot(S id) { Class c = hotwire(id); setOpt(c, 'sleep_noSleep, true); try { callMain(c); } catch e { if (!eq(getInnerMessage(e), "nosleep")) printStackTrace(e); } ret c; }