Libraryless. Click here for Pure Java version (1106L/8K/24K).
!759 // Should be an "always" bot so it notices mode changes. static new HashMap<S, Long> on; // dialog ID -> start time static long timeout = 5*60*1000; // 5 minutes static L<S> nastyStuff = toLinesFullTrim([[ Go away! What do you want? I DON'T KNOW I AM BORED Do it yourself! I'm not your bitch! Leave me alone! You annoy me!! ]]); synchronized static S answer(S s) { S dialog = getDialogID(); //printF("nasty: * *", dialog, s); if (match("mode nasty", s) || match("nasty mode", s)) { print("Nasty on: " + getDialogID()); on.put(dialog, now()); } else if (isNasty() && (match("mode *", s) || match("* mode", s) || match("help", s) || match("exit", s) || match("stop", s))) { print("Nasty off: " + dialog); on.remove(dialog); ret "OK, exiting nasty mode."; } else if (match("mode", s) && isNasty()) ret "I'm in " + quote("nasty") + " mode (" + formatSnippetID(getProgramID()) + ")"; if (!isNasty()) null; ret randomElement(nastyStuff); } static boolean isNasty() { cleanUpMap(); ret on.containsKey(getDialogID()); } // remove the expired entries static void cleanUpMap() { new HashMap<S, Long> newMap; for (S dialogID : keys(on)) { long time = on.get(dialogID); if (!isExpired(time, timeout)) newMap.put(dialogID, time); } on = newMap; }
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment