summaryrefslogtreecommitdiff
path: root/calc.py
diff options
context:
space:
mode:
authorNEMESIS13cz <seke94@seznam.cz>2015-08-11 03:35:23 +0200
committerNEMESIS13cz <seke94@seznam.cz>2015-08-11 03:35:23 +0200
commitf865c02bf50e309adea02f141466a85f79ee0fb2 (patch)
tree9f2f56b2208f1a9853741af42dba218a39a28885 /calc.py
parent6e5829f9d29b3ed4b88dd5e7d581ec01ec8f74cf (diff)
Added support for hex strings
Diffstat (limited to 'calc.py')
-rw-r--r--calc.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/calc.py b/calc.py
index ff4df71..8ac48f0 100644
--- a/calc.py
+++ b/calc.py
@@ -5,6 +5,7 @@ import time
calc_users = open_json_file("calc", [])
math_operators = ["+", "-", "*", "/", "%", ">", "<", "^", "&", "|"]
allowed_strings = ["0b", "0x", "(", ")", "hex(", "bin(", "abs(", "int(", "min(", "max(", "round(", "float("]
+allowed_alpha = ["a", "b", "c", "d", "e", "f"]
calc_perm = "utils.calc"
calc_perm_power = "utils.calc.power"
@@ -41,7 +42,7 @@ def calc(sender, text):
expression += text[i + 1]
i += 1
should_calc = True
- elif char.isdigit() or (expression and char == ".") or (should_calc and char == " ") or (should_calc and char == ","):
+ elif char.isdigit() or char in allowed_alpha or (expression and char == ".") or (should_calc and char == " ") or (should_calc and char == ","):
expression += char
should_calc = True
elif char in math_operators or char in ["(", ")"]: