Skip to content

Commit

Permalink
[calc] Account for silly non-Anglophones
Browse files Browse the repository at this point in the history
Fix #435
  • Loading branch information
embolalia committed Jan 28, 2014
1 parent e63d27e commit a708e4a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion willie/modules/calc.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
http://willie.dfbta.net
"""
from __future__ import unicode_literals

import re
from willie import web
Expand All @@ -22,8 +23,10 @@ def c(bot, trigger):
"""Google calculator."""
if not trigger.group(2):
return bot.reply("Nothing to calculate.")
# Account for the silly non-Anglophones and their silly radix point.
eqn = trigger.group(2).replace(',', '.')
try:
result = str(eval_equation(trigger.group(2)))
result = str(eval_equation(eqn))
except ZeroDivisionError:
result = "Division by zero is not supported in this universe."
except Exception:
Expand Down

0 comments on commit a708e4a

Please sign in to comment.