]> jfr.im git - erebus.git/blob - modules/chanops.py
chanops - why is this here? its not used
[erebus.git] / modules / chanops.py
1 # Erebus IRC bot - Author: Erebus Team
2 # vim: fileencoding=utf-8
3 # chanop commands
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',
10 'compatible': [0],
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 _kick(bot, user, chan, realtarget, *args):
27 people = []
28 if args[0].startswith("#"):
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)
50 @lib.help("<nick|#auth> [<reason>]", "kick all using the auth of <nick>")
51 @lib.argsGE(1)
52 def kickall(bot, user, chan, realtarget, *args):
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
59 if auth is not None:
60 number = _kick(bot, user, chan, realtarget, "#"+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>] [...]", "voices yourself or <nick>s")
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>] [...]", "devoices yourself or <nick>s")
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