Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
override def act: Receive = {
case Command("calc", operation :: args, message) if args.length >= 1 =>
val op = possibleOperations.get(operation)
val response = op.map(f => {
val result = args.map(_.toDouble).reduceLeft( f(_,_) )
OutboundMessage(message.channel, s"Results is: $result")
}).getOrElse(OutboundMessage(message.channel, s"No operation $operation"))
publish(response)
case Command("calc", _, message) =>
publish(OutboundMessage(message.channel, s"No arguments specified!"))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.