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).

1  
!7
2  
3  
cmodule CurrentTimeDialog > DynSayAndInputBot {
4  
  class TimeBot extends AbstractSayAndInputBot2 implements Runnable {
5  
    class Thanks > MatchAttractor {
6  
      *() {
7  
        super("thanks|thank you|thx");
8  
      }
9  
      
10  
      public void run {
11  
        say("You're welcome");
12  
      }
13  
    }
14  
    
15  
    class WhatCanYouDo > MatchAttractor {
16  
      *() {
17  
        super("what can you do...|what is your skill|who are you");
18  
      }
19  
      
20  
      public void run {
21  
        say("I can tell you the time");
22  
        addAttractor(new DoIt);
23  
      }
24  
    }
25  
    
26  
    class DoIt > Attractor {
27  
      public bool matches(S s) {
28  
        ret matchX2("do it|ok|i want that", s);
29  
      }
30  
      
31  
      public void run { sayTime(); }
32  
    }
33  
    
34  
    class TalkToMe extends Attractor {
35  
      public bool matches(S s) {
36  
        ret matchX2("talk to me|hi|talk|say something", s);
37  
      }
38  
      
39  
      public void run { run_public(); }
40  
    }
41  
    
42  
    class DoItAgain extends Attractor {
43  
      public bool matches(S s) {
44  
        ret matchX2("do it again|again|another time", s);
45  
      }
46  
      
47  
      public void run { sayTime(); }
48  
    }
49  
    
50  
    class WhatsTheTime extends Attractor {
51  
      public bool matches(S s) {
52  
        ret matchX2("what's the time|tell me the time|time", s);
53  
      }
54  
      
55  
      public void run { sayTime(); }
56  
    }
57  
    
58  
    class Yes_SayTime extends Attractor {
59  
      public bool matches(S s) {
60  
        ret isYes_1(s);
61  
      }
62  
      
63  
      public void run { sayTime(); }
64  
    }
65  
    
66  
    class SayOK extends Attractor {
67  
      public bool matches(S s) {
68  
        true;
69  
      }
70  
      
71  
      public void run { say("OK"); }
72  
    }
73  
    
74  
    *() {
75  
      addPreprocessors(f ai_dropLeadingAndTrailingAppellations_sortedByLength);
76  
      standardAttractors(new DoItAgain, new WhatsTheTime, new TalkToMe, new WhatCanYouDo, new Thanks);
77  
    }
78  
    
79  
    public void run {
80  
      say("Do you want to know the current time?");
81  
      addAttractor(new Yes_SayTime);
82  
      addLowPrioAttractor(new SayOK);
83  
    }
84  
    
85  
    void sayTime {
86  
      say("It is " + localTime_24());
87  
    }
88  
  }
89  
  
90  
  TimeBot makeBot() { ret new TimeBot; }
91  
}

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: 286 / 721
Version history: 19 change(s)
Referenced in: [show references]