scala-slack-rtm


License

License

MIT
Categories

Categories

Scala Languages
GroupId

GroupId

com.github.agaro1121
ArtifactId

ArtifactId

scala-slack-rtm_2.12
Last Version

Last Version

0.2.18
Release Date

Release Date

Type

Type

jar
Description

Description

scala-slack-rtm
scala-slack-rtm
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-rtm_2.12

How to add to project

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

Dependencies

compile (15)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.12.4
com.github.agaro1121 » scala-slack-rtm-lite_2.12 jar 0.2.18
com.typesafe.akka : akka-http_2.12 jar 10.0.10
com.typesafe.akka : akka-stream_2.12 jar 2.5.6
com.typesafe.akka : akka-testkit_2.12 jar 2.5.6
org.typelevel : cats_2.12 jar 0.9.0
com.github.pureconfig : pureconfig_2.12 jar 0.7.2
de.heikoseeberger : akka-http-circe_2.12 jar 1.12.0
com.typesafe.scala-logging : scala-logging_2.12 jar 3.5.0
ch.qos.logback : logback-classic jar 1.1.7
io.circe : circe-core_2.12 jar 0.8.0
io.circe : circe-generic_2.12 jar 0.8.0
io.circe : circe-generic-extras_2.12 jar 0.8.0
io.circe : circe-parser_2.12 jar 0.8.0
io.circe : circe-shapes_2.12 jar 0.8.0

test (1)

Group / Artifact Type Version
org.scalatest : scalatest_2.12 jar 3.0.1

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.18
0.2.17
0.2.16
0.2.13
0.2.12
0.2.11
0.2.10
0.2.8
0.2.7