]>
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 | ||
535c2460 | 26 | def _kick(bot, user, chan, realtarget, *args): |
27 | people = [] | |
fd07173d | 28 | if args[0].startswith("#"): |
535c2460 | 29 | people = bot.parent.getuserbyauth(args[0][1:]) |
30 | else: | |
31 | people = [args[0]] | |
32 | ||
33 | if len(args) > 1: | |
34 | reason = ' '.join(args[1:]) | |
35 | else: | |
36 | reason = "Commanded" | |
37 | ||
38 | for person in people: | |
39 | bot.conn.send("KICK %s %s :%s" % (chan, person, reason)) | |
40 | return len(people) | |
41 | ||
42 | @lib.hook(None, clevel=lib.OP) | |
43 | @lib.help("<nick|#auth> [<reason>]", "kick <nick>, or all using <#auth>") | |
44 | @lib.argsGE(1) | |
45 | def kick(bot, user, chan, realtarget, *args): | |
46 | number = _kick(bot, user, chan, realtarget, *args) | |
47 | bot.msg(user, "Done. Kicked %d people." % (number)) | |
48 | ||
49 | @lib.hook(None, clevel=lib.OP) | |
77b1f37f | 50 | @lib.help("<nick|#auth> [<reason>]", "kick all using the auth of <nick>") |
535c2460 | 51 | @lib.argsGE(1) |
52 | def kickall(bot, user, chan, realtarget, *args): | |
77b1f37f | 53 | target = args[0] |
54 | if target[0] == "#" and len(target) > 1: | |
55 | auth = target[1:] | |
56 | else: | |
57 | auth = bot.parent.user(args[0]).auth | |
58 | ||
535c2460 | 59 | if auth is not None: |
77b1f37f | 60 | number = _kick(bot, user, chan, realtarget, "#"+auth, *args[1:]) |
535c2460 | 61 | bot.msg(user, "Done. Kicked %d people." % (number)) |
62 | else: | |
63 | bot.msg(user, "I don't know that person's auth.") | |
64 | ||
65 | @lib.hook(None, clevel=lib.OP) | |
66 | @lib.help("<nick> [...]", "kicks multiple nicks.") | |
67 | def kickeach(bot, user, chan, realtarget, *args): | |
68 | number = 0 | |
69 | for person in args: | |
70 | number += _kick(bot, user, chan, realtarget, person) | |
71 | bot.msg(user, "Done. Kicked %d people." % (number)) | |
72 | ||
73 | ||
74 | ||
75 | def _mode(bot, chan, flag, letter, nicks): | |
76 | bot.conn.send("MODE %s %s%s %s" % (chan, flag, letter*len(nicks), ' '.join(nicks))) | |
77 | ||
78 | @lib.hook(None, clevel=lib.OP) | |
79 | @lib.help("[<nick>] [...]", "ops yourself or <nick>s") | |
80 | def op(bot, user, chan, realtarget, *args): | |
81 | if len(args) == 0: args = (user.nick,) | |
82 | _mode(bot, chan, "+", "o", args) | |
83 | bot.msg(user, "Opped.") | |
84 | ||
85 | @lib.hook(None, clevel=lib.OP) | |
86 | @lib.help("[<nick>] [...]", "deops yourself or <nick>s") | |
87 | def deop(bot, user, chan, realtarget, *args): | |
88 | if len(args) == 0: args = (user.nick,) | |
89 | _mode(bot, chan, "-", "o", args) | |
90 | bot.msg(user, "Deopped.") | |
91 | ||
92 | @lib.hook(None, clevel=lib.OP) | |
60f00eaa | 93 | @lib.help("[<nick>] [...]", "voices yourself or <nick>s") |
535c2460 | 94 | def voice(bot, user, chan, realtarget, *args): |
95 | if len(args) == 0: args = (user.nick,) | |
96 | _mode(bot, chan, "+", "v", args) | |
97 | bot.msg(user, "Voiced.") | |
98 | ||
99 | @lib.hook(None, clevel=lib.OP) | |
60f00eaa | 100 | @lib.help("[<nick>] [...]", "devoices yourself or <nick>s") |
535c2460 | 101 | def devoice(bot, user, chan, realtarget, *args): |
102 | if len(args) == 0: args = (user.nick,) | |
103 | _mode(bot, chan, "-", "v", args) | |
104 | bot.msg(user, "Devoiced.") | |
105 |