From a708e4aa798a3523eeb4bb648f18d6451a0758e6 Mon Sep 17 00:00:00 2001 From: Edward Powell Date: Mon, 27 Jan 2014 21:12:28 -0500 Subject: [PATCH] [calc] Account for silly non-Anglophones Fix #435 --- willie/modules/calc.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/willie/modules/calc.py b/willie/modules/calc.py index 8a76dc3ae3..82de164abb 100644 --- a/willie/modules/calc.py +++ b/willie/modules/calc.py @@ -6,6 +6,7 @@ http://willie.dfbta.net """ +from __future__ import unicode_literals import re from willie import web @@ -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: