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).

!7

sS html(S uri, SS params) {
  if (!webAuthed()) {
    S editPW = trim(loadSecretTextFile("#1002192", "edit-pw"));
    if (empty(editPW)) ret "No special password set and you're not master-authed";
    if (!eq(params.get("pw"), editPW)) ret "No password, bugger :)";
  }
  
  S botID = params.get("bot");
  
  if (nempty(params.get("clear"))) {
    clearPrintLog(botID);
    ret hrefreshWithParams(myLink_nonRaw("/"), bot := botID);
  }

  StringBuffer buf;
  if (nempty(botID)) {
    O bot = getBot(botID);
    buf = (StringBuffer) getOpt(bot, "local_log");
    print("1002241: Bot ID = " + botID + ", bot: " + bot + ", buf: " + (buf != null));
  } else
    buf = (StringBuffer) get(mainBot, "print_log");
    
  if (buf == null) ret "Bot not found";
  int size = buf.length();
  ret htag("p", )
    + hform(p("Log size: " + size + " " + hsubmit("Clear") +
    hhidden("bot", botID) + hhidden("clear", "1")), method := "POST")
    + htag("pre", htmlencode(buf));
}

answer {
  if "print log size" {
    StringBuffer buf = cast get(mainBot, "print_log");
    ret str(buf.length());
  }
  
  if (!webAuthed()) ret null;
  
  if "clear print log" {
    ret "OK, cleared " + clearPrintLog(null) + " characters";
  }
}

static int clearPrintLog(S botID) {
  O bot = nempty(botID) ? getBot(botID) : mainBot;
  StringBuffer buf = cast get(bot, "local_log");
  int len = buf.length();
  buf.setLength(0);
  print("Buffer of " + botID + ": " + identityHashCode(buf) + ", " + len);
  ret len;
}

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: 933 / 8412
Version history: 17 change(s)
Referenced in: #3000169 - Answer for stefanreich
#3000174 - Answer for stefanreich
#3000175 - Answer for stefanreich
#3000176 - Answer for stefanreich
#3000177 - Answer for stefanreich
#3000179 - Answer for stefanreich
#3000180 - Answer for stefanreich
#3000181 - Answer for stefanreich
#3000182 - Answer for stefanreich
#3000184 - Answer for stefanreich
#3000185 - Answer for stefanreich
#3000202 - Answer for stefanreich (>> T conversion bot)
#3000203 - Answer for stefanreich (>> timing hello bot)
#3000208 - Answer for bgrgndz (>> list sub bots)
#3000209 - Answer for bgrgndz (>> list sub bots)
#3000238 - Answer for stefanreich (>> t power bot)
#3000369 - Answer for Stefan (>> list sub bots)
#3000376 - Answer for stefanreich (>> list sub bots)
#3000377 - Answer for stefanreich (>> timing eleu?)
#3000380 - Answer for stefanreich (>> list sub bots)
#3000381 - Answer for speedforce (>> list sub bots)
#3000382 - Answer for ferdie (>> t = 1, f = 0)
#3000383 - Answer for funkoverflow (>> t=1, f=0 okay)