]>
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
27 @lib.hook('eval', needchan
=False, glevel
=lib
.MANAGER
)
28 @lib.help("<python>", "eval")
30 def cmd_eval(bot
, user
, chan
, realtarget
, *args
):
31 if chan
is not None and realtarget
== chan
.name
: replyto
= chan
34 try: ret
= eval(' '.join(args
))
35 except Exception: bot
.msg(replyto
, "Error: %s %s" % (sys
.exc_info()[0], sys
.exc_info()[1]))
36 else: bot
.msg(replyto
, "Done: %r" % (ret
,))
39 @lib.hook('exec', needchan
=False, glevel
=lib
.MANAGER
)
40 @lib.help("<python>", "exec")
42 def cmd_exec(bot
, user
, chan
, realtarget
, *args
):
43 if chan
is not None and realtarget
== chan
.name
: replyto
= chan
46 try: exec ' '.join(args
)
47 except Exception: bot
.msg(replyto
, "Error: %s %s" % (sys
.exc_info()[0], sys
.exc_info()[1]))
48 else: bot
.msg(replyto
, "Done.")
50 @lib.hook('exception', needchan
=False, glevel
=lib
.OWNER
)
51 @lib.help(None, "cause an exception")
52 def cmd_exception(*args
, **kwargs
):