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

45
LINES

< > BotCompany Repo | #1008536 // Read Web Bot's Chat Log [OK]

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

Libraryless. Click here for Pure Java version (7630L/51K/170K).

!7

sS botID = #1008316; // #1008533;

sclass Msg {
  long time;
  bool fromUser;
  S text;
  
  *() {}
  *(bool *fromUser, S *text) { time = now(); }
}

concept Conversation {
  S cookie;
  long dialogID;
  new L<Msg> msgs;

  void add(Msg m) {
    msgs.add(m);
    change();
  }
}

p {
  S html = loadPage("http://ai1.lol/" + psI(botID) + "/raw/logs");
  for (L<S> li : html_contentsOfLIs(html)) {
    S dialogID = assertInteger(first(li));
    print("\nDialog " + dialogID);
    new Conversation conv;
    conv.dialogID = parseLong(dialogID);
    for (L<S> li2 : html_contentsOfLIs(li)) {
      S msg = htmldecode(join(li2));
      new Msg m;
      if (msg.startsWith(">")) m.fromUser = true;
      else if (!msg.startsWith("<")) {
        warn("Unknown line: " + msg);
        continue;
      }
      m.text = trim(substring(msg, 1));
      conv.add(m);
      printStruct(m);
    }
  }
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1008536
Snippet name: Read Web Bot's Chat Log [OK]
Eternal ID of this version: #1008536/10
Text MD5: f6fda5a81fe797e70ce6788edc4d7a4d
Transpilation MD5: f9a343f2f4f21fafe70b0ba30a4d8c26
Author: stefan
Category: javax / a.i.
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-05-30 16:44:54
Source code size: 935 bytes / 45 lines
Pitched / IR pitched: No / No
Views / Downloads: 567 / 630
Version history: 9 change(s)
Referenced in: [show references]