]>
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|#auth> [<reason>]", "kick all using the auth of <nick>")
55 def kickall(bot
, user
, chan
, realtarget
, *args
):
57 if target
[0] == "#" and len(target
) > 1:
60 auth
= bot
.parent
.user(args
[0]).auth
63 number
= _kick(bot
, user
, chan
, realtarget
, "#"+auth
, *args
[1:])
64 bot
.msg(user
, "Done. Kicked %d people." % (number
))
66 bot
.msg(user
, "I don't know that person's auth.")
68 @lib.hook(None, clevel
=lib
.OP
)
69 @lib.help("<nick> [...]", "kicks multiple nicks.")
70 def kickeach(bot
, user
, chan
, realtarget
, *args
):
73 number
+= _kick(bot
, user
, chan
, realtarget
, person
)
74 bot
.msg(user
, "Done. Kicked %d people." % (number
))
78 def _mode(bot
, chan
, flag
, letter
, nicks
):
79 bot
.conn
.send("MODE %s %s%s %s" % (chan
, flag
, letter
*len(nicks
), ' '.join(nicks
)))
81 @lib.hook(None, clevel
=lib
.OP
)
82 @lib.help("[<nick>] [...]", "ops yourself or <nick>s")
83 def op(bot
, user
, chan
, realtarget
, *args
):
84 if len(args
) == 0: args
= (user
.nick
,)
85 _mode(bot
, chan
, "+", "o", args
)
86 bot
.msg(user
, "Opped.")
88 @lib.hook(None, clevel
=lib
.OP
)
89 @lib.help("[<nick>] [...]", "deops yourself or <nick>s")
90 def deop(bot
, user
, chan
, realtarget
, *args
):
91 if len(args
) == 0: args
= (user
.nick
,)
92 _mode(bot
, chan
, "-", "o", args
)
93 bot
.msg(user
, "Deopped.")
95 @lib.hook(None, clevel
=lib
.OP
)
96 @lib.help("[<nick>] [...]", "voices yourself or <nick>s")
97 def voice(bot
, user
, chan
, realtarget
, *args
):
98 if len(args
) == 0: args
= (user
.nick
,)
99 _mode(bot
, chan
, "+", "v", args
)
100 bot
.msg(user
, "Voiced.")
102 @lib.hook(None, clevel
=lib
.OP
)
103 @lib.help("[<nick>] [...]", "devoices yourself or <nick>s")
104 def devoice(bot
, user
, chan
, realtarget
, *args
):
105 if len(args
) == 0: args
= (user
.nick
,)
106 _mode(bot
, chan
, "-", "v", args
)
107 bot
.msg(user
, "Devoiced.")