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

32
LINES

< > BotCompany Repo | #1001578 // Leo Bot Web Chat Gateway

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

Libraryless. Click here for Pure Java version (840L/6K/20K).

!747
!pcall {

m {
  static S myName = "Leo Bot";
  static int delay = 5000;
  
  static new L<S> history;
  
  p {
    while (true) {
      pcall { // make sure we stay runnning if connection fails or error
        for (ChatLine l : suckHumans(myName)) {
          historyAdd(l.text);
          S bla = structure(history.subList(Math.max(0, history.size()-3), history.size()));
          S answer = sendToRemoteBot("Leo Bot", "!" + bla);
          print("Leo's answer: " + answer);
          if (answer != null && !answer.equals(history.get(history.size()-1)) && !answer.equals("?")) {
            sayInWebChat(myName, answer);
            historyAdd(answer);
          }
        }
      }
      sleep(delay);
    }
  }
  
  static void historyAdd(S line) {
    history.add(line);
    while (history.size() > 3) history.remove(0);
  }
}

Author comment

Began life as a copy of #1001546

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1001578
Snippet name: Leo Bot Web Chat Gateway
Eternal ID of this version: #1001578/1
Text MD5: 157a767f88c09b612146c353c39e2473
Transpilation MD5: 12a74a944cf3856485d0b8477e19aada
Author: stefan
Category: javax
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-10-25 18:02:06
Source code size: 868 bytes / 32 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 564 / 583
Referenced in: [show references]