]>
Commit | Line | Data |
---|---|---|
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 | |
6 | modinfo = { | |
7 | 'author': 'Erebus Team', | |
8 | 'license': 'public domain', | |
9 | 'compatible': [1], | |
10 | 'depends': [], | |
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 sys | |
21 | import ctlmod | |
22 | ||
23 | ||
24 | @lib.hook('die', needchan=False, glevel=lib.MANAGER) | |
25 | def 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) | |
31 | def 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) | |
40 | def 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) | |
49 | def 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) | |
58 | def 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.") |