!7 sS regexpActivator = "."; // always !include once #1017764 // VirtualMechLists sS mechLibID = #1400124; static O onOutput; // VF1 static bool authorized; sS msgGlobalID; static L bots; abstract sclass AbstractThinkBot { transient VF1 postMessage; transient new L recentHistory; abstract void thinkAbout(S input); void postMessage(S s) { callF(postMessage, s); } JComponent visualize() { ret jpanel(); } } p { mech_useLibrary(mechLibID); L> classes = botClasses(); print("Have think classes: " + classNames(classes)); makeBots(); bot(); } static L> botClasses() { ret myNonAbstractClassesImplementing(AbstractThinkBot); } svoid makeBots() { bots = map nuWithoutArguments(botClasses()); } sbool telegram_amIAuthorized() { ret authorized; } svoid setMsgGlobalID(S globalID) { msgGlobalID = globalID; } sS answer(S s) { temp tempSetThreadLocal(telegram_msg_tl(), litorderedmap(globalID := msgGlobalID)); msgGlobalID = null; final new L output; for (AbstractThinkBot bot : bots) pcall { bot.postMessage = voidfunc(S s) { print(">> " + s); pcallF(onOutput, s); output.add(s); }; bot.thinkAbout(s); } ret rtrim(lines(output)); } svoid setDebug(bool b) { for (O bot : unnull(bots)) setOpt(bot, debug := b); }