]>
jfr.im git - erebus.git/blob - modules/eval.py
1 # Erebus IRC bot - Author: Erebus Team
2 # !EVAL and !EXEC commands
3 # This file is released into the public domain; see http://unlicense.org/
7 'author': 'Erebus Team',
8 'license': 'public domain',
15 lib
= modlib
.modlib(__name__
)
16 modstart
= lib
.modstart
23 @lib.hook('eval', needchan
=False, glevel
=lib
.MANAGER
)
25 def cmd_eval(bot
, user
, chan
, realtarget
, *args
):
26 if chan
is not None: replyto
= chan
29 try: ret
= eval(' '.join(args
))
30 except SystemExit: raise
31 except: bot
.msg(replyto
, "Error (%s): %s" % (sys
.exc_info()[0], sys
.exc_info()[1]))
32 else: bot
.msg(replyto
, "Done: %r" % (ret
,))
35 @lib.hook('exec', needchan
=False, glevel
=lib
.MANAGER
)
37 def cmd_exec(bot
, user
, chan
, realtarget
, *args
):
38 if chan
is not None: replyto
= chan
41 try: exec ' '.join(args
)
42 except SystemExit: raise
43 except: bot
.msg(replyto
, "Error: %s %s" % (sys
.exc_info()[0], sys
.exc_info()[1]))
44 else: bot
.msg(replyto
, "Done.")