-
Notifications
You must be signed in to change notification settings - Fork 7
Implementing Plugins
Stefan Zier edited this page Aug 15, 2015
·
1 revision
Every plugin is an Akka actor and receives all Slack messages seen by sumobot as IncomingMessage. Along with the text of the message, IncomingMessage contains a few other fields like the channel, and whether the message is addressed to the bot directly. All of this information is used to match IncomingMessage and respond if appropriate.
Here is a minimal exmaple of a plugin implementation:
class HelloWorld extends BotPlugin {
override protected def help: String =
s"""
|I'll say hello to anything:
|
|hello <something> - I'll just say hello.
""".stripMargin
private val Hello = matchText("hello (\\w+)")
override protected def receiveIncomingMessage: ReceiveIncomingMessage = {
case message@IncomingMessage(Hello(who), true, _, _) =>
message.respond(s"Hello $who")
}
}
}Here are a few recommendations for designing interactions with the bot:
- Keep it light and fun.
- Design your regular expressions to be fairly permissive, i.e. make it easy for people to "get it right".
- Write your help text in the first person.
- Use
Emotionswhere applicable.