]>
Commit | Line | Data |
---|---|---|
535c2460 | 1 | # Erebus IRC bot - Author: Erebus Team |
2 | # !EVAL and !EXEC commands | |
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,2], | |
10 | 'depends': [], | |
11 | 'softdeps': ['help'], | |
12 | } | |
13 | ||
14 | # preamble | |
15 | import modlib | |
16 | lib = modlib.modlib(__name__) | |
17 | modstart = lib.modstart | |
18 | modstop = lib.modstop | |
19 | ||
20 | # module code | |
21 | import sys | |
22 | import ctlmod | |
23 | ||
24 | ||
25 | def module(name): | |
26 | return lib.mod(name) | |
27 | ||
28 | @lib.hook(None, clevel=lib.OP) | |
29 | @lib.help("<nick|#auth> [<reason>]", "kick <nick>, or all using <#auth>") | |
30 | @lib.argsGE(1) | |
31 | def _kick(bot, user, chan, realtarget, *args): | |
32 | people = [] | |
33 | if args[0][0] == "#": | |
34 | people = bot.parent.getuserbyauth(args[0][1:]) | |
35 | else: | |
36 | people = [args[0]] | |
37 | ||
38 | if len(args) > 1: | |
39 | reason = ' '.join(args[1:]) | |
40 | else: | |
41 | reason = "Commanded" | |
42 | ||
43 | for person in people: | |
44 | bot.conn.send("KICK %s %s :%s" % (chan, person, reason)) | |
45 | return len(people) | |
46 | ||
47 | @lib.hook(None, clevel=lib.OP) | |
48 | @lib.help("<nick|#auth> [<reason>]", "kick <nick>, or all using <#auth>") | |
49 | @lib.argsGE(1) | |
50 | def kick(bot, user, chan, realtarget, *args): | |
51 | number = _kick(bot, user, chan, realtarget, *args) | |
52 | bot.msg(user, "Done. Kicked %d people." % (number)) | |
53 | ||
54 | @lib.hook(None, clevel=lib.OP) | |
55 | @lib.help("<nick> [<reason>]", "kick all using the auth of <nick>") | |
56 | @lib.argsGE(1) | |
57 | def kickall(bot, user, chan, realtarget, *args): | |
58 | auth = bot.parent.user(args[0]).auth | |
59 | if auth is not None: | |
60 | number = _kick(bot, user, chan, realtarget, "#"+bot.parent.user(args[0]).auth, *args[1:]) | |
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) | |
93 | @lib.help("[<nick>] [...]", "") | |
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) | |
100 | @lib.help("[<nick>] [...]", "") | |
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 |