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

46
LINES

< > BotCompany Repo | #1001307 // Conversations Logger Bot

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

Libraryless. Click here for Pure Java version (1412L/10K/33K).

!747

m {
  static new Map<S, Convo> convos; // mapped by dialog ID
  
  static class Convo {
    S dialogID;
    long date;
    L<S> lines;
    S botID;
    S computerID;
  }
  
  p {
    readLocally("convos");
    print("Conversations in my database: " + convos.size());
    makeAndroid("Conversations Log Bot.");
  }
  
  static synchronized S answer(S s) {
    new Matches m;
    
    if (match3("New dialog. dialog id: *. date: *. computer ID: *, bot ID: *. lines: *", s, m)) {
      new Convo x;
      x.dialogID = unquote(m.m[0]);
      x.date = parseLong(unquote(m.m[1]));
      x.computerID = unquote(m.m[2]);
      x.botID = unquote(m.m[3]);
      x.lines = (List) unstructure(unquote(m.m[4]));
      convos.put(x.dialogID, x);
      saveLocally("convos");
      return "OK, now " + convos.size() + " conversations.";
    }
    
    if (match3("Add line to dialog. dialog id: *. line: *", s, m)) {
      S dialogID = unquote(m.m[0]);
      Convo x = convos.get(dialogID);
      if (x == null)
        return format3("Dialog not found: *", dialogID);
      x.lines.add(unquote(m.m[1]));
      return "OK, now " + x.lines.size() + " lines in conversation.";
    }
    
    return standardQuery(s, "convos");
  }
}

Author comment

Began life as a copy of #1001245

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: #1001307
Snippet name: Conversations Logger Bot
Eternal ID of this version: #1001307/1
Text MD5: 7e6e69ef378adafc5e204ed8736816f1
Transpilation MD5: 3ab168d65d822554d9562d9acee9884d
Author: stefan
Category:
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-10-08 18:40:04
Source code size: 1266 bytes / 46 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 609 / 866
Referenced in: [show references]