Libraryless. Click here for Pure Java version (2532L/17K/56K).
!752 static Class receivingBot; static int delay = 3000; // fast // 10000; static boolean keepPreSpunVM = false; static new L<S> 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<DynamicObject>) 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<S> 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; }
Began life as a copy of #1001357
download show line numbers debug dex old transpilations
Travelled to 16 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, dhtvkmknsjym, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, teubizvjbppd, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1001385 |
Snippet name: | Accept incoming bots bot (with white list) |
Eternal ID of this version: | #1001385/1 |
Text MD5: | 637cce1e264c128b4fdfce69b6543bdf |
Transpilation MD5: | 74304e3e82e23792d6d8eee08b919f16 |
Author: | stefan |
Category: | javax |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2016-05-17 13:53:12 |
Source code size: | 2553 bytes / 88 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 656 / 810 |
Referenced in: | [show references] |