Added support for hex strings

This commit is contained in:
NEMESIS13cz
2015-08-11 03:35:23 +02:00
parent 6e5829f9d2
commit f865c02bf5

View File

@@ -5,6 +5,7 @@ import time
calc_users = open_json_file("calc", []) calc_users = open_json_file("calc", [])
math_operators = ["+", "-", "*", "/", "%", ">", "<", "^", "&", "|"] math_operators = ["+", "-", "*", "/", "%", ">", "<", "^", "&", "|"]
allowed_strings = ["0b", "0x", "(", ")", "hex(", "bin(", "abs(", "int(", "min(", "max(", "round(", "float("] 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 = "utils.calc"
calc_perm_power = "utils.calc.power" calc_perm_power = "utils.calc.power"
@@ -41,7 +42,7 @@ def calc(sender, text):
expression += text[i + 1] expression += text[i + 1]
i += 1 i += 1
should_calc = True 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 expression += char
should_calc = True should_calc = True
elif char in math_operators or char in ["(", ")"]: elif char in math_operators or char in ["(", ")"]: