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

!747

m {
  static S name = "Simple List Bot.";
  static L<S> entries = synchroList(); // just in case
  
  p {
    readLocally("entries");
    print("Entries in my database: " + entries.size());
    makeSilentAndroid(name);
  }
  
  static synchronized S answer(S s) {
    new Matches m;
    
    if (match3("add *", s, m)) {
      S x = m.unq(0);
      entries.add(x);
      saveLocally("entries");
      return "OK, now " + entries.size() + " entries.";
    }
    
    if (match3("remove *", s, m)) {
      S x = m.unq(0);
      int i = entries.indexOf(x);
      if (i < 0) ret "Entry not found.";
      entries.remove(i);
      saveLocally("entries");
      return "OK, now " + entries.size() + " entries.";
    }
    
    return standardQuery(s, "entries");
  }
}

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: 569 / 859
Referenced in: #1001706 - User Request List Bot
#3000202 - Answer for stefanreich (>> T conversion bot)
#3000238 - Answer for stefanreich (>> t power bot)
#3000382 - Answer for ferdie (>> t = 1, f = 0)