Created
July 16, 2015 06:23
-
-
Save pjazdzewski1990/f7caec4a137b1a78639f 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
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