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).

1  
!747
2  
!pcall {
3  
4  
m {
5  
  static S myName = "Leo Bot";
6  
  static int delay = 5000;
7  
  
8  
  static new L<S> history;
9  
  
10  
  p {
11  
    while (true) {
12  
      pcall { // make sure we stay runnning if connection fails or error
13  
        for (ChatLine l : suckHumans(myName)) {
14  
          historyAdd(l.text);
15  
          S bla = structure(history.subList(Math.max(0, history.size()-3), history.size()));
16  
          S answer = sendToRemoteBot("Leo Bot", "!" + bla);
17  
          print("Leo's answer: " + answer);
18  
          if (answer != null && !answer.equals(history.get(history.size()-1)) && !answer.equals("?")) {
19  
            sayInWebChat(myName, answer);
20  
            historyAdd(answer);
21  
          }
22  
        }
23  
      }
24  
      sleep(delay);
25  
    }
26  
  }
27  
  
28  
  static void historyAdd(S line) {
29  
    history.add(line);
30  
    while (history.size() > 3) history.remove(0);
31  
  }
32  
}

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