From 5851ae64cab1f8d4fa72e9c79f00d562ef0eaaed Mon Sep 17 00:00:00 2001 From: Nicolas Coevoet Date: Sat, 12 Apr 2014 12:27:25 +0200 Subject: [PATCH] add autoExpire to modes setted when the bot was offline --- plugin.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/plugin.py b/plugin.py index 17ad761..133ced9 100644 --- a/plugin.py +++ b/plugin.py @@ -167,9 +167,9 @@ def match (pattern,n,irc): if len(p): # remove ':' p = p[1:] - if p.find('$') != -1: + if p.find(extprefix) != -1 and not p.endswith(extprefix): # forward - p = p[(p.rfind('$')+1):] + p = p[(p.rfind(extprefix)+1):] if t == 'a': cache[key] = matchAccount (pattern,p,negate,n,extprefix) elif t == 'r': @@ -855,6 +855,7 @@ class Chan (object): else: # if begin_at == end_at --> that means forever c.execute("""INSERT INTO bans VALUES (NULL, ?, ?, ?, ?, ?, ?,NULL, NULL)""", (self.name,by,mode,value,when,when)) + i.isNew = True uid = c.lastrowid # leave channel's users list management to supybot ns = [] @@ -932,6 +933,7 @@ class Item (object): self.removed_by = None self.asked = False self.affects = [] + self.isNew = False def __repr__(self): end = self.expire @@ -1855,7 +1857,17 @@ class ChanTracker(callbacks.Plugin,plugins.ChannelDBHandler): if irc.isChannel(channel) and channel in irc.state.channels: if mode in self.registryValue('modesToAsk',channel=channel) or mode in self.registryValue('modesToAskWhenOpped',channel=channel): chan = self.getChan(irc,channel) - chan.addItem(mode,value,prefix,float(date),self.getDb(irc.network),False) + item = chan.addItem(mode,value,prefix,float(date),self.getDb(irc.network),False) + # added expire date if new modes were added when the bot was offline + expire = self.registryValue('autoExpire',channel=item.channel) + if expire > 0 and item.isNew: + f = None + if self.registryValue('announceBotEdit',channel=item.channel): + f = self._logChan + i = self.getIrc(irc) + i.edit(irc,item.channel,item.mode,item.value,expire,irc.prefix,self.getDb(irc.network),self._schedule,f) + item.isNew = False + self.forceTickle = True def _endList (self,irc,msg,channel,mode): if irc.isChannel(channel) and channel in irc.state.channels: