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

71
LINES

< > BotCompany Repo | #1027704 // Repeat After Me + Go Public/Private [Cruddie Script]

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

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

1  
!7
2  
3  
sclass Converter > CruddieScript {
4  
  S answer(S s) null {
5  
    new Matches m;
6  
    if "what is $x C in Fahrenheit"
7  
      ret celsiusToFahrenheit(parseDouble($x)) + " Fahrenheit";
8  
  }
9  
}
10  
11  
sclass ReproduceAnswers > CruddieScript {
12  
  transient IF0<LS> chatLog_userMessagesOnly;
13  
  LS chatLog_userMessagesOnly() { ret chatLog_userMessagesOnly == null ? null : chatLog_userMessagesOnly.get(); }
14  
  
15  
  S answer(S s) {
16  
    LS msgs = chatLog_userMessagesOnly();
17  
    MultiMap<S> mm = pairsToCIMultiMap(overlappingPairs(msgs));
18  
    ret random(mm.get(s));
19  
  }
20  
}
21  
22  
sclass RepeatAfterMe > CruddieScript {
23  
  swappable void deleteMe() {}
24  
  swappable S rewrite(S s) { ret s; }
25  
  
26  
  S answer(S s) {
27  
    new Matches m;
28  
    if "stop repeating..." {
29  
      deleteMe();
30  
      ret "OK stopped";
31  
    }
32  
    print("Repeating: " + s);
33  
    ret rewrite(s);
34  
  }
35  
}
36  
37  
sclass RepeatAfterMeAndSwitch > RepeatAfterMe {
38  
  S rewrite_base(S s) { ret switcheroo(s); }
39  
}
40  
41  
sclass GoPublic > CruddieScript {
42  
  S answer(S s) null {
43  
    if "go public"
44  
      ret "We're all public";
45  
    if "go private"
46  
      ret "Can't";
47  
    if "are you public"
48  
      ret "Yes";
49  
  }
50  
}
51  
52  
/*sclass GoPublic > CruddieScript {
53  
  swappable void makeBotPublic(bool b) {}
54  
  swappable Bool isBotPublic() { null; }
55  
  
56  
  S answer(S s) null {
57  
    if "go public" {
58  
      makeBotPublic(true);
59  
      ret "OK";
60  
    }      
61  
    if "go private" {
62  
      makeBotPublic(false);
63  
      ret "OK";
64  
    }      
65  
    if "are you public"
66  
      ret trueFalseNull(isBotPublic(), "yes", "no", "not sure");
67  
  }
68  
}*/
69  
70  
cmodule SomeCruddieScripts {
71  
}

Author comment

Began life as a copy of #1027663

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: #1027704
Snippet name: Repeat After Me + Go Public/Private [Cruddie Script]
Eternal ID of this version: #1027704/18
Text MD5: 0c27c523511b6928304ede38d195158d
Transpilation MD5: e91198b7e5db26b19d648eb8477cc665
Author: stefan
Category: javax / chat bots
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-04-05 16:09:19
Source code size: 1619 bytes / 71 lines
Pitched / IR pitched: No / No
Views / Downloads: 158 / 48085
Version history: 17 change(s)
Referenced in: [show references]