]> jfr.im git - erebus.git/blame - modules/control.py
add load OK checking/logging to bot statup module loading
[erebus.git] / modules / control.py
CommitLineData
e2b30093 1# Erebus IRC bot - Author: Erebus Team
4df64299 2# Various highly recommended "control" commands.
e2b30093 3# This file is released into the public domain; see http://unlicense.org/
4
5# module info
6modinfo = {
7 'author': 'Erebus Team',
8 'license': 'public domain',
9 'compatible': [1],
10 'depends': [],
11}
12
13# preamble
14import modlib
15lib = modlib.modlib(__name__)
16modstart = lib.modstart
17modstop = lib.modstop
18
19# module code
20import sys
21import ctlmod
22
23
24@lib.hook('die', needchan=False, glevel=lib.MANAGER)
25def cmd_die(bot, user, chan, realtarget, *args):
26 sys.exit(0)
27 os._exit(0)
4df64299 28
29@lib.hook('modload', needchan=False, glevel=lib.MANAGER)
30@lib.argsEQ(1)
31def cmd_modload(bot, user, chan, realtarget, *args):
32 okay = ctlmod.load(bot.parent, args[0])
33 if okay:
34 bot.msg(user, "Loaded %s" % (args[0]))
35 else:
36 bot.msg(user, "Error loading %s: %r" % (args[0], okay))
37
38@lib.hook('modunload', needchan=False, glevel=lib.MANAGER)
39@lib.argsEQ(1)
40def cmd_modunload(bot, user, chan, realtarget, *args):
41 okay = ctlmod.unload(bot.parent, args[0])
42 if okay:
43 bot.msg(user, "Unloaded %s" % (args[0]))
44 else:
45 bot.msg(user, "Error unloading %s: %r" % (args[0], okay))
46
47@lib.hook('modreload', needchan=False, glevel=lib.MANAGER)
48@lib.argsEQ(1)
49def cmd_modreload(bot, user, chan, realtarget, *args):
50 okay = ctlmod.reloadmod(bot.parent, args[0])
51 if okay:
52 bot.msg(user, "Reloaded %s" % (args[0]))
53 else:
54 bot.msg(user, "Error occurred: %r" % (okay))
55
56@lib.hook('modlist', needchan=False, glevel=lib.STAFF)
57@lib.argsEQ(0)
58def cmd_modlist(bot, user, chan, realtarget, *args):
59 mods = ctlmod.modules
60 for mod in mods.itervalues():
61 bot.msg(user, "- %s %r" % (mod.__name__, mod))
62 bot.msg(user, "Done.")