Added check for .
This commit is contained in:
4
calc.py
4
calc.py
@@ -1,7 +1,7 @@
|
||||
from helpers import *
|
||||
|
||||
calc_users = open_json_file("calc", [])
|
||||
math_operators = ["+", "-", "*", "/", "&", "|",".",]
|
||||
math_operators = ["+", "-", "*", "/", "&", "|"]
|
||||
ignore_operators = ["**", "&&", "||"] # ** may be too intensive, the others cause syntax errors
|
||||
calc_perm = "utils.calc"
|
||||
|
||||
@@ -16,6 +16,8 @@ def calc(text):
|
||||
for char in text:
|
||||
if char.isdigit() or (should_calc and char in [".", " "]):
|
||||
expression += char
|
||||
elif expression and char == ".":
|
||||
expression += char
|
||||
elif char in math_operators:
|
||||
# calculation must include at least 1 operator
|
||||
should_calc = True
|
||||
|
||||
Reference in New Issue
Block a user