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

!7

lib 1400198 // jSlack (fat jar)

import com.github.seratch.jslack.*;
import com.github.seratch.jslack.api.rtm.*;
import com.github.seratch.jslack.api.methods.request.chat.*;
import com.github.seratch.jslack.api.methods.response.chat.*;

p-exp {
  fixContextClassLoader();
  
  S token = assertNempty("oibot token", trim(loadTextFile(javaxSecretDir("oibot-token-2.txt"))));

  new Slack slack;
  RTMClient rtm = slack.rtm(token);
  
  rtm.addMessageHandler((message) -> {
    Map json = jsonDecodeMap(message);
    pnlStruct(json);
    
    if (eq(json.get("text"), "test")) pcall {
      S channelID = cast json.get("channel");
      ChatPostMessageResponse postResponse = slack.methods().chatPostMessage(
        ChatPostMessageRequest.builder()
          .token(token)
          .channel(channelID)
          .text("Test successful.")
          .build());
    }
  });

  // must connect within 30 seconds after issuing wss endpoint
  rtm.connect();
}

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: 308 / 834
Version history: 20 change(s)
Referenced in: [show references]