]> jfr.im git - erebus.git/blame_incremental - modules/eval.py
Added extra parameter to callbacks, "realtarget"
[erebus.git] / modules / eval.py
... / ...
CommitLineData
1# Erebus IRC bot - Author: John Runyon
2# !EVAL and !EXEC commands
3
4# module info
5modinfo = {
6 'author': 'John Runyon (DimeCadmium)',
7 'license': 'public domain',
8 'compatible': [1],
9 'depends': [],
10}
11
12# preamble
13import modlib
14lib = modlib.modlib(__name__)
15modstart = lib.modstart
16modstop = lib.modstop
17
18# module code
19import sys
20
21
22@lib.hook('eval', needchan=False, glevel=lib.MANAGER)
23def cmd_eval(bot, user, chan, realtarget, *args):
24 if chan is not None: replyto = chan
25 else: replyto = user
26
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))
30
31
32@lib.hook('exec', needchan=False, glevel=lib.MANAGER)
33def cmd_exec(bot, user, chan, realtarget, *args):
34 if chan is not None: replyto = chan
35 else: replyto = user
36
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.")