From 9c53e66bf8589c531ec855c907486041a41d5bac Mon Sep 17 00:00:00 2001 From: Nicolas Coevoet Date: Fri, 24 Sep 2021 18:10:15 +0200 Subject: [PATCH] i added an optional configuration autoRemoveUnregisteredQuiets to lift from database +q $~a entries, because they appears in search and are useless --- config.py | 4 +++- plugin.py | 11 ++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/config.py b/config.py index 75ab5d8..9337887 100644 --- a/config.py +++ b/config.py @@ -100,7 +100,9 @@ conf.registerChannelValue(ChanTracker, 'modesToAskWhenOpped', conf.registerChannelValue(ChanTracker, 'autoExpire', registry.Integer(-1, """default expiration time for newly placed bans; -1 disables auto-expiration, otherwise it's in seconds""")) - +conf.registerChannelValue(ChanTracker, 'autoRemoveUnregisteredQuiets', + registry.Boolean(True, """auto remove from database unregistered quiets once expired -q $~a""")) + conf.registerChannelValue(ChanTracker, 'removeAllBans', registry.Boolean(False, """prevent accidental removal of all bans""")) conf.registerChannelValue(ChanTracker, 'removeAllQuiets', diff --git a/plugin.py b/plugin.py index 35f5be6..b536fad 100644 --- a/plugin.py +++ b/plugin.py @@ -949,6 +949,7 @@ class Ircd(object): ircutils.mircColor(mask, 'light blue'))) else: msgs.append('[#%s %s]' % (uid, mask)) + self.verifyRemoval(irc, channel, mode, mask, db, ct, uid) if commits > 0: db.commit() if logFunction: @@ -970,6 +971,10 @@ class Ircd(object): chan.patterns[uid] = Pattern(uid, pattern, int(regexp) == 1, trigger, life, mode, duration) c.close() + + def verifyRemoval (self, irc, channel, mode, value, db, ct, uid): + if ct.registryValue('autoRemoveUnregisteredQuiets', channel=channel, network=irc.network) and mode == 'q' and value == '$~a': + self.remove(uid, db) class Chan(object): @@ -4308,6 +4313,7 @@ class ChanTracker(callbacks.Plugin, plugins.ChannelDBHandler): toCommit = False toexpire = [] tolift = [] + toremove = [] if irc.isChannel(channel) and msg.args[1:] and channel in irc.state.channels: modes = ircutils.separateModes(msg.args[1:]) chan = self.getChan(irc, channel) @@ -4456,6 +4462,7 @@ class ChanTracker(callbacks.Plugin, plugins.ChannelDBHandler): or m in self.registryValue('modesToAskWhenOpped', channel=channel, network=irc.network): toCommit = True item = chan.removeItem(m, value, msg.prefix, c) + toremove.append(item) if n: n.addLog(channel, 'sets %s %s' % (mode, value)) if item: @@ -4552,7 +4559,9 @@ class ChanTracker(callbacks.Plugin, plugins.ChannelDBHandler): msgs.append(mode) if toCommit: db.commit() - + if len(toremove): + for r in toremove: + i.verifyRemoval(irc, item.channel, item.mode, item.value, db, self, item.uid) if irc.state.channels[channel].isHalfopPlus(irc.nick) \ and not self.registryValue('keepOp', channel=channel, network=irc.network): self.forceTickle = True