From e33c69219a4ebb9ddf83d26f1c0c916bb616f26d Mon Sep 17 00:00:00 2001 From: Nicolas Coevoet Date: Mon, 24 Nov 2014 21:57:39 +0100 Subject: [PATCH] added --perm option for ub, to remove persistant bans from Channel.ban list --- plugin.py | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/plugin.py b/plugin.py index 90cfc50..f3e44f1 100644 --- a/plugin.py +++ b/plugin.py @@ -1498,7 +1498,7 @@ class ChanTracker(callbacks.Plugin,plugins.ChannelDBHandler): """[] [] sets - on them, if * found, remove them all""" - b = self._removes(irc,msg,args,channel,mode,items) + b = self._removes(irc,msg,args,channel,mode,items,False) if not msg.nick == irc.nick and not b: irc.reply('unknown patterns, already removed or unsupported mode') undo = wrap(undo,['op','letter',many('something')]) @@ -1507,25 +1507,29 @@ class ChanTracker(callbacks.Plugin,plugins.ChannelDBHandler): """[] [] sets -q on them, if * found, remove them all""" - b = self._removes(irc,msg,args,channel,'q',items) + b = self._removes(irc,msg,args,channel,'q',items,False) if not msg.nick == irc.nick and not b: irc.reply('unknown patterns, already removed or unsupported mode') uq = wrap(uq,['op',many('something')]) - def ub (self, irc, msg, args, channel, items): - """[] [] + def ub (self, irc, msg, args, channel, optlist, items): + """[] [--perm] [] - sets -b on them, if * found, remove them all""" - b = self._removes(irc,msg,args,channel,'b',items) + sets -b on them, if * found, remove them all, --perm to remove them for permanent bans""" + perm = False + for (option, arg) in optlist: + if option == 'perm': + perm = True + b = self._removes(irc,msg,args,channel,'b',items,perm) if not msg.nick == irc.nick and not b: irc.reply('unknown patterns, already removed or unsupported mode') - ub = wrap(ub,['op',many('something')]) + ub = wrap(ub,['op',getopts({'perm':''}),many('something')]) def ui (self, irc, msg, args, channel, items): """[] [] sets -I on them, if * found, remove them all""" - b = self._removes(irc,msg,args,channel,'I',items) + b = self._removes(irc,msg,args,channel,'I',items,False) if not msg.nick == irc.nick and not b: irc.reply('unknown patterns, already removed or unsupported mode') ui = wrap(ui,['op',many('something')]) @@ -1534,7 +1538,7 @@ class ChanTracker(callbacks.Plugin,plugins.ChannelDBHandler): """[] [] sets -e on them, if * found, remove them all""" - b = self._removes(irc,msg,args,channel,'e',items) + b = self._removes(irc,msg,args,channel,'e',items,False) if not msg.nick == irc.nick and not b: irc.reply('unknown patterns, already removed or unsupported mode') ue = wrap(ue,['op',many('something')]) @@ -1714,7 +1718,7 @@ class ChanTracker(callbacks.Plugin,plugins.ChannelDBHandler): for item in targets: r = self.getIrcdMode(irc,mode,item) if i.add(irc,channel,r[0],r[1],duration,msg.prefix,self.getDb(irc.network)): - if perm and r[1].find(self.getIrcdExtbansPrefix(irc)) == -1: + if perm: chan = ircdb.channels.getChannel(channel) chan.addBan(r[1],0) ircdb.channels.setChannel(channel, chan) @@ -1731,7 +1735,7 @@ class ChanTracker(callbacks.Plugin,plugins.ChannelDBHandler): self._tickle(irc) return len(items) == n - def _removes (self,irc,msg,args,channel,mode,items): + def _removes (self,irc,msg,args,channel,mode,items,perm=False): i = self.getIrc(irc) chan = self.getChan(irc,channel) targets = [] @@ -1768,6 +1772,13 @@ class ChanTracker(callbacks.Plugin,plugins.ChannelDBHandler): f = self._logChan for item in targets: r = self.getIrcdMode(irc,mode,item) + if perm: + chan = ircdb.channels.getChannel(channel) + try: + chan.removeBan(item) + except: + self.log.info('%s is not in Channel.ban' % item) + ircdb.channels.setChannel(channel, chan) if i.edit(irc,channel,r[0],r[1],0,msg.prefix,self.getDb(irc.network),None,f,self): count = count + 1 self.forceTickle = True