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

31
LINES

< > BotCompany Repo | #1002378 // Full History Bot (Web)

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

Libraryless. Click here for Pure Java version (902L/6K/22K).

!752

static int maxQuestionLength = 500;
static int maxAnswerLength = 200;

static S html(S subUri, Map<S, S> params) {
  L history = cast get(getMainBot(), "history");
  new StringBuffer buf;
  
  buf.append(pageNav(params, litstringlist(), l(history), "n"));
  
  pcall {
    int x = 0;
    print("l(history)=" + l(history) + ", x=" + x);
    
    int n;
    if (!empty(params.get("n")))
      n = parseInt(params.get("n"));
    else
      n = max(0, l(history)-1)/100*100;
    for (int i = min(n+100, l(history))-1; i >= n; i--) {
      O dialog = history.get(i);
      S q = shorten(getString(dialog, "question"), maxQuestionLength);
      S a = shorten(getString(dialog, "answer"), maxAnswerLength);
      S user = or(getString(dialog, "user"), "User");
      buf.append(htag("li", htmlencode(user) + ": <b>" + htmlencode(q) + "</b>", "class", "splash-li") + "\n");
      buf.append(htag("li", system() + ": <b>" + htmlencode(a) + "</b>", "class", "splash-li") + "\n");
    }
  }
  ret htag("p", "n=" + l(history)) + htag("ul", buf);
}

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: #1002378
Snippet name: Full History Bot (Web)
Eternal ID of this version: #1002378/1
Text MD5: fc7045d8da8a084ddd5e46604aaaa96e
Transpilation MD5: 1bbfb48c30392d4a23e71195acab4a0f
Author: stefan
Category: nl bots
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-02-05 23:36:59
Source code size: 1071 bytes / 31 lines
Pitched / IR pitched: No / No
Views / Downloads: 709 / 50833
Referenced in: [show references]