fix: running @updatebt would trigger a request msg for each new ban.
added option for enable request msg, defaults to False bot owners should run @config plugins.Bantracker.commentRequest True
This commit is contained in:
parent
0cb8fc1fb7
commit
b463ee3b26
|
@ -34,7 +34,9 @@ conf.registerGlobalValue(Bantracker, 'database',
|
||||||
conf.registerGlobalValue(Bantracker, 'bansite',
|
conf.registerGlobalValue(Bantracker, 'bansite',
|
||||||
registry.String('', "Web site for the bantracker, without the 'bans.cgi' appended", private=True))
|
registry.String('', "Web site for the bantracker, without the 'bans.cgi' appended", private=True))
|
||||||
|
|
||||||
conf.registerGroup(Bantracker, 'commentRequest')
|
conf.registerChannelValue(Bantracker, 'commentRequest',
|
||||||
|
registry.Boolean(False,
|
||||||
|
"Enable message requests from bot"))
|
||||||
conf.registerChannelValue(Bantracker.commentRequest, 'type',
|
conf.registerChannelValue(Bantracker.commentRequest, 'type',
|
||||||
SpaceSeparatedListOfTypes(['removal', 'ban', 'quiet'],
|
SpaceSeparatedListOfTypes(['removal', 'ban', 'quiet'],
|
||||||
"List of events for which the bot should request a comment."))
|
"List of events for which the bot should request a comment."))
|
||||||
|
|
|
@ -339,9 +339,11 @@ class Bantracker(callbacks.Plugin):
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def requestComment(self, irc, channel, ban, type=None):
|
def requestComment(self, irc, channel, ban, type=None):
|
||||||
|
if not ban or not self.registryValue('commentRequest', channel):
|
||||||
|
return
|
||||||
# check if we should request a comment
|
# check if we should request a comment
|
||||||
if nickMatch(ban.who, self.registryValue('commentRequest.ignore', channel=channel)):
|
if nickMatch(ban.who, self.registryValue('commentRequest.ignore', channel=channel)):
|
||||||
return
|
return
|
||||||
# check the type of the action taken
|
# check the type of the action taken
|
||||||
mask = ban.mask
|
mask = ban.mask
|
||||||
if not type:
|
if not type:
|
||||||
|
@ -384,7 +386,12 @@ class Bantracker(callbacks.Plugin):
|
||||||
# self.logs[channel] = self.logs[channel][-199:] + [s.strip()]
|
# self.logs[channel] = self.logs[channel][-199:] + [s.strip()]
|
||||||
self.logs[channel].append(s.strip())
|
self.logs[channel].append(s.strip())
|
||||||
|
|
||||||
def doKickban(self, irc, channel, nick, target, kickmsg = None, use_time = None, extra_comment = None):
|
def doKickban(self, irc, channel, *args, **kwargs):
|
||||||
|
ban = self._doKickban(irc, channel, *args, **kwargs)
|
||||||
|
self.requestComment(irc, channel, ban)
|
||||||
|
return ban
|
||||||
|
|
||||||
|
def _doKickban(self, irc, channel, nick, target, kickmsg = None, use_time = None, extra_comment = None):
|
||||||
if not self.registryValue('enabled', channel):
|
if not self.registryValue('enabled', channel):
|
||||||
return
|
return
|
||||||
n = now()
|
n = now()
|
||||||
|
@ -400,8 +407,7 @@ class Bantracker(callbacks.Plugin):
|
||||||
self.bans[channel] = []
|
self.bans[channel] = []
|
||||||
ban = Ban(mask=target, who=nick, when=time.mktime(time.gmtime()), id=id)
|
ban = Ban(mask=target, who=nick, when=time.mktime(time.gmtime()), id=id)
|
||||||
self.bans[channel].append(ban)
|
self.bans[channel].append(ban)
|
||||||
self.requestComment(irc, channel, ban)
|
return ban
|
||||||
return id
|
|
||||||
|
|
||||||
def doUnban(self, irc, channel, nick, mask):
|
def doUnban(self, irc, channel, nick, mask):
|
||||||
if not self.registryValue('enabled', channel):
|
if not self.registryValue('enabled', channel):
|
||||||
|
@ -650,7 +656,7 @@ class Bantracker(callbacks.Plugin):
|
||||||
hostmask = self.nick_to_host(irc, target)
|
hostmask = self.nick_to_host(irc, target)
|
||||||
|
|
||||||
self.doLog(irc, channel.lower(), '*** %s requested a mark for %s\n' % (msg.nick, target))
|
self.doLog(irc, channel.lower(), '*** %s requested a mark for %s\n' % (msg.nick, target))
|
||||||
self.doKickban(irc, channel.lower(), msg.nick, hostmask, kickmsg)
|
self._doKickban(irc, channel.lower(), msg.nick, hostmask, kickmsg)
|
||||||
irc.replySuccess()
|
irc.replySuccess()
|
||||||
|
|
||||||
mark = wrap(mark, [optional('channel'), 'something', additional('text')])
|
mark = wrap(mark, [optional('channel'), 'something', additional('text')])
|
||||||
|
@ -868,7 +874,7 @@ class Bantracker(callbacks.Plugin):
|
||||||
nick = "Automated-Addition"
|
nick = "Automated-Addition"
|
||||||
self.log.info("Adding ban %s to %s (%s)" % (str(ban).replace('%', '%%'), chan, nick))
|
self.log.info("Adding ban %s to %s (%s)" % (str(ban).replace('%', '%%'), chan, nick))
|
||||||
self.doLog(irc, channel.lower(), '*** Ban sync from channel: %s\n' % str(ban).replace('%', '%%'))
|
self.doLog(irc, channel.lower(), '*** Ban sync from channel: %s\n' % str(ban).replace('%', '%%'))
|
||||||
self.doKickban(irc, chan, nick, ban.mask, use_time = ban.when)
|
self._doKickban(irc, chan, nick, ban.mask, use_time = ban.when)
|
||||||
return len(add_bans)
|
return len(add_bans)
|
||||||
|
|
||||||
if not self.check_auth(irc, msg, args, 'owner'):
|
if not self.check_auth(irc, msg, args, 'owner'):
|
||||||
|
|
Loading…
Reference in New Issue