]>
Commit | Line | Data |
---|---|---|
1 | # Erebus IRC bot - Author: Erebus Team | |
2 | # module control through irc | |
3 | # This file is released into the public domain; see http://unlicense.org/ | |
4 | ||
5 | # module info | |
6 | modinfo = { | |
7 | 'author': 'Erebus Team', | |
8 | 'license': 'public domain', | |
9 | 'compatible': [1], # compatible module API versions | |
10 | 'depends': [], # other modules required to work properly? | |
11 | } | |
12 | ||
13 | # preamble | |
14 | import modlib | |
15 | lib = modlib.modlib(__name__) | |
16 | modstart = lib.modstart | |
17 | modstop = lib.modstop | |
18 | ||
19 | # module code | |
20 | import ctlmod | |
21 | ||
22 | @lib.hook('modload', needchan=False, glevel=lib.MANAGER) | |
23 | @lib.argsEQ(1) | |
24 | def 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) | |
33 | def 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) | |
42 | def cmd_modreload(bot, user, chan, realtarget, *args): | |
43 | okay = ctlmod.reloadmod(bot.parent, args[0]) | |
44 | if okay: | |
45 | bot.msg(user, "Reloaded %s" % (args[0])) | |
46 | else: | |
47 | bot.msg(user, "Error occurred: %r" % (okay)) | |
48 | ||
49 | @lib.hook('modlist', needchan=False, glevel=lib.STAFF) | |
50 | @lib.argsEQ(0) | |
51 | def cmd_modlist(bot, user, chan, realtarget, *args): | |
52 | mods = ctlmod.modules | |
53 | for mod in mods.itervalues(): | |
54 | bot.msg(user, "- %s %r" % (mod.__name__, mod)) | |
55 | bot.msg(user, "Done.") |