mirror of
https://github.com/jlu5/PyLink.git
synced 2024-11-27 21:19:31 +01:00
relay: unbreak topic handling (closes #68)
Introducing a new .topicset attributing in IrcChannel denoting whether we've received a TOPIC for this channel from the uplink yet.
This commit is contained in:
parent
e76d31d14e
commit
b1e409ff3e
@ -49,6 +49,7 @@ class IrcChannel():
|
|||||||
self.modes = set()
|
self.modes = set()
|
||||||
self.topic = ''
|
self.topic = ''
|
||||||
self.ts = int(time.time())
|
self.ts = int(time.time())
|
||||||
|
self.topicset = False
|
||||||
self.prefixmodes = {'ops': set(), 'halfops': set(), 'voices': set(),
|
self.prefixmodes = {'ops': set(), 'halfops': set(), 'voices': set(),
|
||||||
'owners': set(), 'admins': set()}
|
'owners': set(), 'admins': set()}
|
||||||
|
|
||||||
|
@ -210,9 +210,9 @@ def initializeChannel(irc, channel):
|
|||||||
relayModes(remoteirc, irc, remoteirc.sid, remotechan)
|
relayModes(remoteirc, irc, remoteirc.sid, remotechan)
|
||||||
relayModes(irc, remoteirc, irc.sid, channel)
|
relayModes(irc, remoteirc, irc.sid, channel)
|
||||||
topic = remoteirc.channels[relay[1]].topic
|
topic = remoteirc.channels[relay[1]].topic
|
||||||
# XXX: find a more elegant way to do this
|
# Only update the topic if it's different from what we already have,
|
||||||
# Only update the topic if it's different from what we already have.
|
# and topic bursting is complete.
|
||||||
if topic and topic != irc.channels[channel].topic:
|
if remoteirc.channels[channel].topicset and topic != irc.channels[channel].topic:
|
||||||
irc.proto.topicServer(irc, irc.sid, channel, topic)
|
irc.proto.topicServer(irc, irc.sid, channel, topic)
|
||||||
|
|
||||||
log.debug('(%s) initializeChannel: joining our users: %s', irc.name, c.users)
|
log.debug('(%s) initializeChannel: joining our users: %s', irc.name, c.users)
|
||||||
@ -506,25 +506,20 @@ utils.add_hook(handle_mode, 'MODE')
|
|||||||
def handle_topic(irc, numeric, command, args):
|
def handle_topic(irc, numeric, command, args):
|
||||||
channel = args['channel']
|
channel = args['channel']
|
||||||
topic = args['topic']
|
topic = args['topic']
|
||||||
# XXX: find a more elegant way to do this
|
for name, remoteirc in utils.networkobjects.items():
|
||||||
# Topics with content take precedence over empty topics.
|
if irc.name == name:
|
||||||
# This prevents us from overwriting topics on channels with
|
continue
|
||||||
# emptiness just because a leaf network hasn't received it yet.
|
|
||||||
if topic:
|
|
||||||
for name, remoteirc in utils.networkobjects.items():
|
|
||||||
if irc.name == name:
|
|
||||||
continue
|
|
||||||
|
|
||||||
remotechan = findRemoteChan(irc, remoteirc, channel)
|
remotechan = findRemoteChan(irc, remoteirc, channel)
|
||||||
# Don't send if the remote topic is the same as ours.
|
# Don't send if the remote topic is the same as ours.
|
||||||
if remotechan is None or topic == remoteirc.channels[remotechan].topic:
|
if remotechan is None or topic == remoteirc.channels[remotechan].topic:
|
||||||
continue
|
continue
|
||||||
# This might originate from a server too.
|
# This might originate from a server too.
|
||||||
remoteuser = getRemoteUser(irc, remoteirc, numeric, spawnIfMissing=False)
|
remoteuser = getRemoteUser(irc, remoteirc, numeric, spawnIfMissing=False)
|
||||||
if remoteuser:
|
if remoteuser:
|
||||||
remoteirc.proto.topicClient(remoteirc, remoteuser, remotechan, topic)
|
remoteirc.proto.topicClient(remoteirc, remoteuser, remotechan, topic)
|
||||||
else:
|
else:
|
||||||
remoteirc.proto.topicServer(remoteirc, remoteirc.sid, remotechan, topic)
|
remoteirc.proto.topicServer(remoteirc, remoteirc.sid, remotechan, topic)
|
||||||
utils.add_hook(handle_topic, 'TOPIC')
|
utils.add_hook(handle_topic, 'TOPIC')
|
||||||
|
|
||||||
def handle_kill(irc, numeric, command, args):
|
def handle_kill(irc, numeric, command, args):
|
||||||
|
@ -610,6 +610,7 @@ def handle_ftopic(irc, numeric, command, args):
|
|||||||
setter = args[2]
|
setter = args[2]
|
||||||
topic = args[-1]
|
topic = args[-1]
|
||||||
irc.channels[channel].topic = topic
|
irc.channels[channel].topic = topic
|
||||||
|
irc.channels[channel].topicset = True
|
||||||
return {'channel': channel, 'setter': setter, 'ts': ts, 'topic': topic}
|
return {'channel': channel, 'setter': setter, 'ts': ts, 'topic': topic}
|
||||||
|
|
||||||
def handle_topic(irc, numeric, command, args):
|
def handle_topic(irc, numeric, command, args):
|
||||||
@ -618,6 +619,7 @@ def handle_topic(irc, numeric, command, args):
|
|||||||
topic = args[1]
|
topic = args[1]
|
||||||
ts = int(time.time())
|
ts = int(time.time())
|
||||||
irc.channels[channel].topic = topic
|
irc.channels[channel].topic = topic
|
||||||
|
irc.channels[channel].topicset = True
|
||||||
return {'channel': channel, 'setter': numeric, 'ts': ts, 'topic': topic}
|
return {'channel': channel, 'setter': numeric, 'ts': ts, 'topic': topic}
|
||||||
|
|
||||||
def handle_invite(irc, numeric, command, args):
|
def handle_invite(irc, numeric, command, args):
|
||||||
|
Loading…
Reference in New Issue
Block a user