]>
Commit | Line | Data |
---|---|---|
931c88a4 | 1 | # Erebus IRC bot - Author: John Runyon |
2 | # !EVAL and !EXEC commands | |
3 | ||
e4255e70 | 4 | # module info |
5 | modinfo = { | |
6 | 'author': 'John Runyon (DimeCadmium)', | |
7 | 'license': 'public domain', | |
8 | 'compatible': [1], | |
9 | 'depends': [], | |
10 | } | |
11 | ||
db50981b | 12 | # preamble |
13 | import modlib | |
14 | lib = modlib.modlib(__name__) | |
15 | modstart = lib.modstart | |
16 | modstop = lib.modstop | |
17 | ||
e4255e70 | 18 | # module code |
db50981b | 19 | import sys |
20 | ||
21 | ||
839d2b35 | 22 | @lib.hook('eval', needchan=False, glevel=lib.MANAGER) |
d431e543 | 23 | @lib.argsGE(1) |
861f83ef | 24 | def cmd_eval(bot, user, chan, realtarget, *args): |
839d2b35 | 25 | if chan is not None: replyto = chan |
26 | else: replyto = user | |
27 | ||
db50981b | 28 | try: ret = eval(' '.join(args)) |
839d2b35 | 29 | except: bot.msg(replyto, "Error (%s): %s" % (sys.exc_info()[0], sys.exc_info()[1])) |
30 | else: bot.msg(replyto, "Done: %r" % (ret)) | |
db50981b | 31 | |
32 | ||
839d2b35 | 33 | @lib.hook('exec', needchan=False, glevel=lib.MANAGER) |
d431e543 | 34 | @lib.argsGE(1) |
861f83ef | 35 | def cmd_exec(bot, user, chan, realtarget, *args): |
839d2b35 | 36 | if chan is not None: replyto = chan |
37 | else: replyto = user | |
38 | ||
db50981b | 39 | try: exec ' '.join(args) |
839d2b35 | 40 | except: bot.msg(replyto, "Error: %s %s" % (sys.exc_info()[0], sys.exc_info()[1])) |
41 | else: bot.msg(replyto, "Done.") |