Created
July 16, 2015 06:22
-
-
Save pjazdzewski1990/e0922413dc9d260eb97b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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