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

91
LINES

< > BotCompany Repo | #1022809 // Current time dialog v1 [ok, but preprocessors not working]

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

Uses 911K of libraries. Click here for Pure Java version (11325L/59K).

!7

cmodule CurrentTimeDialog > DynSayAndInputBot {
  class TimeBot extends AbstractSayAndInputBot2 implements Runnable {
    class Thanks > MatchAttractor {
      *() {
        super("thanks|thank you|thx");
      }
      
      public void run {
        say("You're welcome");
      }
    }
    
    class WhatCanYouDo > MatchAttractor {
      *() {
        super("what can you do...|what is your skill|who are you");
      }
      
      public void run {
        say("I can tell you the time");
        addAttractor(new DoIt);
      }
    }
    
    class DoIt > Attractor {
      public bool matches(S s) {
        ret matchX2("do it|ok|i want that", s);
      }
      
      public void run { sayTime(); }
    }
    
    class TalkToMe extends Attractor {
      public bool matches(S s) {
        ret matchX2("talk to me|hi|talk|say something", s);
      }
      
      public void run { run_public(); }
    }
    
    class DoItAgain extends Attractor {
      public bool matches(S s) {
        ret matchX2("do it again|again|another time", s);
      }
      
      public void run { sayTime(); }
    }
    
    class WhatsTheTime extends Attractor {
      public bool matches(S s) {
        ret matchX2("what's the time|tell me the time|time", s);
      }
      
      public void run { sayTime(); }
    }
    
    class Yes_SayTime extends Attractor {
      public bool matches(S s) {
        ret isYes_1(s);
      }
      
      public void run { sayTime(); }
    }
    
    class SayOK extends Attractor {
      public bool matches(S s) {
        true;
      }
      
      public void run { say("OK"); }
    }
    
    *() {
      addPreprocessors(f ai_dropLeadingAndTrailingAppellations_sortedByLength);
      standardAttractors(new DoItAgain, new WhatsTheTime, new TalkToMe, new WhatCanYouDo, new Thanks);
    }
    
    public void run {
      say("Do you want to know the current time?");
      addAttractor(new Yes_SayTime);
      addLowPrioAttractor(new SayOK);
    }
    
    void sayTime {
      say("It is " + localTime_24());
    }
  }
  
  TimeBot makeBot() { ret new TimeBot; }
}

Author comment

Began life as a copy of #1022808

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1022809
Snippet name: Current time dialog v1 [ok, but preprocessors not working]
Eternal ID of this version: #1022809/20
Text MD5: 8186f92cafac001540fc6d8035e2b14e
Transpilation MD5: 5e2261288d9b2e73460858c5ece697e3
Author: stefan
Category: javax / a.i.
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-04-09 00:53:15
Source code size: 2193 bytes / 91 lines
Pitched / IR pitched: No / No
Views / Downloads: 282 / 716
Version history: 19 change(s)
Referenced in: [show references]