]>
Commit | Line | Data |
---|---|---|
9bd05cf6 | 1 | # Erebus IRC bot - Author: Erebus Team |
931c88a4 | 2 | # !EVAL and !EXEC commands |
9bd05cf6 | 3 | # This file is released into the public domain; see http://unlicense.org/ |
931c88a4 | 4 | |
e4255e70 | 5 | # module info |
6 | modinfo = { | |
9bd05cf6 | 7 | 'author': 'Erebus Team', |
e4255e70 | 8 | 'license': 'public domain', |
9 | 'compatible': [1], | |
10 | 'depends': [], | |
11 | } | |
12 | ||
db50981b | 13 | # preamble |
14 | import modlib | |
15 | lib = modlib.modlib(__name__) | |
16 | modstart = lib.modstart | |
17 | modstop = lib.modstop | |
18 | ||
e4255e70 | 19 | # module code |
db50981b | 20 | import sys |
9557ee54 | 21 | import ctlmod |
db50981b | 22 | |
132e8a0e | 23 | |
24 | def module(name): | |
43540339 | 25 | return lib.mod(name) |
132e8a0e | 26 | |
839d2b35 | 27 | @lib.hook('eval', needchan=False, glevel=lib.MANAGER) |
5f03d045 | 28 | @lib.help("<python>", "eval") |
d431e543 | 29 | @lib.argsGE(1) |
861f83ef | 30 | def cmd_eval(bot, user, chan, realtarget, *args): |
b79721ee | 31 | if chan is not None and realtarget == chan.name: replyto = chan |
839d2b35 | 32 | else: replyto = user |
33 | ||
db50981b | 34 | try: ret = eval(' '.join(args)) |
b79721ee | 35 | except Exception: bot.msg(replyto, "Error: %s %s" % (sys.exc_info()[0], sys.exc_info()[1])) |
e5a24146 | 36 | else: bot.msg(replyto, "Done: %r" % (ret,)) |
db50981b | 37 | |
38 | ||
839d2b35 | 39 | @lib.hook('exec', needchan=False, glevel=lib.MANAGER) |
5f03d045 | 40 | @lib.help("<python>", "exec") |
d431e543 | 41 | @lib.argsGE(1) |
861f83ef | 42 | def cmd_exec(bot, user, chan, realtarget, *args): |
b79721ee | 43 | if chan is not None and realtarget == chan.name: replyto = chan |
839d2b35 | 44 | else: replyto = user |
45 | ||
db50981b | 46 | try: exec ' '.join(args) |
b79721ee | 47 | except Exception: bot.msg(replyto, "Error: %s %s" % (sys.exc_info()[0], sys.exc_info()[1])) |
839d2b35 | 48 | else: bot.msg(replyto, "Done.") |
f7628a8c | 49 | |
ea3cbbdc | 50 | @lib.hook('exception', needchan=False, glevel=lib.OWNER) |
5f03d045 | 51 | @lib.help(None, "cause an exception") |
f7628a8c | 52 | def cmd_exception(*args, **kwargs): |
53 | raise Exception() |