From cd244ee89b78fe32f9f77baba7ac195af9496e5f Mon Sep 17 00:00:00 2001 From: James Lu Date: Wed, 15 Jul 2015 13:53:14 -0700 Subject: [PATCH] relay: block until irc.maxnicklen is set, and remove check for "nick already in use" for internal clients Closes #48. This fixes the edge case where, if a person with a long, cut-off nick changes to another long nick, and the resulting normalized nick is the same, normalizeNick will start incrementing the separator anyway. The correct behavior is to NOT send any nick changes if the old (normalized) nick and the new nick match. --- plugins/relay.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/plugins/relay.py b/plugins/relay.py index 05ac2f9..c4f3ad5 100644 --- a/plugins/relay.py +++ b/plugins/relay.py @@ -16,6 +16,10 @@ dbname = "pylinkrelay.db" relayusers = defaultdict(dict) def normalizeNick(irc, netname, nick, separator="/"): + # Block until we know the IRC network's nick length (after capabilities + # are sent) + irc.connected.wait() + orig_nick = nick protoname = irc.proto.__name__ maxnicklen = irc.maxnicklen @@ -40,8 +44,10 @@ def normalizeNick(irc, netname, nick, separator="/"): nick = nick[:allowedlength] nick += suffix - while utils.nickToUid(irc, nick): - # The nick we want exists? Darn, create another one then. + # TODO: factorize + while utils.nickToUid(irc, nick) and not utils.isInternalClient(irc, utils.nickToUid(irc, nick)): + # The nick we want exists? Darn, create another one then, but only if + # the target isn't an internal client! # Increase the separator length by 1 if the user was already tagged, # but couldn't be created due to a nick conflict. # This can happen when someone steals a relay user's nick.