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

53
LINES

< > BotCompany Repo | #1002356 // Store messages bot

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

Libraryless. Click here for Pure Java version (2293L/14K/49K).

!752
static new MultiMap<S, Line> map;
static class Line { 
  S text;
  S timestamp;
  
  Line(){
  
  }
  *(S *text, S *timestamp) {}
}
p{
  makeBot("Store messages bot");
  load("map");
}

synchronized answer{
  S username = "";
  if(getUserName() == null){
    username = "anonymous";
  }else{
    username = getUserName();
  }
  if(matchStart("list all messages from *", s, m)){
    ret structure(map.get(m.unq(0)));
  }
  if(match("list all users", s)){
    ret structure(map.keySet());
  }
  if(matchStart("did * say something about *", s, m)){
    if(map.containsKey(m.unq(0))){
      List<Line> list = map.get(m.unq(0));
      int times = 0;
      L<S> lolist = new L;
      for (int i = l(list)-1; i >= 0; i--) {
        if(list.get(i).text.contains(m.unq(1))){
          times = times + 1;
          lolist.add(list.get(i).text);
        }
      }
      if (times == 0){
        ret "no results found";
      }else{
        ret lolist + "\n" + times +" results found";
      }
    }else{
      ret m.unq(0) + " did not say anything.";
    }
  } 
  Line line = new Line(s,getSlackTS());
  map.put(username, line);
  save("map");
}

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: #1002356
Snippet name: Store messages bot
Eternal ID of this version: #1002356/1
Text MD5: 00707ecb99cf1c4f37125fd7e8066388
Transpilation MD5: 69f2caf0c62d1c9fd01eefe730cc8a54
Author: bgrgndz
Category:
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-01-15 22:37:02
Source code size: 1191 bytes / 53 lines
Pitched / IR pitched: No / No
Views / Downloads: 950 / 1341
Referenced in: #1002404 - Store messages bot (optimized)
#3000195 - Answer for stefanreich (>> y)
#3000196 - Answer for stefanreich (>> y)
#3000197 - Answer for stefanreich (>> program data sizes)
#3000198 - Answer for stefanreich (>> program data sizes)
#3000199 - Answer for stefanreich (>> program data sizes)
#3000200 - Answer for stefanreich (>> program data sizes)
#3000201 - Answer for stefanreich (>> list all files)
#3000202 - Answer for stefanreich (>> T conversion bot)
#3000238 - Answer for stefanreich (>> t power bot)
#3000382 - Answer for ferdie (>> t = 1, f = 0)
#3000383 - Answer for funkoverflow (>> t=1, f=0 okay)