]>
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 | ||
fb20be7c | 24 | @lib.hook(needchan=False, glevel=lib.MANAGER) |
25 | def die(bot, user, chan, realtarget, *args): | |
e2b30093 | 26 | sys.exit(0) |
27 | os._exit(0) | |
4df64299 | 28 | |
fb20be7c | 29 | @lib.hook(needchan=False, glevel=lib.MANAGER) |
4df64299 | 30 | @lib.argsEQ(1) |
fb20be7c | 31 | def modload(bot, user, chan, realtarget, *args): |
4df64299 | 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 | ||
fb20be7c | 38 | @lib.hook(needchan=False, glevel=lib.MANAGER) |
4df64299 | 39 | @lib.argsEQ(1) |
fb20be7c | 40 | def modunload(bot, user, chan, realtarget, *args): |
4df64299 | 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 | ||
fb20be7c | 47 | @lib.hook(needchan=False, glevel=lib.MANAGER) |
4df64299 | 48 | @lib.argsEQ(1) |
fb20be7c | 49 | def modreload(bot, user, chan, realtarget, *args): |
4df64299 | 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 | ||
fb20be7c | 56 | @lib.hook(needchan=False, glevel=lib.STAFF) |
4df64299 | 57 | @lib.argsEQ(0) |
fb20be7c | 58 | def modlist(bot, user, chan, realtarget, *args): |
4df64299 | 59 | mods = ctlmod.modules |
60 | for mod in mods.itervalues(): | |
61 | bot.msg(user, "- %s %r" % (mod.__name__, mod)) | |
62 | bot.msg(user, "Done.") | |
fb20be7c | 63 | |
64 | @lib.hook(cmd='whoami', needchan=False) | |
65 | def whoami(bot, user, chan, realtarget, *args): | |
66 | if not user.isauthed(): | |
67 | bot.msg(user, "You are not authed.") | |
68 | return | |
69 | ||
70 | fillers = {'auth': user.auth} | |
71 | fmt = "You are %(auth)s" | |
72 | ||
73 | if user.glevel >= 1: | |
74 | fillers['glevel'] = user.glevel | |
75 | fmt += " (global access: %(glevel)s)" | |
76 | else: | |
77 | fmt += " (not staff)" | |
78 | ||
79 | if chan is not None and chan.levelof(user.auth) >= 1: | |
80 | fillers['clevel'] = chan.levelof(user.auth) | |
81 | fmt += " (channel access: %(clevel)s)" | |
82 | else: | |
83 | fmt += " (not a channel user)" | |
84 | bot.msg(user, fmt % fillers) |