Giter VIP home page Giter VIP logo

spark-slack's Introduction

spark-slack

Speak Slack notifications and handle Slack Slash command responses.

Accessing the library

The code is accessible via JitPack by adding these lines to your build.sbt file:

resolvers += "jitpack" at "https://jitpack.io"
libraryDependencies += "com.github.mrpowers" % "spark-slack" % "v0.0.1"

The GitHub releases have JAR files attached if you'd like to add the code as a managed dependency.

Documentation

Here is a link to the latest documentation.

Slack notifications

Send messages to a Slack channel as follows:

import com.github.mrpowers.spark.slack.Notifier

val notifier = new Notifier("https://hooks.slack.com/services/your_secret_stuff")
notifier.speak("You are amazing", "general", ":wink:", "Frank")

Handle Slack Slash Commands

Read here to learn about Slash commands.

Slash commands send JSON responses in this format:

token=gIkuvaNzQIHg97ATvDxqgjtO
team_id=T0001
team_domain=example
channel_id=C2147483705
channel_name=test
user_id=U2147483697
user_name=Steve
command=/weather
text=94070
response_url=https://hooks.slack.com/commands/1234/5678

The SlashParser class converts the JSON response from Slack into a Scala object.

import com.github.mrpowers.spark.slack.slash_commands.SlashParser

val json = """{"token":"gIkuvaNzQIHg97ATvDxqgjtO","team_id":"T0001","team_domain":"example","channel_id":"C2147483705","channel_name":"test","user_id":"U2147483697","user_name":"Steve","command":"/weather","text":"94070","response_url":"https://hooks.slack.com/commands/1234/5678"}"""
val p = new SlashParser(json)
p.slashResponse.token // "gIkuvaNzQIHg97ATvDxqgjtO"

How to contribute

Feel free to report bugs or send a pull request.

We're nice and happy to receive any contributions ๐Ÿ˜‰

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.