diff --git a/docs/source/conf.py b/docs/source/conf.py index efe86f2..c64dbda 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -30,7 +30,7 @@ # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. -extensions = ['sphinx.ext.autodoc', 'sphinx.ext.napoleon' +extensions = ['sphinx.ext.autodoc', 'sphinx.ext.napoleon' ] # Add any paths that contain templates here, relative to this directory. diff --git a/honeybot/plugins/calc.py b/honeybot/plugins/calc.py index 3d18bef..d92a678 100644 --- a/honeybot/plugins/calc.py +++ b/honeybot/plugins/calc.py @@ -13,8 +13,7 @@ >>> .calc returns evaluated expression """ -from string import ascii_letters - +from math import * class Plugin: def __init__(self): @@ -27,11 +26,20 @@ def run(self, incoming, methods, info, bot_info): if info['command'] == 'PRIVMSG': if len(msgs) > 1: if msgs[0] == '.calc': + safe_dict = { + 'acos':acos, 'asin':asin, 'atan':atan, + 'atan2':atan2, 'ceil':ceil, 'cos':cos, + 'cosh':cosh, 'degrees':degrees, 'e':e, + 'exp':exp, 'fabs':fabs, 'floor':floor, + 'fmod':fmod, 'frexp':frexp, 'hypot':hypot, + 'ldexp':ldexp, 'log':log, 'log10':log10, + 'modf':modf, 'pi':pi, 'pow':pow, + 'radians':radians, 'sin':sin, 'sinh':sinh, + 'sqrt':sqrt, 'tan':tan, 'tanh':tanh + } expr = msgs[1] - for c in ascii_letters: - expr = '' + expr.replace(c, '') methods['send'](info['address'], '{}'.format( - eval(expr)) + eval(expr, {"__builtins__":None}, safe_dict)) ) - except Exception as e: - print('woops plugin', __file__, e) + except Exception as ex: + print('woops plugin', __file__, ex)