Libraryless. Click here for Pure Java version (1511L/10K/36K).
// Bot Ref Bot knows which bots are online on some machine. !747 m { static int interval = 4000; static L<ProgramScan.Program> bots = new ArrayList<ProgramScan.Program>(); p { makeAndroid3("Bot Ref Bot."); while (true) { scan(); sleep(interval); } } static void scan() { setBots(quickBotScan()); } static synchronized void setBots(L<ProgramScan.Program> l) { bots = l; } // returned list is thread-safe (immutable even) static synchronized L<ProgramScan.Program> getBots() { ret bots; } static synchronized S answer(S s, L<S> history) { new Matches m; if (match3("please forward to bot *: *", s, m)) { S bot = m.unq(0); S line = m.unq(1); DialogIO io = findBotFromList(bot); if (io != null) { S hello = io.readLine(); if (startsWithIgnoreCase(hello, bot)) { io.sendLine(line); S answer = io.readLine(); io.close(); ret answer; } } // default case print("not in list, fallback"); ret sendToLocalBot(bot, line); // TODO: keep connections } ret useQuestionBot(s, history); } static S useQuestionBot(S s, L<S> history) { ret sendToLocalBot("Questions Bot", "how can question * to bot * be answered?", s, getProgramID()); } static DialogIO findBotFromList(S botName) { for (ProgramScan.Program p : getBots()) if (startsWithIgnoreCase(p.helloString, botName)) ret talkTo(p.port); ret null; } }
download show line numbers debug dex old transpilations
Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, teubizvjbppd, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment