Libraryless. Click here for Pure Java version (1406L/9K/30K).
!752 static class Bot { S id; // always formatted boolean enabled, always; } answer { if (matchStart("askall", s, m)) { s = m.rest().trim(); Map<S, S> answers = getAllAnswers(s); ret "Answers: " + structure(answers); } if (matchStart("combine", s, m)) { s = m.rest().trim(); Map<S, S> answers = getAllAnswers(s); ret combineAnswers(answers); } } static S combineAnswers(Map<S, S> answers) { new TreeSet<S> set; for (S s : values(answers)) if (!isDunno(s)) set.add(s); ret "Actual answers: " + structure(set); } static boolean isDunno(S s) { ret matchStart("dunno", s) || matchStart("i don't know", s); } // map: bot id -> answer static Map<S, S> getAllAnswers(S s) { O dispatcher = call(getMainBot(), "getDispatcher"); L bots = cast call(dispatcher, "getSubBots"); new Map<S, S> map; for (int i = 0; i < l(bots); i++) pcall { Bot bot = (Bot) restructure(bots.get(i)); if (!bot.enabled) continue; if (sameSnippetID(bot.id, getProgramID())) continue; // skip myself to be safe Class c = cast call(dispatcher, "getClassOfSubBot", bot.id); if (c != null) { S a = callStaticAnswerMethod(c, s); if (!empty(a)) map.put(formatSnippetID(bot.id), a); } } ret map; }
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment