Code Monkey home page Code Monkey logo

java-slack-sdk's Introduction

Slack SDK for Java

Maven Central codecov

Slack SDK for Java supports the Slack platform in a Java idiomatic way. The SDK written in Java so developers can use it in any JVM language including Kotlin, Groovy, and Scala.

Within the SDK, there are two different modules:

  • Bolt for Java, which is a framework with a simple API that makes it easy to write modern Slack apps in Java.
  • Slack API Client, for when you need a more customized approach to building a Slack app in Java.

If what you want to do is call Slack APIs in your existing services, we recommend using only the Slack API Client. If instead, you’re developing a new modern and interactive Slack app, we recommend Bolt for it. The framework enables developers to focus on the essential parts of their apps without being bothered by trifles.

Bolt for Java

Bolt for Java is a framework on the JVM that offers an abstraction layer to build Slack apps quickly using modern platform features. Refer to Getting Started with Bolt for detailed instructions.

package hello;

import com.slack.api.bolt.App;
import com.slack.api.bolt.jetty.SlackAppServer;

public class MyApp {
  public static void main(String[] args) throws Exception {
    // App expects env variables (SLACK_BOT_TOKEN, SLACK_SIGNING_SECRET)
    App app = new App();

    app.command("/hello", (req, ctx) -> {
      return ctx.ack(":wave: Hello!");
    });

    SlackAppServer server = new SlackAppServer(app);
    server.start(); // http://localhost:3000/slack/events
  }
}

For Socket Mode enabled apps, Getting Started with Bolt (Socket Mode) is available.

package hello;

import com.slack.api.bolt.App;
import com.slack.api.bolt.socket_mode.SocketModeApp;

public class MyApp {
  public static void main(String[] args) throws Exception {
    // App expects an env variable: SLACK_BOT_TOKEN
    App app = new App();

    app.command("/hello", (req, ctx) -> {
      return ctx.ack(":wave: Hello!");
    });

    // SocketModeApp expects an env variable: SLACK_APP_TOKEN
    new SocketModeApp(app).start();
  }
}

Slack API Client

slack-api-client contains simple, easy-to-use, and flexibly configurable HTTP clients for making requests to Slack APIs. Refer to API Client Basics for details.

import com.slack.api.Slack;
import com.slack.api.methods.response.chat.ChatPostMessageResponse;

Slack slack = Slack.getInstance();
String token = System.getenv("SLACK_TOKEN");

ChatPostMessageResponse response = slack.methods(token).chatPostMessage(req -> req
  .channel("C1234567") // Channel ID
  .text(":wave: Hi from a bot written in Java!"));

Modules

The table below shows all the available modules in the Slack Java SDK. All of them have the same latest version as we release all at the same time, even in the case that some don't have any changes apart from updates on their dependency side.

All released versions are available on the Maven Central repositories. The latest version is: Maven Central

Bolt & Built-in Extensions

groupId:artifactId Description
com.slack.api:bolt Bolt is a framework that offers an abstraction layer to build Slack apps safely and quickly. The most commonly used Servlet environment is supported out-of-the-box.
com.slack.api:bolt-socket-mode This module offers a handy way to run Bolt apps through Socket Mode connections.
com.slack.api:bolt-jetty This module offers a handy way to run Bolt apps on the Java EE compatible Jetty HTTP server (9.x).
com.slack.api:bolt-jakarta-jetty This module offers a handy way to run Bolt apps on the Jakarta EE compatible Jetty HTTP server.
com.slack.api:bolt-aws-lambda This module offers a handy way to run Bolt apps on AWS API Gateway + Lambda.
com.slack.api:bolt-google-cloud-functions This module offers a handy way to run Bolt apps on Google Cloud Functions.
com.slack.api:bolt-micronaut This is an adapter for Micronaut to run Bolt apps on top of it.
com.slack.api:bolt-helidon This is an adapter for Helidon SE to run Bolt apps on top of it.
com.slack.api:bolt-http4k This is an adapter for http4k to run Bolt apps on top of any of the multiple server backends that the library supports.
com.slack.api:bolt-ktor This is an adapter for Ktor to run Bolt apps on top of it.

Foundation Modules

groupId:artifactId Description
com.slack.api:slack-api-model This is a collection of the classes representing the Slack core objects such as conversations, messages, users, blocks, and surfaces. As this is an essential part of the SDK, all other modules depend on this.
com.slack.api:slack-api-model-kotlin-extension This contains the Block Kit Kotlin DSL builder, which allows you to define block kit structures via a Kotlin-native DSL.
com.slack.api:slack-api-client This is a collection of the Slack API clients. The supported are Basic API Methods, Socket Mode, RTM (Real Time Messaging) API, SCIM API, Audit Logs API, and Status API.
com.slack.api:slack-api-client-kotlin-extension This contains extension methods for various slack client message builders so you can seamlessly use the Block Kit Kotlin DSL directly on the Java message builders.
com.slack.api:slack-app-backend This module is a set of Slack app server-side handlers and data classes for Events API, Interactive Components, Slash Commands, Actions, and OAuth flow. These are used by Bolt framework as the foundation of it in primitive layers.

Requirements

The SDK supports OpenJDK 8 and higher LTS versions.

Users can expect every single patch release has been done after verifying functionality by running the basic CI builds with all LTS versions and all the unit tests have passed at least on the latest LTS version. We don't run comprehensive verifications with all OpenJDK distributions but it should be working with all of them.

Getting Help

If you get stuck, we’re here to help. The following are the best ways to get assistance working through your issue:

Important Notice for jSlack users

The jSlack project has been transferred to @slackapi. The jSlack maintenance releases for security issues or major bugfixes will be continued at https://github.com/seratch/jslack-maintenance-releases .

Contributing

We welcome contributions from everyone! Please check out our Contributor's Guide for how to contribute in a helpful and collaborative way.

java-slack-sdk's People

Contributors

ajurasz avatar d-subrahmanyam avatar dashorst avatar dependabot[bot] avatar domdomegg avatar eamelink avatar emanguy avatar filmaj avatar frankspitulski avatar gavinbunney avatar howyi avatar hrothwell avatar ikolomiets avatar jasonmullins avatar joeltoby avatar jongilmore avatar kingbuzzer avatar lfbrandao avatar marcwrobel avatar musketyr avatar newcron avatar ramzimaalej avatar rocketraman avatar seratch avatar slushpupie avatar stevengill avatar svc-ghe-snow avatar sylvainjuge avatar williambergamin avatar zimeg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

java-slack-sdk's Issues

remove extra dependencies....

non documented dependencies:
If it is "simple" why do I need to keep adding libraries.

okhttp3/RequestBody
slf4j
org.slf4j.impl.StaticLoggerBinder
lombok

Implement `conversations` API

From the docs:

The new Slack Conversations API provides your app with a unified interface to work with all the channel-like things encountered in Slack; public channels, private channels, direct messages, group direct messages, and our newest channel type, Shared Channels.The new Slack Conversations API provides your app with a unified interface to work with all the channel-like things encountered in Slack; public channels, private channels, direct messages, group direct messages, and our newest channel type, Shared Channels.

@seratch - I'm happy to do this if you agree that it adds value?

Can't post as a user

Hey 👋 @seratch If I read this code:
https://github.com/seratch/jslack/blob/master/src/main/java/com/github/seratch/jslack/shortcut/impl/ShortcutImpl.java#L122

post and postAsBot do exactly the same thing, for post the call of _post() should be _post(channel, text, Collections.emptyList(), true); (with true and not false)

    @Override
    public ChatPostMessageResponse post(ChannelName channel, String text) throws IOException, SlackApiException {
        return _post(channel, text, Collections.emptyList(), false);
    }

    @Override
    public ChatPostMessageResponse postAsBot(ChannelName channel, String text) throws IOException, SlackApiException {
        return _post(channel, text, Collections.emptyList(), false);
    }

Refactor all tests with Mock API calls

Mocking Slack API requests instead of making real calls will improve the tests and enable us to test calls that cannot be tested in an automated fashion without mocks such as dialog.open requests.

Slack's API team recently released Steno:

Slack app testing companion - Record and Replay your HTTP requests, both incoming and outgoing

I would like to integrate Steno into JSlack and replace all existing tests with Steno mock scenarios.

Few Questions on Slack

  1. How can I send a scrollable data grid to slack as an incoming webhook response? Given it supports the only image format.
  2. Can I send an image object as streaming content to incoming webhook response? or I need to publish this image object as an image in some folder and provide that URL as an attachment.
  3. Now I have an app on my slack account. How do I make it available for my client's account and their workspace?
  4. How about security. Can I put security on this slack app(which I created) so that only legitimate user, workspaces and accounts can only access this App?
    • My workflow - Every time a question is asked on Slack app, it hits my rest endpoint and once the question is processed I post the answer on incoming webhook.
      How do I put security on each such transactions? so that it is secured.

I am little confused in terms of where and all security is required. I did go through manage distribution and OAuth sections in Slack doc but couldn't completely comprehend. Where to start, etc.

Appreciate, if you can answer my queries. I am simultaneously checking with Slack Team as well.

Access to RTMStartResponse

I want access to RTMStartResponse. Unfortunately RTMClient rtm = new Slack().rtm(token) (as suggested in the README) doesn't facilitate that.

After looking at https://github.com/seratch/jslack/blob/master/src/main/java/com/github/seratch/jslack/Slack.java#L66 I went for something like this.

Slack slack = Slack.getInstance();
RTMStartResponse rtmStartResponse = slack.methods()
			.rtmStart(RTMStartRequest.builder().token(token).build());
RTMClient rtmClient = new RTMClient(rtmStartResponse.getUrl());

System.out.println(rtmStartResponse.getTeam().getName());
System.out.println(rtmStartResponse.getUsers().size());

And I have the access that I'm after.

Although I'm only using public methods, I'm wondering if this is likely to be safe going forward. Am I using anything that not intended to be part of the public API?

Allow configuring URL prefixes

First, thanks for your sharing jslack 👍

I'm using the Slack Methods client and I noticed the API prefix is hardcoded in a static final variable in MethodsClientImpl#ENDPOINT_URL_PREFIX. It'd be very useful if we could override those prefixes from outside.

A common scenario is when you want to use something like wiremock for writing integration tests using mock calls. In those cases you need to hit the stub server instead of the real one, so you need to configure a different URL prefix. You'll need this for #36 too. I could send you a PR if you don't mind.

session closed: 0, reason: The decoded text message was too big for the output buffer and the endpoint does not support partial messages

Long-time user, first-time reporter here. Thanks for building this library. It is great.

From time to time, my app is rendered useless with this message

2019-02-06 14:30:49.982 DEBUG [ient-SecureIO-1]               c.g.s.j.a.r.RTMClient                   -- session closed: 0, reason: The decoded text message was too big for the output buffer and the endpoint does not support partial messages

Once that happens, the com.github.seratch.jslack.Slack instance needs to be discarded. Since I'm creating it as a Spring Bean, and the instance is autowired, I end up restarting the application.

My current close handler only updates the health of the application and lets the unhealthy check take care of restarting the application.

            rtm.addCloseHandler {
                log.error("Session Closed: $it")
                slackHealth.healthy = false
                slackHealth.reason = it.reasonPhrase
            }
  1. Is there a strategy to recover from this?
  2. Can this problem be avoided?

Bubbling up HTTP 429s (too many requests)

Slack recently introduced a new rate-limiting system which is detailed here.

As part of this, API methods now return an HTTP 429 response (too many requests) if limits are exceeded. As is best practice, the 429 response is accompanied by a retry-after header. This type of error is not returned as a JSON error object, but as a simple HTTP response. Example from the documentation section for 'responding to rate limit conditions':

HTTP/1.1 429 Too Many Requests

Retry-After: 30

Although it is correctly the responsibility of the client and not JSlack to implement rate limiting, the issue is that this error is not currently bubbled up to the client. There is no way for example to access the value of the Retry-After header.

@seratch Do you have any thoughts on the best way to handle these HTTP 429 responses in JSlack? Would it make sense to add a special case to the SlackHttpClient.buildJsonResponse method after the existing HTTP 200 handling? E.G:

if (response.code() == 200) {
    ...
} else if (response.code() == 429) {
    ...
}

I guess that would also require changes to SlackApiErrorResponse? Is there a better design?

Proxy support for RTM Client

Does anyone modify RTM client for proxy support. I have proxy setup between my client and slack channel. I tried to do it in RTMClient class but websocket does not have any method to handle the proxy. Please share your code..

No class def found during runtime.

Hi seratch !

java.lang.NoClassDefFoundError: Failed resolution of: Lorg/slf4j/LoggerFactory;
at com.github.seratch.jslack.common.http.SlackHttpClient.(SlackHttpClient.java:12)
at com.github.seratch.jslack.Slack.(Slack.java:31)
at com.redgold.raktim.cs727.MainActivity.openSlackGame(MainActivity.java:89)

This error keeps coming. Apparently your jar in Maven repository is not dependency complete? Please tell me a correct way to include the jar. Or, please, give me a workaround. I am depending on it.

Action button confirmation should have property name "confirm" instead of "confirmation"

Current implementation of button with confirmation doesn't show the actual confirmation since uses incorrect attribute name:
Current version:

{
    "name": "game",
    "text": "Thermonuclear War",
    "style": "danger",
    "type": "button",
    "value": "war",
        "confirmation": {
            "title": "Are you sure?",
            "text": "Wouldn't you prefer a good game of chess?",
            "ok_text": "Yes",
            "dismiss_text": "No"
    }
}

Correct version:

{
    "name": "game",
    "text": "Thermonuclear War",
    "style": "danger",
    "type": "button",
    "value": "war",
        "confirm": {
            "title": "Are you sure?",
            "text": "Wouldn't you prefer a good game of chess?",
            "ok_text": "Yes",
            "dismiss_text": "No"
    }
}

Problem is here:
https://github.com/seratch/jslack/blob/e633154c85c2a1a5b358b41185a5c663559dd71b/src/main/java/com/github/seratch/jslack/api/model/Action.java#L45

Unable to post response message back to slack channel

Hi this might be a bit noddy so forgive me if I'm missing something, I've worked off your docs and have produced this section of code to post a response back as a bot user to the originating channel.

Slack slack = Slack.getInstance();
ApiToken token = ApiToken.of("TOKEN");

if(message.event.text.contains("test")) {
ChatPostMessageResponse postResponse = slack.methods().chatPostMessage(
ChatPostMessageRequest.builder()
.token(token.getValue())
.channel("")
.text("Hello from bot")
.asUser(false)
.username("@abot")
.build());
assert postResponse.isOk();
}

There seems to be an issue and I'm not sure if its the code or outside of that.

The exception that I'm getting is connect timed out.
I'm using ngrok to handle the tunnelling between slack and my local machine and have worked with it well enough over the last few days to handle communication between a service and a slash command, with the system set up in the same way I'm not having any issues.

I am unable to get the connection between my local machine and slack to work correctly. Am I missing something.
__

Attachment misses author_subname field

Hey,

Could you please add author_subname in Attachment?
Would also need a new build and maven delivery :)

Thanks in advance, and again congratulations for the work done!

Jboss Wildfly 10.0.1 NoSuchMethodException com.github.seratch.jslack.api.rtm.RTMClient.<init>()

I was using Spring annotation inject the Slack class, but the server failed to deploy and throws

java.lang.RuntimeException: java.lang.NoSuchMethodException: com.github.seratch.jslack.api.rtm.RTMClient.<init>()

The full stack track of exception is:

01:00:50,366 INFO  [io.undertow.websockets.jsr] (ServerService Thread Pool -- 97) UT026004: Adding annotated client endpoint class com.github.seratch.jslack.api.rtm.RTMClient
01:00:50,371 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 97) MSC000001: Failed to start service jboss.undertow.deployment.default-server.default-host./axelerator: org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./project: java.lang.RuntimeException: javax.websocket.DeploymentException: UT003024: Web socket deployment failed
	at org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:85) [wildfly-undertow-10.1.0.Final.jar:10.1.0.Final]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [rt.jar:1.8.0_191]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [rt.jar:1.8.0_191]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [rt.jar:1.8.0_191]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [rt.jar:1.8.0_191]
	at java.lang.Thread.run(Thread.java:748) [rt.jar:1.8.0_191]
	at org.jboss.threads.JBossThread.run(JBossThread.java:320)
Caused by: java.lang.RuntimeException: javax.websocket.DeploymentException: UT003024: Web socket deployment failed
	at io.undertow.websockets.jsr.Bootstrap.handleDeployment(Bootstrap.java:101)
	at io.undertow.servlet.core.DeploymentManagerImpl.handleExtensions(DeploymentManagerImpl.java:255)
	at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:159)
	at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:100) [wildfly-undertow-10.1.0.Final.jar:10.1.0.Final]
	at org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:82) [wildfly-undertow-10.1.0.Final.jar:10.1.0.Final]
	... 6 more
