mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-11-22 02:37:22 +01:00
Added split throttling to the Herald plugin.
This commit is contained in:
parent
13e1f7ccb9
commit
d43828ecfa
@ -51,6 +51,9 @@ conf.registerChannelValue(Herald.throttle, 'afterPart',
|
|||||||
registry.NonNegativeInteger(0, """Determines the minimum number of seconds
|
registry.NonNegativeInteger(0, """Determines the minimum number of seconds
|
||||||
after parting that the bot will not herald the person when he or she
|
after parting that the bot will not herald the person when he or she
|
||||||
rejoins."""))
|
rejoins."""))
|
||||||
|
conf.registerChannelValue(Herald.throttle, 'afterSplit',
|
||||||
|
registry.NonNegativeInteger(60, """Determines the minimum number of seconds
|
||||||
|
after a netsplit that the bot will not herald the users that split."""))
|
||||||
conf.registerChannelValue(Herald, 'default',
|
conf.registerChannelValue(Herald, 'default',
|
||||||
registry.String('', """Sets the default herald to use. If a user has a
|
registry.String('', """Sets the default herald to use. If a user has a
|
||||||
personal herald specified, that will be used instead. If set to the empty
|
personal herald specified, that will be used instead. If set to the empty
|
||||||
|
|||||||
@ -40,6 +40,7 @@ import supybot.ircmsgs as ircmsgs
|
|||||||
import supybot.plugins as plugins
|
import supybot.plugins as plugins
|
||||||
import supybot.ircutils as ircutils
|
import supybot.ircutils as ircutils
|
||||||
import supybot.callbacks as callbacks
|
import supybot.callbacks as callbacks
|
||||||
|
from supybot.structures import TimeoutQueue
|
||||||
|
|
||||||
filename = conf.supybot.directories.data.dirize('Herald.db')
|
filename = conf.supybot.directories.data.dirize('Herald.db')
|
||||||
|
|
||||||
@ -59,6 +60,8 @@ class Herald(callbacks.Plugin):
|
|||||||
self.db = HeraldDB(filename)
|
self.db = HeraldDB(filename)
|
||||||
world.flushers.append(self.db.flush)
|
world.flushers.append(self.db.flush)
|
||||||
self.lastParts = plugins.ChannelUserDictionary()
|
self.lastParts = plugins.ChannelUserDictionary()
|
||||||
|
splitTimeout = conf.supybot.plugins.Herald.throttle.afterSplit
|
||||||
|
self.splitters = TimeoutQueue(splitTimeout)
|
||||||
self.lastHerald = plugins.ChannelUserDictionary()
|
self.lastHerald = plugins.ChannelUserDictionary()
|
||||||
|
|
||||||
def die(self):
|
def die(self):
|
||||||
@ -67,14 +70,31 @@ class Herald(callbacks.Plugin):
|
|||||||
self.db.close()
|
self.db.close()
|
||||||
self.__parent.die()
|
self.__parent.die()
|
||||||
|
|
||||||
|
def doQuit(self, irc, msg):
|
||||||
|
# We want to observe netsplits and keep from heralding users rejoining
|
||||||
|
# after one.
|
||||||
|
if ircmsgs.isSplit(msg):
|
||||||
|
self.splitters.enqueue(msg.nick)
|
||||||
|
try:
|
||||||
|
id = ircdb.users.getUserId(msg.prefix)
|
||||||
|
self.splitters.enqueue(id)
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
|
||||||
def doJoin(self, irc, msg):
|
def doJoin(self, irc, msg):
|
||||||
if ircutils.strEqual(irc.nick, msg.nick):
|
if ircutils.strEqual(irc.nick, msg.nick):
|
||||||
return # It's us.
|
return # It's us.
|
||||||
|
if msg.nick in splitters:
|
||||||
|
self.log.debug('Not heralding %s, recent split.', msg.nick)
|
||||||
|
return # Recently split.
|
||||||
channel = msg.args[0]
|
channel = msg.args[0]
|
||||||
irc = callbacks.SimpleProxy(irc, msg)
|
irc = callbacks.SimpleProxy(irc, msg)
|
||||||
if self.registryValue('heralding', channel):
|
if self.registryValue('heralding', channel):
|
||||||
try:
|
try:
|
||||||
id = ircdb.users.getUserId(msg.prefix)
|
id = ircdb.users.getUserId(msg.prefix)
|
||||||
|
if id in splitters:
|
||||||
|
self.log.debug('Not heralding id #%s, recent split.', id)
|
||||||
|
return
|
||||||
herald = self.db[channel, id]
|
herald = self.db[channel, id]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
default = self.registryValue('default', channel)
|
default = self.registryValue('default', channel)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user