3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-30 23:09:23 +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:
James Lu 2015-07-20 13:18:04 -07:00
parent e76d31d14e
commit b1e409ff3e
3 changed files with 19 additions and 21 deletions

View File

@ -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()}

View File

@ -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,11 +506,6 @@ 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
# Topics with content take precedence over empty topics.
# This prevents us from overwriting topics on channels with
# emptiness just because a leaf network hasn't received it yet.
if topic:
for name, remoteirc in utils.networkobjects.items(): for name, remoteirc in utils.networkobjects.items():
if irc.name == name: if irc.name == name:
continue continue

View File

@ -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):