mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-23 10:34:19 +01:00
Should be a fix for the double relaying of topics.
This commit is contained in:
parent
383559e479
commit
2d0be46cd0
@ -53,7 +53,7 @@ import supybot.ircmsgs as ircmsgs
|
|||||||
import supybot.ircutils as ircutils
|
import supybot.ircutils as ircutils
|
||||||
import supybot.registry as registry
|
import supybot.registry as registry
|
||||||
import supybot.callbacks as callbacks
|
import supybot.callbacks as callbacks
|
||||||
from supybot.structures import RingBuffer
|
from supybot.structures import RingBuffer, MultiSet
|
||||||
|
|
||||||
def configure(advanced):
|
def configure(advanced):
|
||||||
from supybot.questions import output, expect, anything, something, yn
|
from supybot.questions import output, expect, anything, something, yn
|
||||||
@ -102,6 +102,7 @@ class Relay(callbacks.Privmsg):
|
|||||||
self._whois = {}
|
self._whois = {}
|
||||||
self.lastmsg = {}
|
self.lastmsg = {}
|
||||||
self.ircstates = {}
|
self.ircstates = {}
|
||||||
|
self.queuedTopics = structures.MultiSet()
|
||||||
self.last20Privmsgs = ircutils.IrcDict()
|
self.last20Privmsgs = ircutils.IrcDict()
|
||||||
|
|
||||||
def __call__(self, irc, msg):
|
def __call__(self, irc, msg):
|
||||||
@ -487,14 +488,26 @@ class Relay(callbacks.Privmsg):
|
|||||||
|
|
||||||
def doTopic(self, irc, msg):
|
def doTopic(self, irc, msg):
|
||||||
irc = self._getRealIrc(irc)
|
irc = self._getRealIrc(irc)
|
||||||
if ircutils.strEqual(msg.nick, irc.nick):
|
|
||||||
return
|
|
||||||
(channel, newTopic) = msg.args
|
(channel, newTopic) = msg.args
|
||||||
if channel not in self.registryValue('channels'):
|
if channel not in self.registryValue('channels'):
|
||||||
return
|
return
|
||||||
network = self._getIrcName(irc)
|
network = self._getIrcName(irc)
|
||||||
if self.registryValue('topicSync', channel):
|
if self.registryValue('topicSync', channel):
|
||||||
m = ircmsgs.topic(channel, newTopic)
|
m = ircmsgs.topic(channel, newTopic)
|
||||||
|
for otherIrc in world.ircs:
|
||||||
|
if irc != otherIrc:
|
||||||
|
try:
|
||||||
|
if otherIrc.state.getTopic(channel) != newTopic:
|
||||||
|
if (otherIrc, newTopic) not in self.queuedTopics:
|
||||||
|
self.queuedTopics.add((otherIrc, newTopic))
|
||||||
|
otherIrc.queueMsg(m)
|
||||||
|
else:
|
||||||
|
self.queuedTopics.remove((otherIrc, newTopic))
|
||||||
|
|
||||||
|
except KeyError:
|
||||||
|
self.log.warning('Not on %s on %s, '
|
||||||
|
'can\'t sync topics.',
|
||||||
|
channel, otherIrc.network)
|
||||||
else:
|
else:
|
||||||
s = 'topic change by %s on %s: %s' % (msg.nick, network, newTopic)
|
s = 'topic change by %s on %s: %s' % (msg.nick, network, newTopic)
|
||||||
m = ircmsgs.privmsg(channel, s)
|
m = ircmsgs.privmsg(channel, s)
|
||||||
@ -523,20 +536,6 @@ class Relay(callbacks.Privmsg):
|
|||||||
s = self._formatPrivmsg(irc.nick, network, msg)
|
s = self._formatPrivmsg(irc.nick, network, msg)
|
||||||
relayMsg = ircmsgs.privmsg(channel, s)
|
relayMsg = ircmsgs.privmsg(channel, s)
|
||||||
self._sendToOthers(irc, relayMsg)
|
self._sendToOthers(irc, relayMsg)
|
||||||
elif msg.command == 'TOPIC' and len(msg.args) > 1 and \
|
|
||||||
self.registryValue('topicSync', msg.args[0]):
|
|
||||||
(channel, topic) = msg.args
|
|
||||||
if channel in self.registryValue('channels'):
|
|
||||||
for otherIrc in world.ircs:
|
|
||||||
if otherIrc != irc:
|
|
||||||
try:
|
|
||||||
if otherIrc.state.getTopic(channel) != topic:
|
|
||||||
otherIrc.queueMsg(msg)
|
|
||||||
except KeyError:
|
|
||||||
self.log.warning('Not on %s on %s -- '
|
|
||||||
'Can\'t synchronize topics.',
|
|
||||||
channel, otherIrc.server)
|
|
||||||
|
|
||||||
return msg
|
return msg
|
||||||
|
|
||||||
Class = Relay
|
Class = Relay
|
||||||
|
Loading…
Reference in New Issue
Block a user