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

29
LINES

< > BotCompany Repo | #1021658 // dm_bot_execEvalCmd

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (15887L/100K).

sbool dm_bot_execEvalCmd(VF1<S> postMessage, S s, O... _) {
  double timeout = optPar timeout(_, 60.0);
  O safetyCheck = optPar safetyCheck(_);
  O mod = dm_current_generic();
  optPar bool alwaysFresh;
  
  new Matches m;
  bool freshMe = swic_trim(s, "!fresh ", m);
  if (freshMe || eq(s, "!fresh")) {
    dm_refreshTranspiler();
    if (!freshMe) ret true with callF(postMessage, "OK");
  } else if (alwaysFresh) dm_refreshTranspiler();
      
  if (swic_trim(s, "!eval ", m))
    ret true with callF(postMessage, pcallOrExceptionText_strOrNull(func {
      S code = m.rest();
      try answer (S) callF(safetyCheck, code);
      ret print("eval result > ", strOrNull(dm_javaEvalOrInterpret(code)));
    }));
        
  if (freshMe || swic_trim(s, "!real-eval ", m))
    ret true with callF(postMessage, evalWithTimeout_text(timeout, func {
      temp dm_enter(mod);
      S code = m.rest();
      try answer (S) callF(safetyCheck, code);
      ret print("eval result > ", dm_javaEval(code));
    }));
  false;
}

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1021658
Snippet name: dm_bot_execEvalCmd
Eternal ID of this version: #1021658/14
Text MD5: 8f245553548fc90cc1ff577b728186fe
Transpilation MD5: f99252f47bd55c78987cde5abab05781
Author: stefan
Category: javax / stefan's os
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-08-28 18:25:22
Source code size: 1044 bytes / 29 lines
Pitched / IR pitched: No / No
Views / Downloads: 344 / 488
Version history: 13 change(s)
Referenced in: [show references]