Caused by: javax.websocket.DeploymentException: UT003024: Web socket deployment failed
	at io.undertow.websockets.jsr.ServerWebSocketContainer.addEndpointInternal(ServerWebSocketContainer.java:660)
	at io.undertow.websockets.jsr.ServerWebSocketContainer.addEndpoint(ServerWebSocketContainer.java:586)
	at io.undertow.websockets.jsr.Bootstrap.handleDeployment(Bootstrap.java:95)
	... 10 more
Caused by: java.lang.RuntimeException: java.lang.NoSuchMethodException: com.github.seratch.jslack.api.rtm.RTMClient.<init>()
	at org.jboss.as.ee.component.ReflectiveClassIntrospector.createFactory(ReflectiveClassIntrospector.java:59) [wildfly-ee-10.1.0.Final.jar:10.1.0.Final]
	at org.jboss.as.ee.component.ComponentRegistry.createInstanceFactory(ComponentRegistry.java:76) [wildfly-ee-10.1.0.Final.jar:10.1.0.Final]
	at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$ComponentClassIntrospector.createInstanceFactory(UndertowDeploymentInfoService.java:1444) [wildfly-undertow-10.1.0.Final.jar:10.1.0.Final]
	at io.undertow.websockets.jsr.ServerWebSocketContainer.addEndpointInternal(ServerWebSocketContainer.java:654)
	... 12 more
Caused by: java.lang.NoSuchMethodException: com.github.seratch.jslack.api.rtm.RTMClient.<init>()
	at java.lang.Class.getConstructor0(Class.java:3082) [rt.jar:1.8.0_191]

When I deploy the project to Jboss standalone, there is no problem, any suggestion on how to fix this problem.

  • jslack: 1.1.6

  • jboss/wildfly:10.1.0.Final

Request to add to Message object

Hi,

Love this project, saving me a bunch of time and effort! Thank you!

Can you add the bot_id, username and subtype to the Message object please? If you post with a custom username it is stored in the Message username field which I can't access.

cheers
Martin

Library doesn't want to be compiled with 1.7 target

Hi, is it possible to use this library with java 1.6-1.7 in Android projects ? When i added it to our gradle build, i got this error :

Error:Execution failed for task ':sdk:transformClassesWithDexForDebugAndroidTest'.
> com.android.build.api.transform.TransformException: java.lang.RuntimeException: java.lang.RuntimeException: Unable to pre-dex '/Users/andrewzakordonets/.m2/repository/com/github/seratch/jslack/1.0.8/jslack-1.0.8.jar' to '/Users/andrewzakordonets/Work/Vimpelcom/veon-sdk/sdk/build/intermediates/transforms/dex/androidTest/debug/folders/1000/10/jslack-1.0.8_6cfaf33714fc85887f68054544efa05c861e4aee'

ConfirmationMessage don't appear to work.

Following the code it appears the naming convention for confirmation messages is incompatible with Slack at the moment.

I pinpointed the issue to here String json = GsonFactory.createSnakeCase().toJson(req.getAttachments()); in MethodsClientImpl.java

The outputted json includes "confirmation_message". It should be "confirm".

The primary issue is the class name from what I can tell.
ConfirmationMessage -> Confirm should fix the issue.

I'm not sure if the issue has arisen due to a change in Slack.

Below is the supporting documentation for the confirm button syntax (I don't know if they changed prior)
https://api.slack.com/docs/message-buttons

MethodsClientImpl is difficult to subclass

MethodsClientImpl implements over 130 API methods from the MethodsClient interface. Each of these methods in turn invokes one of three private doPost... methods.

I would like to extend MethodsClientImpl within my project to add some custom rate limiting, but this would require overriding each of the 130+ methods (as the private doPost... methods cannot be overridden).

Changing the access modifiers on the three doPost methods from private to protected would make it much easier for clients to write custom MethodsClient implementations.

Methods users.setPhoto and users.deletePhoto

Hello guys! I'm really enjoying using this library, congratulations.
I did not find the implementation for the "users.setPhoto" and "users.deletePhoto" methods.
Is there any future plan to be implemented? Thank you.

payload.channel() doesn't work for me

in your src-files' comments i found the description of the Payload's "channel()"-method
if i'm not wrong, i should be able to write to another channel, than the webhook specifies
for me that doesn't work

i created a webhook for my "#general" channel, and want to send a message to the "#random" channel

Payload payload = Payload.builder() .channel("#random")

i've used that code at payload's building, but it still sends to "#general"
is there something I'm not seeing?
thx

Upgrade oss-parent to 9

The latest version of the oss-parent POM is 9. jslack currently uses version 7.

I'll craft a PR for this, but need to reference an issue nr in it.

RMI thread Deadlock

take() is not the best solution for theBlockingQueue<Runnable>

System props

awt.toolkit=sun.lwawt.macosx.LWCToolkit
file.encoding=UTF-8
file.separator=/
gopherProxySet=false
java.awt.graphicsenv=sun.awt.CGraphicsEnvironment
java.awt.printerjob=sun.lwawt.macosx.CPrinterJob
java.class.path=target/Smoker.jar
java.class.version=55.0
java.home=/Library/Java/JavaVirtualMachines/openjdk-11.0.1.jdk/Contents/Home
java.io.tmpdir=/var/folders/2h/mjw8k1v93z9_t746q075t7j80000gp/T/
java.library.path=/Users/oshabur/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.
java.rmi.server.randomIDs=true
java.runtime.name=OpenJDK Runtime Environment
java.runtime.version=11.0.1+13
java.specification.name=Java Platform API Specification
java.specification.vendor=Oracle Corporation
java.specification.version=11
java.vendor=Oracle Corporation
java.vendor.url=http://java.oracle.com/
java.vendor.url.bug=http://bugreport.java.com/bugreport/
java.vendor.version=18.9
java.version=11.0.1
java.version.date=2018-10-16
java.vm.compressedOopsMode=Zero based
java.vm.info=mixed mode
java.vm.name=OpenJDK 64-Bit Server VM
java.vm.specification.name=Java Virtual Machine Specification
java.vm.specification.vendor=Oracle Corporation
java.vm.specification.version=11
java.vm.vendor=Oracle Corporation
java.vm.version=11.0.1+13
jdk.debug=release
line.separator=\n
os.arch=x86_64
os.name=Mac OS X
os.version=10.14.1
path.separator=:
sun.arch.data.model=64
sun.boot.library.path=/Library/Java/JavaVirtualMachines/openjdk-11.0.1.jdk/Contents/Home/lib
sun.cpu.endian=little
sun.cpu.isalist=
sun.io.unicode.encoding=UnicodeBig
sun.java.command=target/Smoker.jar -Dslack.bot.access.list=oshaburov,oshaburov
sun.java.launcher=SUN_STANDARD
sun.jnu.encoding=UTF-8
sun.management.compiler=HotSpot 64-Bit Tiered Compilers
sun.os.patch.level=unknown

Parking threads
image

CPU Time
image

CPU samples
image

Full thread dump
thread_dump.txt

Code

public class Smoker {
    private static boolean isRun = false;
    private static final Logger LOG = LoggerFactory.getLogger(Smoker.class);

    public static void main(String[] args) {
        isRun = true;
        String token = BaseMessageHandler.getToken();
        try (RTMClient rtm = new Slack().rtm(token)) {
            LOG.info("Real Time Messaging client started");
            rtm.addMessageHandler(new UserMessageHandler());
            rtm.addMessageHandler(new GroupMessageHandler());
            rtm.addErrorHandler(new ErrorHandler());
            rtm.connect();
            addShutdownHook();
            while (isRun) {
                sleep(1000);
            }
        } catch (Throwable e) {
            LOG.error("Unexpected exception. Service died.", e);
        } finally {
            Runtime.getRuntime().exit(1);
        }
    }
}

Log example
image

image

Common interfaces for Request and Response

Hi @seratch,

Thanks for open-sourcing the great library.
What's your opinion on providing two common marker interfaces to be implemented by all request and response objects? I.E. All requests implement request and all responses implement response.

In my opinion it would be extremely useful for developers in a number of situations I've encountered:

  1. It would enable clients to decorate requests / response to add additional client data.
  2. Type erasure (and the like). The ability to do Processor<Request> would be a major plus.

If you're in favour, I'd be more than happy to create a pull request. Please let me me know if you'd like me to do so.

Cheers, Joel

How do I mention a slack user?

On the rest-api :
I can perform that using the below message.

{"text": "@username", "link_names": "1"}";

Just looking for the corresponding jslack code.

Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.