-
Notifications
You must be signed in to change notification settings - Fork 0
/
autoopmodule.py
31 lines (25 loc) · 1.08 KB
/
autoopmodule.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from botmodule import BotModule, CmdException
class AutoOPModule(BotModule):
def is_autoop(self, user, channel):
perm = self.bot.get_service('permission')
return perm.has_permission(user, 'op.' + channel)
def is_autovoice(self, user, channel):
perm = self.bot.get_service('permission')
return perm.has_permission(user, 'voice.' + channel)
def handle_msg_join(self, conn, msg):
user = msg['prefix']
channel = msg['params'][0]
if self.is_autoop(user, channel):
conn.msg_chan_mode(channel, '+o', user['nick'])
if self.is_autovoice(user, channel):
conn.msg_chan_mode(channel, '+v', user['nick'])
def handle_cmd_opme(self, conn, **kwargs):
if self.is_autoop(kwargs['sender'], kwargs['target']):
conn.msg_chan_mode(kwargs['target'], '+o', kwargs['sender']['nick'])
else:
conn.msg_privmsg(kwargs['respond'], 'Access denied')
def handle_cmd_voiceme(self, conn, **kwargs):
if self.is_autovoice(kwargs['sender'], kwargs['target']):
conn.msg_chan_mode(kwargs['target'], '+v', kwargs['sender']['nick'])
else:
conn.msg_privmsg(kwargs['respond'], 'Access denied')