mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-02-17 14:10:41 +01:00
Slight refactoring.
This commit is contained in:
parent
154577832c
commit
4837707e65
@ -144,6 +144,19 @@ class Enforcer(callbacks.Privmsg):
|
|||||||
capabilities = [_chanCap(channel, 'op'),_chanCap(channel, 'protected')]
|
capabilities = [_chanCap(channel, 'op'),_chanCap(channel, 'protected')]
|
||||||
return ircdb.checkCapabilities(hostmask, capabilities)
|
return ircdb.checkCapabilities(hostmask, capabilities)
|
||||||
|
|
||||||
|
def _isPowerful(self, irc, msg):
|
||||||
|
if msg.nick == irc.nick:
|
||||||
|
return True # It's me.
|
||||||
|
if not ircutils.isUserHostmask(msg.prefix):
|
||||||
|
return True # It's a server.
|
||||||
|
chanserv = self.registryValue('ChanServ')
|
||||||
|
if ircutils.nickEqual(msg.nick, chanserv):
|
||||||
|
return True # It's ChanServ.
|
||||||
|
capability = _chanCap(msg.args[0], 'op')
|
||||||
|
if ircdb.checkCapability(msg.prefix, capability):
|
||||||
|
return True # It's a chanop.
|
||||||
|
return False # Default.
|
||||||
|
|
||||||
def _revenge(self, irc, channel, hostmask):
|
def _revenge(self, irc, channel, hostmask):
|
||||||
irc.queueMsg(ircmsgs.ban(channel, ircutils.banmask(hostmask)))
|
irc.queueMsg(ircmsgs.ban(channel, ircutils.banmask(hostmask)))
|
||||||
irc.queueMsg(ircmsgs.kick(channel,ircutils.nickFromHostmask(hostmask)))
|
irc.queueMsg(ircmsgs.kick(channel,ircutils.nickFromHostmask(hostmask)))
|
||||||
@ -152,8 +165,7 @@ class Enforcer(callbacks.Privmsg):
|
|||||||
channel = msg.args[0]
|
channel = msg.args[0]
|
||||||
kicked = msg.args[1].split(',')
|
kicked = msg.args[1].split(',')
|
||||||
deop = False
|
deop = False
|
||||||
if msg.nick != irc.nick and \
|
if not self._isPowerful(irc, msg):
|
||||||
not ircdb.checkCapability(msg.prefix, _chanCap(channel, 'op')):
|
|
||||||
for nick in kicked:
|
for nick in kicked:
|
||||||
hostmask = irc.state.nickToHostmask(nick)
|
hostmask = irc.state.nickToHostmask(nick)
|
||||||
if nick == irc.nick:
|
if nick == irc.nick:
|
||||||
@ -162,7 +174,7 @@ class Enforcer(callbacks.Privmsg):
|
|||||||
deop = True
|
deop = True
|
||||||
if self._isProtected(channel, hostmask):
|
if self._isProtected(channel, hostmask):
|
||||||
deop = True
|
deop = True
|
||||||
irc.queueMsg(ircmsgs.invite(channel, msg.args[1]))
|
irc.queueMsg(ircmsgs.invite(msg.args[1], channel))
|
||||||
if deop:
|
if deop:
|
||||||
deop = False
|
deop = False
|
||||||
if self.registryValue('takeRevenge', channel):
|
if self.registryValue('takeRevenge', channel):
|
||||||
@ -173,11 +185,8 @@ class Enforcer(callbacks.Privmsg):
|
|||||||
def doMode(self, irc, msg):
|
def doMode(self, irc, msg):
|
||||||
channel = msg.args[0]
|
channel = msg.args[0]
|
||||||
chanserv = self.registryValue('ChanServ', channel)
|
chanserv = self.registryValue('ChanServ', channel)
|
||||||
if not ircutils.isChannel(channel) or \
|
if not ircutils.isChannel(channel) or self._isPowerful(irc, msg):
|
||||||
(chanserv and msg.nick == chanserv):
|
|
||||||
return
|
return
|
||||||
if msg.nick != irc.nick and \
|
|
||||||
not ircdb.checkCapability(msg.prefix, _chanCap(channel, 'op')):
|
|
||||||
for (mode, value) in ircutils.separateModes(msg.args[1:]):
|
for (mode, value) in ircutils.separateModes(msg.args[1:]):
|
||||||
if value == msg.nick:
|
if value == msg.nick:
|
||||||
continue
|
continue
|
||||||
@ -221,9 +230,6 @@ class Enforcer(callbacks.Privmsg):
|
|||||||
else:
|
else:
|
||||||
irc.queueMsg(ircmsgs.deop(channel, msg.nick))
|
irc.queueMsg(ircmsgs.deop(channel, msg.nick))
|
||||||
elif mode == '+b':
|
elif mode == '+b':
|
||||||
# To be safe, only #channel,ops are allowed to ban.
|
|
||||||
if not ircdb.checkCapability(msg.prefix,
|
|
||||||
_chanCap(channel, 'op')):
|
|
||||||
irc.queueMsg(ircmsgs.unban(channel, value))
|
irc.queueMsg(ircmsgs.unban(channel, value))
|
||||||
if self.registryValue('takeRevenge', channel):
|
if self.registryValue('takeRevenge', channel):
|
||||||
self._revenge(irc, channel, msg.prefix)
|
self._revenge(irc, channel, msg.prefix)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user