[Calc] Fix things
parent
0ebecf3c90
commit
13b3a2ed90
10
calc.py
10
calc.py
|
@ -37,7 +37,7 @@ def eval_(node):
|
||||||
elif isinstance(node, ast.BinOp): # <left> <operator> <right>
|
elif isinstance(node, ast.BinOp): # <left> <operator> <right>
|
||||||
return eval_(node.op)(eval_(node.left), eval_(node.right))
|
return eval_(node.op)(eval_(node.left), eval_(node.right))
|
||||||
elif isinstance(node, ast.Call): # <func> ( <args> )
|
elif isinstance(node, ast.Call): # <func> ( <args> )
|
||||||
return getfunc(node.func.id)(*(eval_(e) for e in node.func.args))
|
return getfunc(node.func.id)(*(eval_(e) for e in node.args))
|
||||||
else:
|
else:
|
||||||
raise TypeError("AST node type not allowed: '" + type(node).__name__ + "'")
|
raise TypeError("AST node type not allowed: '" + type(node).__name__ + "'")
|
||||||
|
|
||||||
|
@ -51,12 +51,12 @@ def c(phenny, input):
|
||||||
q = input.group(2).encode('utf-8')
|
q = input.group(2).encode('utf-8')
|
||||||
print("[LOG]: %s calculated '%s'" % (input.nick,q))
|
print("[LOG]: %s calculated '%s'" % (input.nick,q))
|
||||||
try:
|
try:
|
||||||
phenny.say(eval_expr(q))
|
phenny.say(str(eval_expr(q)))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
phenny.say("Exception: " + str(e))
|
phenny.say("Exception: " + str(e))
|
||||||
|
|
||||||
c.commands = ['c']
|
c.commands = ['c']
|
||||||
c.example = '.c 5 + 3'
|
c.example = '.c 5 + 3'
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
print __doc__.strip()
|
print __doc__.strip()
|
||||||
|
|
Loading…
Reference in New Issue