]>
Commit | Line | Data |
---|---|---|
00823c25 | 1 | # Erebus IRC bot - Author: Erebus Team |
db75daab | 2 | # !EVAL and !EXEC commands |
00823c25 | 3 | # This file is released into the public domain; see http://unlicense.org/ |
db75daab | 4 | |
28d7d32f JR |
5 | # module info |
6 | modinfo = { | |
00823c25 | 7 | 'author': 'Erebus Team', |
28d7d32f JR |
8 | 'license': 'public domain', |
9 | 'compatible': [1], | |
10 | 'depends': [], | |
11 | } | |
12 | ||
d1ea05b0 JR |
13 | # preamble |
14 | import modlib | |
15 | lib = modlib.modlib(__name__) | |
16 | modstart = lib.modstart | |
17 | modstop = lib.modstop | |
18 | ||
28d7d32f | 19 | # module code |
d1ea05b0 JR |
20 | import sys |
21 | ||
67e04ca5 | 22 | @lib.hook('eval', needchan=False, glevel=lib.MANAGER) |
32cabc3d | 23 | @lib.argsGE(1) |
30e3843d | 24 | def cmd_eval(bot, user, chan, realtarget, *args): |
67e04ca5 JR |
25 | if chan is not None: replyto = chan |
26 | else: replyto = user | |
27 | ||
d1ea05b0 | 28 | try: ret = eval(' '.join(args)) |
67e04ca5 JR |
29 | except: bot.msg(replyto, "Error (%s): %s" % (sys.exc_info()[0], sys.exc_info()[1])) |
30 | else: bot.msg(replyto, "Done: %r" % (ret)) | |
d1ea05b0 JR |
31 | |
32 | ||
67e04ca5 | 33 | @lib.hook('exec', needchan=False, glevel=lib.MANAGER) |
32cabc3d | 34 | @lib.argsGE(1) |
30e3843d | 35 | def cmd_exec(bot, user, chan, realtarget, *args): |
67e04ca5 JR |
36 | if chan is not None: replyto = chan |
37 | else: replyto = user | |
38 | ||
d1ea05b0 | 39 | try: exec ' '.join(args) |
67e04ca5 JR |
40 | except: bot.msg(replyto, "Error: %s %s" % (sys.exc_info()[0], sys.exc_info()[1])) |
41 | else: bot.msg(replyto, "Done.") |