Skip to content

Instantly share code, notes, and snippets.

@pjazdzewski1990
Created July 16, 2015 06:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pjazdzewski1990/e0922413dc9d260eb97b to your computer and use it in GitHub Desktop.
Save pjazdzewski1990/e0922413dc9d260eb97b to your computer and use it in GitHub Desktop.
object BotRunner extends Shutdownable {
val system = ActorSystem("SlackBotSystem")
val eventBus = new MessageEventBus
val slackBot = system.actorOf(Props(classOf[SlackBotActor], new ExampleBotsBundle(), eventBus, this, None), "slack-bot")
var botInfo: Option[BotInfo] = None
def main(args: Array[String]) {
println("SlackBot started")
println("With api key: " + SlackConfig.apiKey)
try {
slackBot ! Start
system.awaitTermination()
println("Shutdown successful...")
} catch {
case e: Exception =>
println("An unhandled exception occurred...", e)
system.shutdown()
system.awaitTermination()
}
}
sys.addShutdownHook(shutdown())
override def shutdown(): Unit = {
slackBot ! WebSocket.Release
system.shutdown()
system.awaitTermination()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment