]> jfr.im git - erebus.git/blame - modules/eval.py
Added a few module featuresm depends needs testing!
[erebus.git] / modules / eval.py
CommitLineData
28d7d32f
JR
1# module info
2modinfo = {
3 'author': 'John Runyon (DimeCadmium)',
4 'license': 'public domain',
5 'compatible': [1],
6 'depends': [],
7}
8
d1ea05b0
JR
9# preamble
10import modlib
11lib = modlib.modlib(__name__)
12modstart = lib.modstart
13modstop = lib.modstop
14
28d7d32f 15# module code
d1ea05b0
JR
16import sys
17
18
19@lib.hook('eval')
20def cmd_eval(bot, user, chan, *args):
21 try: ret = eval(' '.join(args))
22 except: bot.msg(chan, "Error (%s): %s" % (sys.exc_info()[0], sys.exc_info()[1]))
23 else: bot.msg(chan, "Done: %r" % (ret))
24
25
26@lib.hook('exec')
27def cmd_exec(bot, user, chan, *args):
28 try: exec ' '.join(args)
29 except: bot.msg(chan, "Error: %s %s" % (sys.exc_info()[0], sys.exc_info()[1]))
30 else: bot.msg(chan, "Done.")