X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=data%2Frbot%2Fplugins%2Fmath.rb;h=9dd35c985fabdb2f53be5e942b1a4644aab6a4f5;hb=1fa68bb86705b0e1e70d9d655bbfd8e1e13eb093;hp=945b2c78abf915742511249a012f27741ad63f52;hpb=38212f89578111324c096d9bab55f2225a1d4d76;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git diff --git a/data/rbot/plugins/math.rb b/data/rbot/plugins/math.rb index 945b2c78..9dd35c98 100644 --- a/data/rbot/plugins/math.rb +++ b/data/rbot/plugins/math.rb @@ -85,8 +85,8 @@ class MathPlugin < Plugin expr.gsub!(/\bpercent/, "*0.01") expr.gsub!(/\% of\b/, "*0.01*") expr.gsub!(/\%/, "*0.01") - expr.gsub!(/\bsquare root of (\d+)/, '\1 ** 0.5 ') - expr.gsub!(/\bcubed? root of (\d+)/, '\1 **(1.0/3.0) ') + expr.gsub!(/\bsquare root of (\d+(\.\d+)?)/, '\1 ** 0.5 ') + expr.gsub!(/\bcubed? root of (\d+(\.\d+)?)/, '\1 **(1.0/3.0) ') expr.gsub!(/ of /, " * ") expr.gsub!(/(bit(-| )?)?xor(\'?e?d( with))?/, "^") expr.gsub!(/(bit(-| )?)?or(\'?e?d( with))?/, "|") @@ -110,9 +110,9 @@ class MathPlugin < Plugin answer = "a number with >30 digits..." end end - m.reply answer + m.reply answer.to_s rescue Exception => e - error "couldn't evaluate expression \"#{m.params}\": #{e.inspect}" + error e m.reply "illegal expression \"#{m.params}\"" return end