mirror of
https://github.com/jlu5/PyLink.git
synced 2024-11-24 03:29:28 +01:00
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.
This commit is contained in:
parent
6e37e1c05d
commit
cd244ee89b
@ -16,6 +16,10 @@ dbname = "pylinkrelay.db"
|
|||||||
relayusers = defaultdict(dict)
|
relayusers = defaultdict(dict)
|
||||||
|
|
||||||
def normalizeNick(irc, netname, nick, separator="/"):
|
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
|
orig_nick = nick
|
||||||
protoname = irc.proto.__name__
|
protoname = irc.proto.__name__
|
||||||
maxnicklen = irc.maxnicklen
|
maxnicklen = irc.maxnicklen
|
||||||
@ -40,8 +44,10 @@ def normalizeNick(irc, netname, nick, separator="/"):
|
|||||||
|
|
||||||
nick = nick[:allowedlength]
|
nick = nick[:allowedlength]
|
||||||
nick += suffix
|
nick += suffix
|
||||||
while utils.nickToUid(irc, nick):
|
# TODO: factorize
|
||||||
# The nick we want exists? Darn, create another one then.
|
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,
|
# Increase the separator length by 1 if the user was already tagged,
|
||||||
# but couldn't be created due to a nick conflict.
|
# but couldn't be created due to a nick conflict.
|
||||||
# This can happen when someone steals a relay user's nick.
|
# This can happen when someone steals a relay user's nick.
|
||||||
|
Loading…
Reference in New Issue
Block a user