use a config option for store when we last checked for ban review.
That way we can skip bans already reviewed.
This commit is contained in:
parent
82a5cd7d08
commit
7c042b4a79
|
@ -52,3 +52,9 @@ conf.registerChannelValue(Bantracker.commentRequest.forward, 'channels',
|
||||||
"List of channels/nicks to forward the request if the op that set the ban/quiet"\
|
"List of channels/nicks to forward the request if the op that set the ban/quiet"\
|
||||||
" is in the forward list."))
|
" is in the forward list."))
|
||||||
|
|
||||||
|
|
||||||
|
# temp config
|
||||||
|
conf.registerGlobalValue(Bantracker, 'reviewTime',
|
||||||
|
registry.Integer(0, "", ))
|
||||||
|
conf.registerGlobalValue(Bantracker, 'reviewAfterTime',
|
||||||
|
registry.Integer(2, "", ))
|
||||||
|
|
|
@ -381,27 +381,35 @@ class Bantracker(callbacks.Plugin):
|
||||||
irc.reply(s, to=ban.who, private=True)
|
irc.reply(s, to=ban.who, private=True)
|
||||||
|
|
||||||
def reviewBans(self, irc):
|
def reviewBans(self, irc):
|
||||||
|
try:
|
||||||
self.log.debug('Checking for bans that need review ...')
|
self.log.debug('Checking for bans that need review ...')
|
||||||
now = time.mktime(time.gmtime())
|
now = time.mktime(time.gmtime())
|
||||||
try:
|
lastreview = self.registryValue('reviewTime')
|
||||||
|
reviewAfterTime = self.registryValue('reviewAfterTime') * 60 # time in mins
|
||||||
|
if not lastreview:
|
||||||
|
lastreview = now
|
||||||
for channel, bans in self.bans.iteritems():
|
for channel, bans in self.bans.iteritems():
|
||||||
for ban in bans:
|
for ban in bans:
|
||||||
age = now - ban.when
|
banTime = now - ban.when
|
||||||
self.log.debug(' channel %s ban %s (%s)', channel, ban.mask, age)
|
reviewTime = lastreview - ban.when
|
||||||
# FIXME doesn't check if op is not online
|
self.log.debug(' channel %s ban %s (%s/%s/%s)', channel, ban.mask, reviewTime,
|
||||||
# FIXME doesn't mark if the review was sent
|
reviewAfterTime, banTime)
|
||||||
if age > 120: # lets use mins for now
|
if reviewTime <= reviewAfterTime < banTime:
|
||||||
op = ban.who
|
op = ban.who
|
||||||
|
# ban.who can be a nick or IRC hostmask
|
||||||
|
if ircutils.isUserHostmask(op):
|
||||||
op = op[:op.find('!')]
|
op = op[:op.find('!')]
|
||||||
s = "Please review ban '%s' in %s" %(ban.mask, channel)
|
s = "Please review ban '%s' in %s" %(ban.mask, channel)
|
||||||
|
# FIXME doesn't check if op is not online
|
||||||
msg = ircmsgs.privmsg(op, s)
|
msg = ircmsgs.privmsg(op, s)
|
||||||
irc.queueMsg(msg)
|
irc.queueMsg(msg)
|
||||||
else:
|
elif banTime < reviewAfterTime:
|
||||||
# the bans left are even more recent
|
# the bans left are even more recent
|
||||||
break
|
break
|
||||||
|
self.setRegistryValue('reviewTime', now) # update last time reviewed
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
# I need to catch exceptions as they are silenced
|
# I need to catch exceptions as they are silenced
|
||||||
self.log.error('Except: %s' %e)
|
self.log.debug('Except: %s' %e)
|
||||||
|
|
||||||
def doLog(self, irc, channel, s):
|
def doLog(self, irc, channel, s):
|
||||||
if not self.registryValue('enabled', channel):
|
if not self.registryValue('enabled', channel):
|
||||||
|
|
Loading…
Reference in New Issue