Added some underscore action to eval.

This commit is contained in:
Jeremy Fincher 2004-08-20 05:30:37 +00:00
parent fd959370a1
commit 956a156b21

View File

@ -338,6 +338,11 @@ class Owner(privmsgs.CapabilityCheckingPrivmsg):
return return
if conf.allowEval: if conf.allowEval:
_evalEnv = {'_': None,
'__': None,
'___': None,
}
_evalEnv.update(globals())
def eval(self, irc, msg, args): def eval(self, irc, msg, args):
"""<expression> """<expression>
@ -348,7 +353,12 @@ class Owner(privmsgs.CapabilityCheckingPrivmsg):
if conf.allowEval: if conf.allowEval:
s = privmsgs.getArgs(args) s = privmsgs.getArgs(args)
try: try:
irc.reply(repr(eval(s))) self._evalEnv.update(locals())
x = eval(s, self._evalEnv, self._evalEnv)
self._evalEnv['___'] = self._evalEnv['__']
self._evalEnv['__'] = self._evalEnv['_']
self._evalEnv['_'] = x
irc.reply(repr(x))
except SyntaxError, e: except SyntaxError, e:
irc.reply('%s: %r' % (utils.exnToString(e), s)) irc.reply('%s: %r' % (utils.exnToString(e), s))
except Exception, e: except Exception, e: