diff options
author | NEMESIS13cz <seke94@seznam.cz> | 2015-08-11 03:35:23 +0200 |
---|---|---|
committer | NEMESIS13cz <seke94@seznam.cz> | 2015-08-11 03:35:23 +0200 |
commit | f865c02bf50e309adea02f141466a85f79ee0fb2 (patch) | |
tree | 9f2f56b2208f1a9853741af42dba218a39a28885 /calc.py | |
parent | 6e5829f9d29b3ed4b88dd5e7d581ec01ec8f74cf (diff) |
Added support for hex strings
Diffstat (limited to 'calc.py')
-rw-r--r-- | calc.py | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -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 ["(", ")"]: |