!759 // Should be an "always" bot so it notices mode changes. static new HashMap on; // dialog ID -> start time static long timeout = 5*60*1000; // 5 minutes static L 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 newMap; for (S dialogID : keys(on)) { long time = on.get(dialogID); if (!isExpired(time, timeout)) newMap.put(dialogID, time); } on = newMap; }