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.

!759

snew JTextArea thoughtArea;
snew JTextArea chatArea;
snew JTextField chatField;

static new L<E> script;
static int idx;

p {
  script = parsePoem("#1003305");
  
  showSideBySide("GMail Bot",
    withTitle("Chat", centerAndSouth(chatArea, chatField)),
    withTitle("Thoughts", thoughtArea));
    
  chatField.requestFocus();
  onEnter(chatField, runnable {
    pcall {
      if (eq(nextMove(), "move"))
        ++idx;
    }
    chatArea.append(chatField.getText() + "\n");
    chatField.selectAll();
  });
  
  swingEverySecond(thoughtArea, runnable { predict(); });
}

svoid predict {
  new StringBuilder buf;
  try {
    buf.append(unparsePoem(subList(script, idx)) + "\n\n");
    S move = nextMove();
    buf.append("Probable next move: " + move + "\n\n");
  } catch e {
    buf.append("\n\n" + getStackTrace(e));
  }
  setText(thoughtArea, buf);
}

sS nextMove {
  S input = chatField.getText();
  if (idx >= l(script)) ret "stop";
  E e = get(script, idx);
  if (e.q != null && match(e.q, input)) ret "move";
  ret "stop";
}

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: 501 / 515
Referenced in: [show references]