]>
Commit | Line | Data |
---|---|---|
535c2460 | 1 | # Erebus IRC bot - Author: Erebus Team |
4477123d | 2 | # vim: fileencoding=utf-8 |
f5aec865 | 3 | # chanop commands |
535c2460 | 4 | # This file is released into the public domain; see http://unlicense.org/ |
5 | ||
6 | # module info | |
7 | modinfo = { | |
8 | 'author': 'Erebus Team', | |
9 | 'license': 'public domain', | |
fa93b933 | 10 | 'compatible': [0], |
535c2460 | 11 | 'depends': [], |
12 | 'softdeps': ['help'], | |
13 | } | |
14 | ||
15 | # preamble | |
16 | import modlib | |
17 | lib = modlib.modlib(__name__) | |
18 | modstart = lib.modstart | |
19 | modstop = lib.modstop | |
20 | ||
21 | # module code | |
22 | import sys | |
23 | import ctlmod | |
24 | ||
25 | ||
26 | def module(name): | |
27 | return lib.mod(name) | |
28 | ||
535c2460 | 29 | def _kick(bot, user, chan, realtarget, *args): |
30 | people = [] | |
fd07173d | 31 | if args[0].startswith("#"): |
535c2460 | 32 | people = bot.parent.getuserbyauth(args[0][1:]) |
33 | else: | |
34 | people = [args[0]] | |
35 | ||
36 | if len(args) > 1: | |
37 | reason = ' '.join(args[1:]) | |
38 | else: | |
39 | reason = "Commanded" | |
40 | ||
41 | for person in people: | |
42 | bot.conn.send("KICK %s %s :%s" % (chan, person, reason)) | |
43 | return len(people) | |
44 | ||
45 | @lib.hook(None, clevel=lib.OP) | |
46 | @lib.help("<nick|#auth> [<reason>]", "kick <nick>, or all using <#auth>") | |
47 | @lib.argsGE(1) | |
48 | def kick(bot, user, chan, realtarget, *args): | |
49 | number = _kick(bot, user, chan, realtarget, *args) | |
50 | bot.msg(user, "Done. Kicked %d people." % (number)) | |
51 | ||
52 | @lib.hook(None, clevel=lib.OP) | |
77b1f37f | 53 | @lib.help("<nick|#auth> [<reason>]", "kick all using the auth of <nick>") |
535c2460 | 54 | @lib.argsGE(1) |
55 | def kickall(bot, user, chan, realtarget, *args): | |
77b1f37f | 56 | target = args[0] |
57 | if target[0] == "#" and len(target) > 1: | |
58 | auth = target[1:] | |
59 | else: | |
60 | auth = bot.parent.user(args[0]).auth | |
61 | ||
535c2460 | 62 | if auth is not None: |
77b1f37f | 63 | number = _kick(bot, user, chan, realtarget, "#"+auth, *args[1:]) |
535c2460 | 64 | bot.msg(user, "Done. Kicked %d people." % (number)) |
65 | else: | |
66 | bot.msg(user, "I don't know that person's auth.") | |
67 | ||
68 | @lib.hook(None, clevel=lib.OP) | |
69 | @lib.help("<nick> [...]", "kicks multiple nicks.") | |
70 | def kickeach(bot, user, chan, realtarget, *args): | |
71 | number = 0 | |
72 | for person in args: | |
73 | number += _kick(bot, user, chan, realtarget, person) | |
74 | bot.msg(user, "Done. Kicked %d people." % (number)) | |
75 | ||
76 | ||
77 | ||
78 | def _mode(bot, chan, flag, letter, nicks): | |
79 | bot.conn.send("MODE %s %s%s %s" % (chan, flag, letter*len(nicks), ' '.join(nicks))) | |
80 | ||
81 | @lib.hook(None, clevel=lib.OP) | |
82 | @lib.help("[<nick>] [...]", "ops yourself or <nick>s") | |
83 | def op(bot, user, chan, realtarget, *args): | |
84 | if len(args) == 0: args = (user.nick,) | |
85 | _mode(bot, chan, "+", "o", args) | |
86 | bot.msg(user, "Opped.") | |
87 | ||
88 | @lib.hook(None, clevel=lib.OP) | |
89 | @lib.help("[<nick>] [...]", "deops yourself or <nick>s") | |
90 | def deop(bot, user, chan, realtarget, *args): | |
91 | if len(args) == 0: args = (user.nick,) | |
92 | _mode(bot, chan, "-", "o", args) | |
93 | bot.msg(user, "Deopped.") | |
94 | ||
95 | @lib.hook(None, clevel=lib.OP) | |
60f00eaa | 96 | @lib.help("[<nick>] [...]", "voices yourself or <nick>s") |
535c2460 | 97 | def voice(bot, user, chan, realtarget, *args): |
98 | if len(args) == 0: args = (user.nick,) | |
99 | _mode(bot, chan, "+", "v", args) | |
100 | bot.msg(user, "Voiced.") | |
101 | ||
102 | @lib.hook(None, clevel=lib.OP) | |
60f00eaa | 103 | @lib.help("[<nick>] [...]", "devoices yourself or <nick>s") |
535c2460 | 104 | def devoice(bot, user, chan, realtarget, *args): |
105 | if len(args) == 0: args = (user.nick,) | |
106 | _mode(bot, chan, "-", "v", args) | |
107 | bot.msg(user, "Devoiced.") | |
108 |