]>
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',
16 lib
= modlib
.modlib(__name__
)
17 modstart
= lib
.modstart
28 @lib.hook('eval', needchan
=False, wantchan
=True, glevel
=lib
.MANAGER
)
29 @lib.help("<python>", "eval")
31 def cmd_eval(bot
, user
, chan
, realtarget
, *args
):
32 if chan
is not None: replyto
= chan
35 try: ret
= eval(' '.join(args
))
36 except Exception: bot
.msg(replyto
, "Error: %s %s" % (sys
.exc_info()[0], sys
.exc_info()[1]))
37 else: bot
.msg(replyto
, "Done: %r" % (ret
,))
40 @lib.hook('exec', needchan
=False, wantchan
=True, glevel
=lib
.MANAGER
)
41 @lib.help("<python>", "exec")
43 def cmd_exec(bot
, user
, chan
, realtarget
, *args
):
44 if chan
is not None: replyto
= chan
47 try: exec ' '.join(args
)
48 except Exception: bot
.msg(replyto
, "Error: %s %s" % (sys
.exc_info()[0], sys
.exc_info()[1]))
49 else: bot
.msg(replyto
, "Done.")
51 @lib.hook('exception', needchan
=False, glevel
=lib
.OWNER
)
52 @lib.help(None, "cause an exception")
53 def cmd_exception(*args
, **kwargs
):