Skip to content

Instantly share code, notes, and snippets.

@seratch
Created March 6, 2020 08:08
Show Gist options
  • Save seratch/9fa8980b9469993d03a5503053a26bf0 to your computer and use it in GitHub Desktop.
Save seratch/9fa8980b9469993d03a5503053a26bf0 to your computer and use it in GitHub Desktop.
Bolt for Java 1.0.0-RC1
plugins {
id("application")
}
java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
repositories {
mavenCentral()
}
dependencies {
implementation("com.slack.api:bolt:1.0.0-RC1")
implementation("com.slack.api:bolt-jetty:1.0.0-RC1")
implementation("org.slf4j:slf4j-simple:1.7.30")
}
application {
mainClassName = "hello.MyApp"
}
run {
// gradle run -DslackLogLevel=debug
systemProperty "org.slf4j.simpleLogger.log.com.slack.api", System.getProperty("slackLogLevel")
}
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 {
var app = new App();
app.message("Are you ready?", (req, ctx) -> {
var mesage = "<@" + req.getEvent().getUser() + "> Let's go!";
var result = ctx.say(mesage);
ctx.logger.info("result: {}", result);
return ctx.ack();
});
var server = new SlackAppServer(app);
server.start(); // http://localhost:3000/slack/events
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment