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

1  
sbool dm_bot_execEvalCmd(VF1<S> postMessage, S s, O... _) {
2  
  double timeout = optPar timeout(_, 60.0);
3  
  O safetyCheck = optPar safetyCheck(_);
4  
  O mod = dm_current_generic();
5  
  optPar bool alwaysFresh;
6  
  
7  
  new Matches m;
8  
  bool freshMe = swic_trim(s, "!fresh ", m);
9  
  if (freshMe || eq(s, "!fresh")) {
10  
    dm_refreshTranspiler();
11  
    if (!freshMe) ret true with callF(postMessage, "OK");
12  
  } else if (alwaysFresh) dm_refreshTranspiler();
13  
      
14  
  if (swic_trim(s, "!eval ", m))
15  
    ret true with callF(postMessage, pcallOrExceptionText_strOrNull(func {
16  
      S code = m.rest();
17  
      try answer (S) callF(safetyCheck, code);
18  
      ret print("eval result > ", strOrNull(dm_javaEvalOrInterpret(code)));
19  
    }));
20  
        
21  
  if (freshMe || swic_trim(s, "!real-eval ", m))
22  
    ret true with callF(postMessage, evalWithTimeout_text(timeout, func {
23  
      temp dm_enter(mod);
24  
      S code = m.rest();
25  
      try answer (S) callF(safetyCheck, code);
26  
      ret print("eval result > ", dm_javaEval(code));
27  
    }));
28  
  false;
29  
}

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: 346 / 492
Version history: 13 change(s)
Referenced in: [show references]