irclib: Don't return the same nick twice when duplicates in supybot.nick.alternates + supybot.nick.

It migt crash on: 'assert newNick != self.nick'
This commit is contained in:
Valentin Lorentz 2019-01-27 09:10:06 +01:00
parent d20e418fd0
commit 624553c069

View File

@ -978,6 +978,7 @@ class Irc(IrcCommandDispatcher, log.Firewalled):
self.user = ircutils.standardSubstitute(self, None, get_value('user'))
self.ident = get_value('ident')
self.alternateNicks = conf.supybot.nick.alternates()[:]
self.triedNicks = ircutils.IrcSet()
self.password = network_config.password()
self.prefix = '%s!%s@%s' % (self.nick, self.ident, 'unset.domain')
# The rest.
@ -1370,20 +1371,23 @@ class Irc(IrcCommandDispatcher, log.Firewalled):
nick %= conf.supybot.nick()
else:
nick %= network_nick
return nick
else:
nick = conf.supybot.nick()
network_nick = conf.supybot.networks.get(self.network).nick()
if network_nick != '':
nick = network_nick
ret = nick
L = list(nick)
while len(L) <= 3:
L.append('`')
while ircutils.strEqual(ret, nick):
L[random.randrange(len(L))] = utils.iter.choice('0123456789')
ret = ''.join(L)
return ret
if nick not in self.triedNicks:
self.triedNicks.add(nick)
return nick
nick = conf.supybot.nick()
network_nick = conf.supybot.networks.get(self.network).nick()
if network_nick != '':
nick = network_nick
ret = nick
L = list(nick)
while len(L) <= 3:
L.append('`')
while ret in self.triedNicks:
L[random.randrange(len(L))] = utils.iter.choice('0123456789')
ret = ''.join(L)
self.triedNicks.add(ret)
return ret
def do002(self, msg):
"""Logs the ircd version."""