Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

27
LINES

< > BotCompany Repo | #1029139 // Laugh About User's Jokes [OK, knows a single joke]

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Uses 1796K of libraries. Click here for Pure Java version (9387L/49K).

!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;
  }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1029139
Snippet name: Laugh About User's Jokes [OK, knows a single joke]
Eternal ID of this version: #1029139/15
Text MD5: a0f09cb7fe5d6cb9a55faea25b358769
Transpilation MD5: 786642e79f00c95e9ac4c044274ba344
Author: stefan
Category: javax / speech
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-07-22 18:37:00
Source code size: 843 bytes / 27 lines
Pitched / IR pitched: No / No
Views / Downloads: 211 / 3064
Version history: 14 change(s)
Referenced in: [show references]