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

34
LINES

< > BotCompany Repo | #1001704 // Simple List Bot

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

Libraryless. Click here for Pure Java version (1823L/12K/40K).

1  
!747
2  
3  
m {
4  
  static S name = "Simple List Bot.";
5  
  static L<S> entries = synchroList(); // just in case
6  
  
7  
  p {
8  
    readLocally("entries");
9  
    print("Entries in my database: " + entries.size());
10  
    makeSilentAndroid(name);
11  
  }
12  
  
13  
  static synchronized S answer(S s) {
14  
    new Matches m;
15  
    
16  
    if (match3("add *", s, m)) {
17  
      S x = m.unq(0);
18  
      entries.add(x);
19  
      saveLocally("entries");
20  
      return "OK, now " + entries.size() + " entries.";
21  
    }
22  
    
23  
    if (match3("remove *", s, m)) {
24  
      S x = m.unq(0);
25  
      int i = entries.indexOf(x);
26  
      if (i < 0) ret "Entry not found.";
27  
      entries.remove(i);
28  
      saveLocally("entries");
29  
      return "OK, now " + entries.size() + " entries.";
30  
    }
31  
    
32  
    return standardQuery(s, "entries");
33  
  }
34  
}

Author comment

Began life as a copy of #1001321

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: #1001704
Snippet name: Simple List Bot
Eternal ID of this version: #1001704/1
Text MD5: 26e7d8f0bdeeb77d5ebdbc38de20f58d
Transpilation MD5: fda7c0f9ed060c831ff58ad5898d6a42
Author: stefan
Category:
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-11-11 21:17:22
Source code size: 801 bytes / 34 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 508 / 771
Referenced in: [show references]