Skip to content

Instantly share code, notes, and snippets.

@pjazdzewski1990
Created July 16, 2015 06:23
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/f7caec4a137b1a78639f to your computer and use it in GitHub Desktop.
Save pjazdzewski1990/f7caec4a137b1a78639f to your computer and use it in GitHub Desktop.
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