]>
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', |
fa93b933 | 9 | 'compatible': [0], |
e4255e70 | 10 | 'depends': [], |
a62d0d18 | 11 | 'softdeps': ['help'], |
e4255e70 | 12 | } |
13 | ||
db50981b | 14 | # preamble |
15 | import modlib | |
16 | lib = modlib.modlib(__name__) | |
17 | modstart = lib.modstart | |
18 | modstop = lib.modstop | |
19 | ||
e4255e70 | 20 | # module code |
db50981b | 21 | import sys |
9557ee54 | 22 | import ctlmod |
db50981b | 23 | |
132e8a0e | 24 | |
25 | def module(name): | |
43540339 | 26 | return lib.mod(name) |
132e8a0e | 27 | |
889eeb24 | 28 | @lib.hook('eval', needchan=False, wantchan=True, glevel=lib.OWNER) |
5f03d045 | 29 | @lib.help("<python>", "eval") |
d431e543 | 30 | @lib.argsGE(1) |
861f83ef | 31 | def cmd_eval(bot, user, chan, realtarget, *args): |
f5aec865 | 32 | if chan is not None: replyto = chan |
839d2b35 | 33 | else: replyto = user |
34 | ||
db50981b | 35 | try: ret = eval(' '.join(args)) |
b79721ee | 36 | except Exception: bot.msg(replyto, "Error: %s %s" % (sys.exc_info()[0], sys.exc_info()[1])) |
e5a24146 | 37 | else: bot.msg(replyto, "Done: %r" % (ret,)) |
db50981b | 38 | |
39 | ||
889eeb24 | 40 | @lib.hook('exec', needchan=False, wantchan=True, glevel=lib.OWNER) |
5f03d045 | 41 | @lib.help("<python>", "exec") |
d431e543 | 42 | @lib.argsGE(1) |
861f83ef | 43 | def cmd_exec(bot, user, chan, realtarget, *args): |
f5aec865 | 44 | if chan is not None: replyto = chan |
839d2b35 | 45 | else: replyto = user |
46 | ||
db50981b | 47 | try: exec ' '.join(args) |
b79721ee | 48 | except Exception: bot.msg(replyto, "Error: %s %s" % (sys.exc_info()[0], sys.exc_info()[1])) |
839d2b35 | 49 | else: bot.msg(replyto, "Done.") |
f7628a8c | 50 | |
ea3cbbdc | 51 | @lib.hook('exception', needchan=False, glevel=lib.OWNER) |
5f03d045 | 52 | @lib.help(None, "cause an exception") |
f7628a8c | 53 | def cmd_exception(*args, **kwargs): |
54 | raise Exception() |