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

38
LINES

< > BotCompany Repo | #1001976 // I Have Bot (developing)

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

Transpiled version (1995L) is out of date.

1  
!752
2  
3  
static class Msg {
4  
  S user, text;
5  
  
6  
  *(S *user, S *text) {}
7  
  *() {}
8  
}
9  
10  
// persistent
11  
static PersistentLog<Msg> msgs;
12  
13  
// built every time in memory
14  
static new MultiMap<S, Msg> msgsByUser;
15  
16  
p {
17  
  msgs = new PersistentLog<Msg>("incoming-msgs");
18  
  for (Msg m : msgs) pcall { answer(m.text, m.user); }
19  
  
20  
  makeBot("I Have Bot.");
21  
}
22  
23  
static S answer(S s) {
24  
  ret answer(s, "user");
25  
}
26  
27  
static synchronized S answer(S s, S user) {
28  
  msgs.add(new Msg(user, s));
29  
  new Matches m;
30  
  ret answerImpl(user);
31  
  msgsByUser.put(m.user, m);
32  
  if (matchStart("i have", s, m)) {
33  
    print(structure(m));
34  
    S rest = m.rest();
35  
    print("Rest: " + quote(rest));
36  
    ret "ok";
37  
  }
38  
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1001976
Snippet name: I Have Bot (developing)
Eternal ID of this version: #1001976/1
Text MD5: 4b9b0bc81274198aaaad9b66937c32fa
Author: stefan
Category: javax
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-12-10 20:14:54
Source code size: 710 bytes / 38 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 614 / 690
Referenced in: [show references]