Sha256: 60a8e429f566ba6dc1f3f4852ce513057b9fc6d603a4e663eb70baeb9e27351d
Contents?: true
Size: 536 Bytes
Versions: 2
Compression:
Stored size: 536 Bytes
Contents
require 'calc' # A simple calculator. This delegates all calculations to the 'calc' # gem. class Robut::Plugin::Calc < Robut::Plugin::Base # Perform the calculation specified in +message+, and send the # result back. def handle(time, sender_nick, message) if sent_to_me?(message) && words(message).first == 'calc' calculation = words(message, 'calc').join(' ') begin reply("#{calculation} = #{Calc.evaluate(calculation)}") rescue reply("Can't calculate that.") end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
robut-0.2.1 | lib/robut/plugin/calc.rb |
robut-0.2.0 | lib/robut/plugin/calc.rb |