i added an optional configuration autoRemoveUnregisteredQuiets to lift from database +q $~a entries, because they appears in search and are useless

This commit is contained in:
Nicolas Coevoet 2021-09-24 18:10:15 +02:00
parent 3ef7520394
commit 9c53e66bf8
2 changed files with 13 additions and 2 deletions

View File

@ -100,6 +100,8 @@ 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"""))

View File

@ -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:
@ -971,6 +972,10 @@ class Ircd(object):
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):
__slots__ = ('ircd', 'name', '_lists', 'queue', 'update', 'mark', 'action', 'dones', 'syn', 'opAsked',
@ -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