def _getNextNick(self):
        if self.alternateNicks:
            nick = self.alternateNicks.pop(0)
            if '%s' in nick:
                network_nick = conf.supybot.networks.get(self.network).nick()
                if network_nick == '':
                    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
dataset/ETHPy150Open ProgVal/Limnoria/src/irclib.py/Irc._getNextNick/original