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

25
LINES

< > BotCompany Repo | #1023940 // eeZee old [http]

JavaX source code (Dynamic Module) - run with: Stefan's OS

1  
!7
2  
3  
cmodule eeZee > DynDiscordHopper {
4  
  S url = "https://4b559f3a.ngrok.io";
5  
  
6  
  transient NotTooOften ntoError = notTooOften_1min();
7  
  
8  
  @Override S answer(S input, Map map) {
9  
    try answer super.answer(input, map);
10  
    
11  
    try {
12  
      long time = sysNow();
13  
      S s = loadPageWithTimeout(60.0, url + hquery(message := input));
14  
      print("Got " + (s == null ? "timeout" : nChars(s)) + " in " + elapsedSeconds(time) + " s");
15  
      ret s;
16  
    } catch e {
17  
      if (!ntoError.yo()) null;
18  
      S str = exceptionToStringShort(e);
19  
      if (cic(str, "Server returned HTTP response code: 502")) // rough
20  
        ret null with print("Bot is offline (502)");
21  
      print(e);
22  
      ret "Error: " + shorten(100, str);
23  
    }
24  
  }
25  
}

Author comment

Began life as a copy of #1023928

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1023940
Snippet name: eeZee old [http]
Eternal ID of this version: #1023940/1
Text MD5: 590ce88f09bf3ff1f9a632ca432b5a44
Author: stefan
Category: javax / discord / a.i.
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-07-13 21:20:55
Source code size: 752 bytes / 25 lines
Pitched / IR pitched: No / No
Views / Downloads: 226 / 250
Referenced in: [show references]