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

35
LINES

< > BotCompany Repo | #1022377 // Test jSlack [OK]

JavaX source code (desktop) [tags: use-pretranspiled] - run with: x30.jar

Download Jar. Uses 0K of libraries. Click here for Pure Java version (7554L/54K).

1  
!7
2  
3  
lib 1400198 // jSlack (fat jar)
4  
5  
import com.github.seratch.jslack.*;
6  
import com.github.seratch.jslack.api.rtm.*;
7  
import com.github.seratch.jslack.api.methods.request.chat.*;
8  
import com.github.seratch.jslack.api.methods.response.chat.*;
9  
10  
p-exp {
11  
  fixContextClassLoader();
12  
  
13  
  S token = assertNempty("oibot token", trim(loadTextFile(javaxSecretDir("oibot-token-2.txt"))));
14  
15  
  new Slack slack;
16  
  RTMClient rtm = slack.rtm(token);
17  
  
18  
  rtm.addMessageHandler((message) -> {
19  
    Map json = jsonDecodeMap(message);
20  
    pnlStruct(json);
21  
    
22  
    if (eq(json.get("text"), "test")) pcall {
23  
      S channelID = cast json.get("channel");
24  
      ChatPostMessageResponse postResponse = slack.methods().chatPostMessage(
25  
        ChatPostMessageRequest.builder()
26  
          .token(token)
27  
          .channel(channelID)
28  
          .text("Test successful.")
29  
          .build());
30  
    }
31  
  });
32  
33  
  // must connect within 30 seconds after issuing wss endpoint
34  
  rtm.connect();
35  
}

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: #1022377
Snippet name: Test jSlack [OK]
Eternal ID of this version: #1022377/21
Text MD5: 10776006757c53ab4f04c9827335c218
Transpilation MD5: b48444dc0558a6dd758601631abf33b8
Author: stefan
Category: javax / slack
Type: JavaX source code (desktop)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-03-16 15:29:27
Source code size: 990 bytes / 35 lines
Pitched / IR pitched: No / No
Views / Downloads: 426 / 1122
Version history: 20 change(s)
Referenced in: [show references]