Uses 911K of libraries. Click here for Pure Java version (16334L/91K).
1 | !7 |
2 | |
3 | cmodule TrainableBot > DynSockPuppetConvo {
|
4 | delegate Post to JChatConvo. |
5 | |
6 | LS suggestions; |
7 | S functions; |
8 | transient SingleComponentPanel scpSuggestions; |
9 | transient FunctionsLoader loader; |
10 | transient Thread playThread; |
11 | |
12 | start {
|
13 | onPostAdded.add(post -> startPlaying()); |
14 | } |
15 | |
16 | visual jvsplit(super, |
17 | withMargin(jhsplit( |
18 | jCenteredSection("Suggestions", scpSuggestions = singleComponentPanel(renderSuggestions())),
|
19 | northAndCenterWithMargin( |
20 | jrightaligned(jbutton("Load", rThreadEnter loadFunctions)),
|
21 | dm_textAreaAsSection functions())))); |
22 | |
23 | JComponent renderSuggestions() {
|
24 | ret ele_renderSuggestions(null, suggestions, |
25 | sayAction := (IVF1<S>) s -> addPost(s, true), |
26 | submitAction := (IVF1<S>) s -> addPost(s, false)); |
27 | } |
28 | |
29 | void showSuggestions(Cl<S> suggestions) {
|
30 | setField(suggestions := asList(suggestions)); |
31 | showSuggestions(); |
32 | } |
33 | |
34 | void showSuggestions {
|
35 | scpSuggestions?.setComponent(renderSuggestions()); |
36 | } |
37 | |
38 | void loadFunctions {
|
39 | dispose loader; |
40 | loader = new FunctionsLoader(filter isStandardFunction(tlftj(functions))); |
41 | loader.loadFunctionsParams = litparams(header := "set flag NoGenericFunctions."); |
42 | loader.onLoaded(r startPlaying); |
43 | loader.loadInBackground(); |
44 | } |
45 | |
46 | void startPlaying enter {
|
47 | if (loader == null) loadFunctions(); |
48 | cancelThread(playThread); |
49 | playThread = null; |
50 | playThread = startThread(rEnter play); |
51 | } |
52 | |
53 | void play {
|
54 | //showSuggestions(ll("test " + now()));
|
55 | new LinkedHashSet<S> l; |
56 | S input = lastInput(); |
57 | for ping (S f : loader.functions) {
|
58 | addIfInstanceOf(l, S, callBlobFunction(f)); |
59 | ping(); |
60 | if (nempty(input)) |
61 | addIfInstanceOf(l, S, callBlobFunction(f, input)); |
62 | } |
63 | showSuggestions(l); |
64 | } |
65 | |
66 | O callBlobFunction(S fname, O... args) {
|
67 | if (canCallWithVarargs(module(), fname, args)) |
68 | ret callWithVarargs(module(), fname ,args); |
69 | else |
70 | ret callOpt(loader.blob, fname, args); |
71 | } |
72 | |
73 | LPairS userBotPairs() { ret chatConvo_userBotPairs(posts); }
|
74 | } |
Began life as a copy of #1026803
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: | #1026808 |
| Snippet name: | Parrot 1.1 (with functions list, runs each function invidiually) |
| Eternal ID of this version: | #1026808/32 |
| Text MD5: | 311c0366ca4b19ccfc098bcb7553f9cd |
| Transpilation MD5: | 140b5960b0c9a372a6f0b6ab34fc0ff2 |
| Author: | stefan |
| Category: | javax / stefan's os |
| Type: | JavaX source code (Dynamic Module) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2020-01-25 15:52:27 |
| Source code size: | 2138 bytes / 74 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 553 / 981 |
| Version history: | 31 change(s) |
| Referenced in: | [show references] |