X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=data%2Frbot%2Fplugins%2Fmath.rb;h=081c9c042378cf761c5670e5df82dc34df3f6238;hb=052217de30c59206d7025b582d4604557a747470;hp=f54733b33c0435e3e6a0d2ebd32a5e70f422b407;hpb=e7c109b7f575d4c9e14ce1b523697a943320d7bd;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git diff --git a/data/rbot/plugins/math.rb b/data/rbot/plugins/math.rb index f54733b3..081c9c04 100644 --- a/data/rbot/plugins/math.rb +++ b/data/rbot/plugins/math.rb @@ -44,7 +44,7 @@ class MathPlugin < Plugin val = Math.exp($2).to_s expr.gsub!(/#{Regexp.escape exp}/, "+#{val}") end - + while expr =~ /^\s*(dec2hex\s*(\d+))\s*\?*/ exp = $1 val = sprintf("%x", $2) @@ -56,13 +56,13 @@ class MathPlugin < Plugin while expr =~ /(log\s*((\d+\.?\d*)|\d*\.?\d+))\s*/ exp = $1 res = $2 - + if res == 0 val = "Infinity" else val = Math.log(res).to_s end - + expr.gsub!(/#{Regexp.escape exp}/, "+#{val}") end @@ -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