]>
jfr.im git - erebus.git/blob - modules/chanops.py
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/
7 'author': 'Erebus Team',
8 'license': 'public domain',
16 lib
= modlib
.modlib(__name__
)
17 modstart
= lib
.modstart
28 @lib.hook(None, clevel
=lib
.OP
)
29 @lib.help("<nick|#auth> [<reason>]", "kick <nick>, or all using <#auth>")
31 def _kick(bot
, user
, chan
, realtarget
, *args
):
34 people
= bot
.parent
.getuserbyauth(args
[0][1:])
39 reason
= ' '.join(args
[1:])
44 bot
.conn
.send("KICK %s %s :%s" % (chan
, person
, reason
))
47 @lib.hook(None, clevel
=lib
.OP
)
48 @lib.help("<nick|#auth> [<reason>]", "kick <nick>, or all using <#auth>")
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
))
54 @lib.hook(None, clevel
=lib
.OP
)
55 @lib.help("<nick> [<reason>]", "kick all using the auth of <nick>")
57 def kickall(bot
, user
, chan
, realtarget
, *args
):
58 auth
= bot
.parent
.user(args
[0]).auth
60 number
= _kick(bot
, user
, chan
, realtarget
, "#"+bot
.parent
.user(args
[0]).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>] [...]", "")
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>] [...]", "")
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.")