]>
jfr.im git - erebus.git/blob - modules/eval.py
1 # Erebus IRC bot - Author: John Runyon
2 # !EVAL and !EXEC commands
6 'author': 'John Runyon (DimeCadmium)',
7 'license': 'public domain',
14 lib
= modlib
.modlib(__name__
)
15 modstart
= lib
.modstart
22 @lib.hook('eval', needchan
=False, glevel
=lib
.MANAGER
)
23 def cmd_eval(bot
, user
, chan
, realtarget
, *args
):
24 if chan
is not None: replyto
= chan
27 try: ret
= eval(' '.join(args
))
28 except: bot
.msg(replyto
, "Error (%s): %s" % (sys
.exc_info()[0], sys
.exc_info()[1]))
29 else: bot
.msg(replyto
, "Done: %r" % (ret
))
32 @lib.hook('exec', needchan
=False, glevel
=lib
.MANAGER
)
33 def cmd_exec(bot
, user
, chan
, realtarget
, *args
):
34 if chan
is not None: replyto
= chan
37 try: exec ' '.join(args
)
38 except: bot
.msg(replyto
, "Error: %s %s" % (sys
.exc_info()[0], sys
.exc_info()[1]))
39 else: bot
.msg(replyto
, "Done.")