]> jfr.im git - erebus.git/blame - modules/module.py
Merge branch 'master' of kronos.jfr.im:erebus
[erebus.git] / modules / module.py
CommitLineData
9bd05cf6 1# Erebus IRC bot - Author: Erebus Team
586997a7 2# module control through irc
d431e543 3# This file is released into the public domain; see http://unlicense.org/
4
5# module info
6modinfo = {
9bd05cf6 7 'author': 'Erebus Team',
d431e543 8 'license': 'public domain',
9 'compatible': [1], # compatible module API versions
10 'depends': [], # other modules required to work properly?
11}
12
13# preamble
14import modlib
15lib = modlib.modlib(__name__)
16modstart = lib.modstart
17modstop = lib.modstop
18
19# module code
20import ctlmod
21
22@lib.hook('modload', needchan=False, glevel=lib.MANAGER)
23@lib.argsEQ(1)
24def cmd_modload(bot, user, chan, realtarget, *args):
25 okay = ctlmod.load(bot.parent, args[0])
26 if okay:
27 bot.msg(user, "Loaded %s" % (args[0]))
28 else:
29 bot.msg(user, "Error loading %s: %r" % (args[0], okay))
30
31@lib.hook('modunload', needchan=False, glevel=lib.MANAGER)
32@lib.argsEQ(1)
33def cmd_modunload(bot, user, chan, realtarget, *args):
34 okay = ctlmod.unload(bot.parent, args[0])
35 if okay:
36 bot.msg(user, "Unloaded %s" % (args[0]))
37 else:
38 bot.msg(user, "Error unloading %s: %r" % (args[0], okay))
39
40@lib.hook('modreload', needchan=False, glevel=lib.MANAGER)
41@lib.argsEQ(1)
42def cmd_modreload(bot, user, chan, realtarget, *args):
43 okay = ctlmod.reloadmod(bot.parent, args[0])
44 bot.msg(user, "Reloaded %s" % (args[0]))
45
46@lib.hook('modlist', needchan=False, glevel=lib.STAFF)
47@lib.argsEQ(0)
48def cmd_modlist(bot, user, chan, realtarget, *args):
6b2c681d 49 mods = ctlmod.modules
50 for mod in mods.itervalues():
51 bot.msg(user, "- %s %r" % (mod.__name__, mod))
52 bot.msg(user, "Done.")