sclass BakedBot { VirtualMechLists lists = new SimpleMechLists; Class bot; int goodTests, badTests; static S defaultSnippetID = #1017706; S snippetID = defaultSnippetID; *(VirtualMechLists *lists) { _init(); } *() { _init(); } void _init { bot = hotwireDependentSharingClasses(snippetID, VirtualMechLists); setOpt(bot, mechLibID := null); setOpt(bot, makeAndroid3_disable := true); //lists.verbose = true; setLists(lists); runMain(bot); } S answer(S s) { ret unnull(callAnswerMethod(bot, s)); } S answer_verbose(S s) { ret print("< ", answer(print("> ", s))); } S check(S input, S expectedOutput) { ret assertEqualsVerbose_match(unnull(expectedOutput), answer(print("> ", input))); } bool pcheck(S input, S expectedOutput) { pcall-short { check(input, expectedOutput); ++goodTests; true; } ++badTests; false; } bool pcheckOrPrintLog(S input, S expectedOutput) { if (pcheck(input, expectedOutput)) true; ret false with printLines((LS) getOpt(getBot('TelegramFactsBot), 'checkingLog)); } void setList(S name, S text) { lists.setText(name, text); } S getList(S name) { ret lists.mL_raw(name); } void setAuthorized(bool b) { setOpt(bot, authorized := b); } S answerAuthed(S s) { final bool authedOld = isTrue(getOpt(bot, 'authorized)); setAuthorized(true); tempAfterwards(r { setAuthorized(authedOld); }); ret answer(s); } void setLists(VirtualMechLists lists) { this.lists = lists; setAll(callOpt(bot, 'mechMode), readMode := lists, writeMode := lists); } O getBot(S shortClassName) { ret firstWithShortClassName((L) get(bot, 'bots), shortClassName); } void cleanMeUp { cleanUp(bot); bot = null; } O factsBot() { ret getBot('TelegramFactsBot); } void addFact(S fact) { if (!contains(lines(lists.mL_raw("Random facts")), fact)) lists.append("Random facts", fact); } void printTestStats { print("\nGood tests: " + goodTests + ", bad tests: " + badTests + "\n"); } void imagineMode() { set(factsBot(), imagineMode := true); } Collection imaginedFacts() { ret (Collection) get(factsBot(), 'imaginedFacts); } void useIterate(bool useIterate) { set(factsBot(), +useIterate); } void useDiskCache(bool useDiskCache) { setOpt(bot, transpileRaw_useDiskCache := useDiskCache); } void debug(bool debug) { set(factsBot(), +debug); } void setRules(S rules) { if (lists cast SimpleMechLists) lists.setText("NL Logic Examples", rules); } }