mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-02-19 23:20:57 +01:00
Use a global q so urls snarfed by another plugin aren't snarfed by later plugins.
This commit is contained in:
parent
3bd1e009fa
commit
5042f9e1c8
@ -161,10 +161,10 @@ def channel(f):
|
|||||||
ff(irc, msg, args, *L)
|
ff(irc, msg, args, *L)
|
||||||
return utils.changeFunctionName(newf, f.func_name, f.__doc__)
|
return utils.changeFunctionName(newf, f.func_name, f.__doc__)
|
||||||
|
|
||||||
|
_snarfed = structures.smallqueue()
|
||||||
def urlSnarfer(f):
|
def urlSnarfer(f):
|
||||||
"""Protects the snarfer from loops and whatnot."""
|
"""Protects the snarfer from loops and whatnot."""
|
||||||
f = _threadedWrapMethod(f)
|
f = _threadedWrapMethod(f)
|
||||||
q = structures.smallqueue()
|
|
||||||
def newf(self, irc, msg, match, *L):
|
def newf(self, irc, msg, match, *L):
|
||||||
channel = msg.args[0]
|
channel = msg.args[0]
|
||||||
if ircutils.isChannel(channel):
|
if ircutils.isChannel(channel):
|
||||||
@ -174,15 +174,16 @@ def urlSnarfer(f):
|
|||||||
return
|
return
|
||||||
now = time.time()
|
now = time.time()
|
||||||
cutoff = now - conf.supybot.snarfThrottle()
|
cutoff = now - conf.supybot.snarfThrottle()
|
||||||
while q and q[0][2] < cutoff:
|
while _snarfed and _snarfed[0][2] < cutoff:
|
||||||
q.dequeue()
|
_snarfed.dequeue()
|
||||||
url = match.group(0)
|
url = match.group(0)
|
||||||
for (qUrl, target, when) in q:
|
for (qUrl, target, when) in q:
|
||||||
if url == qUrl and target == channel and not world.testing:
|
if url == qUrl and target == channel and not world.testing:
|
||||||
self.log.warning('Not snarfing %s from %r.', url, msg.prefix)
|
self.log.info('Not snarfing %s from %r: in queue.',
|
||||||
|
url, msg.prefix)
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
q.enqueue((url, channel, now))
|
_snarfed.enqueue((url, channel, now))
|
||||||
if self.threaded:
|
if self.threaded:
|
||||||
f(self, irc, msg, match, *L)
|
f(self, irc, msg, match, *L)
|
||||||
else:
|
else:
|
||||||
@ -192,7 +193,6 @@ def urlSnarfer(f):
|
|||||||
t.setDaemon(True)
|
t.setDaemon(True)
|
||||||
t.start()
|
t.start()
|
||||||
newf = utils.changeFunctionName(newf, f.func_name, f.__doc__)
|
newf = utils.changeFunctionName(newf, f.func_name, f.__doc__)
|
||||||
newf.q = q # This isn't necessary, it's just for debugging.
|
|
||||||
return newf
|
return newf
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user