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

48
LINES

< > BotCompany Repo | #1003306 // GMail Bot (dev., old)

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Transpiled version (2371L) is out of date.

1  
!759
2  
3  
snew JTextArea thoughtArea;
4  
snew JTextArea chatArea;
5  
snew JTextField chatField;
6  
7  
static new L<E> script;
8  
static int idx;
9  
10  
p {
11  
  script = parsePoem("#1003305");
12  
  
13  
  showSideBySide("GMail Bot",
14  
    withTitle("Chat", centerAndSouth(chatArea, chatField)),
15  
    withTitle("Thoughts", thoughtArea));
16  
    
17  
  chatField.requestFocus();
18  
  onEnter(chatField, runnable {
19  
    pcall {
20  
      if (eq(nextMove(), "move"))
21  
        ++idx;
22  
    }
23  
    chatArea.append(chatField.getText() + "\n");
24  
    chatField.selectAll();
25  
  });
26  
  
27  
  swingEverySecond(thoughtArea, runnable { predict(); });
28  
}
29  
30  
svoid predict {
31  
  new StringBuilder buf;
32  
  try {
33  
    buf.append(unparsePoem(subList(script, idx)) + "\n\n");
34  
    S move = nextMove();
35  
    buf.append("Probable next move: " + move + "\n\n");
36  
  } catch e {
37  
    buf.append("\n\n" + getStackTrace(e));
38  
  }
39  
  setText(thoughtArea, buf);
40  
}
41  
42  
sS nextMove {
43  
  S input = chatField.getText();
44  
  if (idx >= l(script)) ret "stop";
45  
  E e = get(script, idx);
46  
  if (e.q != null && match(e.q, input)) ret "move";
47  
  ret "stop";
48  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1003306
Snippet name: GMail Bot (dev., old)
Eternal ID of this version: #1003306/1
Text MD5: 42d533fae06b7520616bdf2d747904e1
Author: stefan
Category: javax / talking robots
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-07-19 15:01:12
Source code size: 1084 bytes / 48 lines
Pitched / IR pitched: No / No
Views / Downloads: 607 / 660
Referenced in: [show references]