]>
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
)
29 def cmd_eval(bot
, user
, chan
, realtarget
, *args
):
30 if chan
is not None and realtarget
== chan
.name
: replyto
= chan
33 try: ret
= eval(' '.join(args
))
34 except Exception: bot
.msg(replyto
, "Error: %s %s" % (sys
.exc_info()[0], sys
.exc_info()[1]))
35 else: bot
.msg(replyto
, "Done: %r" % (ret
,))
38 @lib.hook('exec', needchan
=False, glevel
=lib
.MANAGER
)
40 def cmd_exec(bot
, user
, chan
, realtarget
, *args
):
41 if chan
is not None and realtarget
== chan
.name
: replyto
= chan
44 try: exec ' '.join(args
)
45 except Exception: bot
.msg(replyto
, "Error: %s %s" % (sys
.exc_info()[0], sys
.exc_info()[1]))
46 else: bot
.msg(replyto
, "Done.")