!7 cmodule LaughAboutJokes > DynPrintLogAndEnabled { long historical, hysterical; switchable double jokeTimeout = 20.0; switchable int volume = 25; start { ownResource(onActiveOrPassiveSpeechRecognized(s -> enter { if (!enabled) ret; print("Got line: " + s); if (cic(s, "histor")) setField(historical := now()); if (cic(s, "hyster")) setField(hysterical := now()); if (recent(historical) && recent(hysterical) || cicOneOf(s, "hysterical day", "hysterical reason", "hysterically grown")) { infoBox("Hahaha historical/hysterical joke"); laugh_gain = volume/100.0; laugh(); setFields(historical := 0, hysterical := 0); } })); } bool recent(long timestamp) { ret elapsedSeconds_now(timestamp) <= jokeTimeout; } }