!752 static Class receivingBot; static int delay = 3000; // fast // 10000; static boolean keepPreSpunVM = false; static new L acceptedProgramIDs; // none unless you change it p { readLocally("acceptedProgramIDs"); makeAndroid3("Accept incoming bots bot."); if (keepPreSpunVM) runInNewThread("#1001379"); while (true) { pcall { doIt(); } sleep(delay); } } static void doIt() { S answer = sendToRemoteBot("Identity Manager", format3("Who is moving to * (full state)", getComputerID())); print(answer); processIncoming(answer); } static synchronized void processIncoming(S answer) { for (DynamicObject state : (L) unstructure(answer)) { print("State: " + structure(state)); S botID = cast state.fieldValues.get("id"); S dataID = cast state.fieldValues.get("dataID"); if (!acceptedProgramIDs.contains(formatSnippetID(botID))) { print("Rejecting bot " + botID + "."); print(sendToRemoteBot("Identity Manager", format3("* is now in state *", botID, "rejected"))); continue; } else print("OK, accepting bot " + botID + " as per white list."); try { if (receivingBot == null) receivingBot = hotwire("#1001337"); answer = (S) call(receivingBot, "doIt", botID, dataID); print(answer); if (!match3("All done.", answer)) continue; print(sendToRemoteBot("Identity Manager", format3("* is now in state *", botID, "residing"))); } catch (Throwable e) { e.printStackTrace(); print(sendToRemoteBot("Identity Manager", format3("* is now in state *", botID, "error: " + getStackTrace(e)))); } } } static synchronized S answer(S s, L history) { new Matches m; if (match3("please accept bot * from now on", s, m)) { S id = formatSnippetID(unquote(m.m[0])); if (!acceptedProgramIDs.contains(id)) { acceptedProgramIDs.add(id); saveLocally("acceptedProgramIDs"); } ret "OK."; } if (match3("please reject bot * from now on", s, m)) { S id = formatSnippetID(unquote(m.m[0])); acceptedProgramIDs.remove(id); saveLocally("acceptedProgramIDs"); ret "OK."; } if (match3("would you accept bot *?", s, m)) { S id = formatSnippetID(unquote(m.m[0])); return acceptedProgramIDs.contains(id) ? "Yes." : "No."; } if (match3("show white list", s)) return structure(acceptedProgramIDs); ret null; }