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

53
LINES

< > BotCompany Repo | #1002241 // Show Output Bot

JavaX source code [tags: ai1-lol butter use-pretranspiled] - run with: x30.jar - homepage - homepage

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

1  
!7
2  
3  
sS html(S uri, SS params) {
4  
  if (!webAuthed()) {
5  
    S editPW = trim(loadSecretTextFile("#1002192", "edit-pw"));
6  
    if (empty(editPW)) ret "No special password set and you're not master-authed";
7  
    if (!eq(params.get("pw"), editPW)) ret "No password, bugger :)";
8  
  }
9  
  
10  
  S botID = params.get("bot");
11  
  
12  
  if (nempty(params.get("clear"))) {
13  
    clearPrintLog(botID);
14  
    ret hrefreshWithParams(myLink_nonRaw("/"), bot := botID);
15  
  }
16  
17  
  StringBuffer buf;
18  
  if (nempty(botID)) {
19  
    O bot = getBot(botID);
20  
    buf = (StringBuffer) getOpt(bot, "local_log");
21  
    print("1002241: Bot ID = " + botID + ", bot: " + bot + ", buf: " + (buf != null));
22  
  } else
23  
    buf = (StringBuffer) get(mainBot, "print_log");
24  
    
25  
  if (buf == null) ret "Bot not found";
26  
  int size = buf.length();
27  
  ret htag("p", )
28  
    + hform(p("Log size: " + size + " " + hsubmit("Clear") +
29  
    hhidden("bot", botID) + hhidden("clear", "1")), method := "POST")
30  
    + htag("pre", htmlencode(buf));
31  
}
32  
33  
answer {
34  
  if "print log size" {
35  
    StringBuffer buf = cast get(mainBot, "print_log");
36  
    ret str(buf.length());
37  
  }
38  
  
39  
  if (!webAuthed()) ret null;
40  
  
41  
  if "clear print log" {
42  
    ret "OK, cleared " + clearPrintLog(null) + " characters";
43  
  }
44  
}
45  
46  
static int clearPrintLog(S botID) {
47  
  O bot = nempty(botID) ? getBot(botID) : mainBot;
48  
  StringBuffer buf = cast get(bot, "local_log");
49  
  int len = buf.length();
50  
  buf.setLength(0);
51  
  print("Buffer of " + botID + ": " + identityHashCode(buf) + ", " + len);
52  
  ret len;
53  
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1002241
Snippet name: Show Output Bot
Eternal ID of this version: #1002241/18
Text MD5: b67c42816d06a369712eb5c3b90710ef
Transpilation MD5: 426cf31c57090c6b13a29fd8fc04fada
Author: stefan
Category: javax
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-12-26 15:49:11
Source code size: 1540 bytes / 53 lines
Pitched / IR pitched: No / No
Views / Downloads: 866 / 8290
Version history: 17 change(s)
Referenced in: [show references]