scala-slack-web


License

License

MIT
Categories

Categories

Scala Languages
GroupId

GroupId

com.github.agaro1121
ArtifactId

ArtifactId

scala-slack-web_2.11
Last Version

Last Version

0.2.27
Release Date

Release Date

Type

Type

jar
Description

Description

scala-slack-web
scala-slack-web
Project URL

Project URL

https://github.com/agaro1121/scala-slack-client
Project Organization

Project Organization

com.github.agaro1121
Source Code Management

Source Code Management

https://github.com/agaro1121/scala-slack-client

Download scala-slack-web_2.11

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.agaro1121/scala-slack-web_2.11/ -->
<dependency>
    <groupId>com.github.agaro1121</groupId>
    <artifactId>scala-slack-web_2.11</artifactId>
    <version>0.2.27</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.agaro1121/scala-slack-web_2.11/
implementation 'com.github.agaro1121:scala-slack-web_2.11:0.2.27'
// https://jarcasting.com/artifacts/com.github.agaro1121/scala-slack-web_2.11/
implementation ("com.github.agaro1121:scala-slack-web_2.11:0.2.27")
'com.github.agaro1121:scala-slack-web_2.11:jar:0.2.27'
<dependency org="com.github.agaro1121" name="scala-slack-web_2.11" rev="0.2.27">
  <artifact name="scala-slack-web_2.11" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.agaro1121', module='scala-slack-web_2.11', version='0.2.27')
)
libraryDependencies += "com.github.agaro1121" % "scala-slack-web_2.11" % "0.2.27"
[com.github.agaro1121/scala-slack-web_2.11 "0.2.27"]

Dependencies

compile (15)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.11.12
com.github.agaro1121 : scala-slack-core_2.11 jar 0.2.27
com.typesafe.akka : akka-http_2.11 jar 10.1.3
com.typesafe.akka : akka-stream_2.11 jar 2.5.13
com.typesafe.akka : akka-testkit_2.11 jar 2.5.13
org.typelevel : cats-core_2.11 jar 1.0.1
com.github.pureconfig : pureconfig_2.11 jar 0.9.1
de.heikoseeberger : akka-http-circe_2.11 jar 1.21.0
com.typesafe.scala-logging : scala-logging_2.11 jar 3.9.0
ch.qos.logback : logback-classic jar 1.2.3
io.circe : circe-core_2.11 jar 0.9.3
io.circe : circe-generic_2.11 jar 0.9.3
io.circe : circe-generic-extras_2.11 jar 0.9.3
io.circe : circe-parser_2.11 jar 0.9.3
io.circe : circe-shapes_2.11 jar 0.9.3

test (1)

Group / Artifact Type Version
org.scalatest : scalatest_2.11 jar 3.0.5

Project Modules

There are no modules declared in this project.

README

Updates coming soon !!!!

This is my attempt to provide a library that will allow users to create bots.

The first thing you need to do is create a token.conf file with one configuration.

bot-token = "xoxb-..."

You can create your bot on slack and obtain a token.

Add the following to your build.sbt

resolvers += Resolver.bintrayRepo("agaro1121", "com.github.agaro1121")

libraryDependencies += "com.github.agaro1121" %% "scala-slack-rtm-lite" % "0.2.26"

The next thing you require is a class that extends AbilityToRespondToRtm This will be an actor It will look like this:

import akka.actor.{ActorRef, ActorSystem, Props}
import akka.stream.ActorMaterializer
import com.github.agaro1121.rtmlite
import com.github.agaro1121.rtmlite.client.AbilityToRespondToRtm
import com.github.agaro1121.sharedevents.models.SlackMessage

object TestBot {
  def props: Props = Props(new TestBot())
}

class TestBot extends AbilityToRespondToRtm {
  override def receiveWithWsActorToRespond(slack: ActorRef): Receive = {

    case msg@SlackMessage(text, _, _, _, _) =>
      println(s"Test Bot received Abstract message: $text")
      slack ! msg.replyWithMessage(s"Test Bot received Abstract message: $text")


  }
}

object TestBotTester extends App {

  implicit val system = ActorSystem("main")
  implicit val mat = ActorMaterializer()
  import system.dispatcher

  val rtmClient = rtmlite.client.RtmClient()
  val testBot = system.actorOf(TestBot.props)

  rtmClient.connectWithUntypedActor(testBot).onComplete(println)
}

You can also interact with Slack with the following:

  • PartialFunction[SlackMessage, SlackMessage]
  • PartialFunction[SlackMessage, Future[SlackMessage]]
import akka.actor.ActorSystem
import akka.stream.ActorMaterializer
import com.github.agaro1121.rtmlite
import com.github.agaro1121.sharedevents.models.SlackMessage

object TestBotUsingPf {
  val handler: PartialFunction[SlackMessage, SlackMessage] = {
    case msg@SlackMessage(text, _, _, _, _) =>
      println(s"Test Bot received Abstract message: $text")
      msg.replyWithMessage(s"Test Bot received Abstract message: $text")
  }
}

object TestBotTester extends App {

  implicit val system = ActorSystem("main")
  implicit val mat = ActorMaterializer()
  import system.dispatcher

  val rtmClient = rtmlite.client.RtmClient()

  rtmClient.connectWithPF(TestBotUsingPf.handler).onComplete(println)
}

Versions

Version
0.2.27
0.2.25
0.2.24
0.2.23
0.2.22
0.2.21
0.2.18
0.2.17
0.2.16
0.2.13
0.2.11
0.2.10
0.2.8
0.2.7
0.2.6
0.2.5