Add option to exempt voiced users from channel protections.

This commit is contained in:
Krytarik Raido 2022-10-12 18:34:04 +02:00
parent 4c53d28f11
commit 2646838ad7
2 changed files with 25 additions and 19 deletions

View File

@ -86,6 +86,9 @@ conf.registerChannelValue(ChanTracker, 'triggerOps',
conf.registerChannelValue(ChanTracker, 'allowOpToConfig', conf.registerChannelValue(ChanTracker, 'allowOpToConfig',
registry.Boolean(False, """grant channel operators the ability to configure some ChanTracker protections for their channel""")) registry.Boolean(False, """grant channel operators the ability to configure some ChanTracker protections for their channel"""))
conf.registerChannelValue(ChanTracker, 'ignoreVoicedUser',
registry.Boolean(False, """exempt voiced users from channel protections"""))
conf.registerChannelValue(ChanTracker, 'opCommand', conf.registerChannelValue(ChanTracker, 'opCommand',
registry.String("PRIVMSG ChanServ :OP $channel $nick", """command used to obtain channel operator status"""), opSettable=False) registry.String("PRIVMSG ChanServ :OP $channel $nick", """command used to obtain channel operator status"""), opSettable=False)

View File

@ -2232,7 +2232,8 @@ class ChanTracker(callbacks.Plugin, plugins.ChannelDBHandler):
tell if <nick> is vip in <channel>; mostly used for debugging""" tell if <nick> is vip in <channel>; mostly used for debugging"""
i = self.getIrc(irc) i = self.getIrc(irc)
if nick in i.nicks: if nick in i.nicks:
irc.reply(self._isVip(irc, channel, self.getNick(irc, nick))) isVip = self._isVip(irc, channel, self.getNick(irc, nick))
irc.reply(str(isVip))
else: else:
irc.reply('nick not found') irc.reply('nick not found')
self._tickle(irc) self._tickle(irc)
@ -2254,7 +2255,8 @@ class ChanTracker(callbacks.Plugin, plugins.ChannelDBHandler):
if p.startswith('$a:'): if p.startswith('$a:'):
best = p best = p
break break
irc.reply(chan.isWrong(best)) isWrong = chan.isWrong(best)
irc.reply(str(isWrong))
else: else:
irc.reply('nick not found') irc.reply('nick not found')
self._tickle(irc) self._tickle(irc)
@ -3771,7 +3773,6 @@ class ChanTracker(callbacks.Plugin, plugins.ChannelDBHandler):
isNick = self._isSomething(irc, channel, best, 'nick') isNick = self._isSomething(irc, channel, best, 'nick')
if isNick: if isNick:
isBad = self._isBad(irc, channel, best) isBad = self._isBad(irc, channel, best)
kind = None
if isBad: if isBad:
kind = 'bad' kind = 'bad'
else: else:
@ -3878,8 +3879,7 @@ class ChanTracker(callbacks.Plugin, plugins.ChannelDBHandler):
break break
chan = self.getChan(irc, channel) chan = self.getChan(irc, channel)
n.addLog(channel, 'NOTICE | %s' % text) n.addLog(channel, 'NOTICE | %s' % text)
isVip = self._isVip(irc, channel, n) if not self._isVip(irc, channel, n):
if not isVip:
isNotice = self._isSomething(irc, channel, best, 'notice') isNotice = self._isSomething(irc, channel, best, 'notice')
isBad = False isBad = False
if isNotice: if isNotice:
@ -3895,14 +3895,14 @@ class ChanTracker(callbacks.Plugin, plugins.ChannelDBHandler):
(m, p) = self.getIrcdMode(irc, mode, best) (m, p) = self.getIrcdMode(irc, mode, best)
self._act(irc, channel, m, p, duration, comment, msg.nick) self._act(irc, channel, m, p, duration, comment, msg.nick)
self.forceTickle = True self.forceTickle = True
if self.registryValue('announceNotice', channel=channel, network=irc.network): if self.registryValue('announceNotice', channel=channel, network=irc.network):
if not chan.isWrong(best): if not chan.isWrong(best):
if self.registryValue('useColorForAnnounces', channel=channel, network=irc.network): if self.registryValue('useColorForAnnounces', channel=channel, network=irc.network):
self._logChan(irc, channel, '[%s] %s notice "%s"' % (ircutils.bold( self._logChan(irc, channel, '[%s] %s notice "%s"' % (ircutils.bold(
channel), ircutils.mircColor(msg.prefix, 'light blue'), text)) channel), ircutils.mircColor(msg.prefix, 'light blue'), text))
else: else:
self._logChan(irc, channel, '[%s] %s notice "%s"' % ( self._logChan(irc, channel, '[%s] %s notice "%s"' % (
channel, msg.prefix, text)) channel, msg.prefix, text))
self._tickle(irc) self._tickle(irc)
def _schedule(self, irc, end, force): def _schedule(self, irc, end, force):
@ -3924,6 +3924,9 @@ class ChanTracker(callbacks.Plugin, plugins.ChannelDBHandler):
protected = ircdb.makeChannelCapability(channel, 'protected') protected = ircdb.makeChannelCapability(channel, 'protected')
if ircdb.checkCapability(n.prefix, protected): if ircdb.checkCapability(n.prefix, protected):
return True return True
if self.registryValue('ignoreVoicedUser', channel=channel, network=irc.network) \
and irc.state.channels[channel].isVoicePlus(n.prefix.split('!')[0]):
return True
return False return False
def doPrivmsg(self, irc, msg): def doPrivmsg(self, irc, msg):
@ -3977,8 +3980,7 @@ class ChanTracker(callbacks.Plugin, plugins.ChannelDBHandler):
message = '- %s -' % text message = '- %s -' % text
n.addLog(channel, message) n.addLog(channel, message)
# protection features # protection features
isVip = self._isVip(irc, channel, n) if not self._isVip(irc, channel, n):
if not isVip:
isCtcp = False isCtcp = False
if isCtcpMsg and not isAction: if isCtcpMsg and not isAction:
isCtcp = self._isSomething(irc, channel, best, 'ctcp') isCtcp = self._isSomething(irc, channel, best, 'ctcp')
@ -4034,8 +4036,8 @@ class ChanTracker(callbacks.Plugin, plugins.ChannelDBHandler):
self._act(irc, channel, m, p, isPattern.duration, self._act(irc, channel, m, p, isPattern.duration,
'matches #%s : %s' % (isPattern.uid, isMatch[1]), msg.nick) 'matches #%s : %s' % (isPattern.uid, isMatch[1]), msg.nick)
isBad = self._isBad(irc, channel, best) isBad = self._isBad(irc, channel, best)
self.forceTickle = True
chan.countpattern(isPattern.uid, self.getDb(irc.network)) chan.countpattern(isPattern.uid, self.getDb(irc.network))
self.forceTickle = True
elif not isRepeat: elif not isRepeat:
key = 'pattern%s' % channel key = 'pattern%s' % channel
if key in chan.repeatLogs: if key in chan.repeatLogs:
@ -4057,7 +4059,6 @@ class ChanTracker(callbacks.Plugin, plugins.ChannelDBHandler):
if not (isPattern or isTemporaryPattern) \ if not (isPattern or isTemporaryPattern) \
and (isFlood or isLowFlood or isRepeat or isHilight or isCap or isCtcp): and (isFlood or isLowFlood or isRepeat or isHilight or isCap or isCtcp):
isBad = self._isBad(irc, channel, best) isBad = self._isBad(irc, channel, best)
kind = None
duration = 0 duration = 0
if isBad: if isBad:
kind = 'bad' kind = 'bad'
@ -4272,7 +4273,8 @@ class ChanTracker(callbacks.Plugin, plugins.ChannelDBHandler):
for nick in list(irc.state.channels[channel].users): for nick in list(irc.state.channels[channel].users):
L.append(nick) L.append(nick)
for nick in L: for nick in L:
if not self._isVip(irc, channel, self.getNick(irc, nick)): isVip = self._isVip(irc, channel, self.getNick(irc, nick))
if not isVip:
n = self.getNick(irc, nick) n = self.getNick(irc, nick)
m = match(target, n, irc, self.registryValue('resolveIp')) m = match(target, n, irc, self.registryValue('resolveIp'))
if m: if m:
@ -4342,7 +4344,8 @@ class ChanTracker(callbacks.Plugin, plugins.ChannelDBHandler):
if item and len(item.affects): if item and len(item.affects):
for affected in item.affects: for affected in item.affects:
nick = affected.split('!')[0] nick = affected.split('!')[0]
if self._isVip(irc, channel, self.getNick(irc, nick)): isVip = self._isVip(irc, channel, self.getNick(irc, nick))
if isVip:
continue continue
if m in self.registryValue('modesToAsk', channel=channel, network=irc.network) \ if m in self.registryValue('modesToAsk', channel=channel, network=irc.network) \
and self.registryValue('doActionAgainstAffected', channel=channel, network=irc.network) \ and self.registryValue('doActionAgainstAffected', channel=channel, network=irc.network) \