]>
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
29 def _kick(bot
, user
, chan
, realtarget
, *args
):
31 if args
[0].startswith("#"):
32 people
= bot
.parent
.getuserbyauth(args
[0][1:])
37 reason
= ' '.join(args
[1:])
42 bot
.conn
.send("KICK %s %s :%s" % (chan
, person
, reason
))
45 @lib.hook(None, clevel
=lib
.OP
)
46 @lib.help("<nick|#auth> [<reason>]", "kick <nick>, or all using <#auth>")
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
))
52 @lib.hook(None, clevel
=lib
.OP
)
53 @lib.help("<nick> [<reason>]", "kick all using the auth of <nick>")
55 def kickall(bot
, user
, chan
, realtarget
, *args
):
56 auth
= bot
.parent
.user(args
[0]).auth
58 number
= _kick(bot
, user
, chan
, realtarget
, "#"+bot
.parent
.user(args
[0]).auth
, *args
[1:])
59 bot
.msg(user
, "Done. Kicked %d people." % (number
))
61 bot
.msg(user
, "I don't know that person's auth.")
63 @lib.hook(None, clevel
=lib
.OP
)
64 @lib.help("<nick> [...]", "kicks multiple nicks.")
65 def kickeach(bot
, user
, chan
, realtarget
, *args
):
68 number
+= _kick(bot
, user
, chan
, realtarget
, person
)
69 bot
.msg(user
, "Done. Kicked %d people." % (number
))
73 def _mode(bot
, chan
, flag
, letter
, nicks
):
74 bot
.conn
.send("MODE %s %s%s %s" % (chan
, flag
, letter
*len(nicks
), ' '.join(nicks
)))
76 @lib.hook(None, clevel
=lib
.OP
)
77 @lib.help("[<nick>] [...]", "ops yourself or <nick>s")
78 def op(bot
, user
, chan
, realtarget
, *args
):
79 if len(args
) == 0: args
= (user
.nick
,)
80 _mode(bot
, chan
, "+", "o", args
)
81 bot
.msg(user
, "Opped.")
83 @lib.hook(None, clevel
=lib
.OP
)
84 @lib.help("[<nick>] [...]", "deops yourself or <nick>s")
85 def deop(bot
, user
, chan
, realtarget
, *args
):
86 if len(args
) == 0: args
= (user
.nick
,)
87 _mode(bot
, chan
, "-", "o", args
)
88 bot
.msg(user
, "Deopped.")
90 @lib.hook(None, clevel
=lib
.OP
)
91 @lib.help("[<nick>] [...]", "voices yourself or <nick>s")
92 def voice(bot
, user
, chan
, realtarget
, *args
):
93 if len(args
) == 0: args
= (user
.nick
,)
94 _mode(bot
, chan
, "+", "v", args
)
95 bot
.msg(user
, "Voiced.")
97 @lib.hook(None, clevel
=lib
.OP
)
98 @lib.help("[<nick>] [...]", "devoices yourself or <nick>s")
99 def devoice(bot
, user
, chan
, realtarget
, *args
):
100 if len(args
) == 0: args
= (user
.nick
,)
101 _mode(bot
, chan
, "-", "v", args
)
102 bot
.msg(user
, "Devoiced.")