From 270b2c143f4e98248e47a7b44d23b109e968a78b Mon Sep 17 00:00:00 2001 From: Nicolas Coevoet Date: Tue, 1 Jun 2021 20:55:02 +0000 Subject: [PATCH] Added new config entries, removeAllBans|Quiets|Invites|Exempts to prevent by default the mass removal with ub * --- config.py | 13 +++++++++++-- plugin.py | 28 ++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/config.py b/config.py index 78cf0ea..f3a7f4a 100644 --- a/config.py +++ b/config.py @@ -79,7 +79,7 @@ conf.registerChannelValue(ChanTracker, 'opCommand', conf.registerChannelValue(ChanTracker, 'modesToAsk', registry.CommaSeparatedListOfStrings(['b','q'], """list of channel modes to sync into the bot's tracking database when it joins the channel""")) - + conf.registerChannelValue(ChanTracker, 'modesToAskWhenOpped', registry.CommaSeparatedListOfStrings(['e','I'], """list of channel modes to sync into the bot's tracking database when it is opped""")) @@ -88,8 +88,17 @@ 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, 'removeAllBans', + registry.Boolean(False, """prevent accidental removal of all bans""")) +conf.registerChannelValue(ChanTracker, 'removeAllQuiets', + registry.Boolean(False, """prevent accidental removal of all quiets""")) +conf.registerChannelValue(ChanTracker, 'removeAllExempts', + registry.Boolean(False, """prevent accidental removal of all exempts""")) +conf.registerChannelValue(ChanTracker, 'removeAllInvites', + registry.Boolean(False, """prevent accidental removal of all invites""")) + # announces related to logChannel - + conf.registerChannelValue(ChanTracker, 'logChannel', registry.String("", """where bot announces op's actions; it is highly recommended to set an appropriate operator's channel to receive the various useful messages, nick can be used"""),opSettable=False) diff --git a/plugin.py b/plugin.py index 277b820..70b6620 100644 --- a/plugin.py +++ b/plugin.py @@ -1709,6 +1709,13 @@ class ChanTracker(callbacks.Plugin,plugins.ChannelDBHandler): """[] [] sets -q on them, if * found, remove them all""" + isMass = False + for item in items: + if item == '*': + isMass = True + if isMass and not self.registryValue('removeAllQuiets',channel=channel): + irc.reply('removal of all quiets has been disabled for %s' % channel) + return b = self._removes(irc,msg,args,channel,'q',items,False) if not msg.nick == irc.nick and not b: irc.reply('nicks not found or hostmasks invalids or targets are not +q') @@ -1722,6 +1729,13 @@ class ChanTracker(callbacks.Plugin,plugins.ChannelDBHandler): for (option, arg) in optlist: if option == 'perm': perm = True + isMass = False + for item in items: + if item == '*': + isMass = True + if isMass and not self.registryValue('removeAllBans',channel=channel): + irc.reply('removal of all bans has been disabled for %s' % channel) + return b = self._removes(irc,msg,args,channel,'b',items,perm) if not msg.nick == irc.nick and not b: if perm: @@ -1737,6 +1751,13 @@ class ChanTracker(callbacks.Plugin,plugins.ChannelDBHandler): """[] [] sets -I on them, if * found, remove them all""" + isMass = False + for item in items: + if item == '*': + isMass = True + if isMass and not self.registryValue('removeAllInvites',channel=channel): + irc.reply('removal of all invites has been disabled for %s' % channel) + return b = self._removes(irc,msg,args,channel,'I',items,False) if not msg.nick == irc.nick and not b: irc.reply('nicks not found or hostmasks invalids or targets are not +I') @@ -1746,6 +1767,13 @@ class ChanTracker(callbacks.Plugin,plugins.ChannelDBHandler): """[] [] sets -e on them, if * found, remove them all""" + isMass = False + for item in items: + if item == '*': + isMass = True + if isMass and not self.registryValue('removeAllExempts',channel=channel): + irc.reply('removal of all exempts has been disabled for %s' % channel) + return b = self._removes(irc,msg,args,channel,'e',items,False) if not msg.nick == irc.nick and not b: irc.reply('nicks not found or hostmasks invalids or targets are not +e')