]>
jfr.im git - erebus.git/blob - modules/chanops.py
1 # Erebus IRC bot - Author: Erebus Team
2 # vim: fileencoding=utf-8
4 # This file is released into the public domain; see http://unlicense.org/
8 'author': 'Erebus Team',
9 'license': 'public domain',
17 lib
= modlib
.modlib(__name__
)
18 modstart
= lib
.modstart
26 def _kick(bot
, user
, chan
, realtarget
, *args
):
28 if args
[0].startswith("#"):
29 people
= bot
.parent
.getuserbyauth(args
[0][1:])
34 reason
= ' '.join(args
[1:])
39 bot
.conn
.send("KICK %s %s :%s" % (chan
, person
, reason
))
42 @lib.hook(None, clevel
=lib
.OP
)
43 @lib.help("<nick|#auth> [<reason>]", "kick <nick>, or all using <#auth>")
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
))
49 @lib.hook(None, clevel
=lib
.OP
)
50 @lib.help("<nick|#auth> [<reason>]", "kick all using the auth of <nick>")
52 def kickall(bot
, user
, chan
, realtarget
, *args
):
54 if target
[0] == "#" and len(target
) > 1:
57 auth
= bot
.parent
.user(args
[0]).auth
60 number
= _kick(bot
, user
, chan
, realtarget
, "#"+auth
, *args
[1:])
61 bot
.msg(user
, "Done. Kicked %d people." % (number
))
63 bot
.msg(user
, "I don't know that person's auth.")
65 @lib.hook(None, clevel
=lib
.OP
)
66 @lib.help("<nick> [...]", "kicks multiple nicks.")
67 def kickeach(bot
, user
, chan
, realtarget
, *args
):
70 number
+= _kick(bot
, user
, chan
, realtarget
, person
)
71 bot
.msg(user
, "Done. Kicked %d people." % (number
))
75 def _mode(bot
, chan
, flag
, letter
, nicks
):
76 bot
.conn
.send("MODE %s %s%s %s" % (chan
, flag
, letter
*len(nicks
), ' '.join(nicks
)))
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.")
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.")
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.")
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.")