!752 static class Bot { S id; // always formatted boolean enabled, always; } answer { if (matchStart("askall", s, m)) { s = m.rest().trim(); Map answers = getAllAnswers(s); ret "Answers: " + structure(answers); } if (matchStart("combine", s, m)) { s = m.rest().trim(); Map answers = getAllAnswers(s); ret combineAnswers(answers); } } static S combineAnswers(Map answers) { new TreeSet 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 getAllAnswers(S s) { O dispatcher = call(getMainBot(), "getDispatcher"); L bots = cast call(dispatcher, "getSubBots"); new Map 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; }