mirror of
https://github.com/thelounge/thelounge
synced 2024-11-30 07:50:34 +00:00
Merge pull request #3870 from thelounge/xpaw/random-nick-safeguard
Safeguard nick randomizer up to allowed length
This commit is contained in:
commit
36844f948c
1 changed files with 7 additions and 1 deletions
|
@ -55,9 +55,15 @@ module.exports = function (irc, network) {
|
|||
lobby.pushMessage(client, msg, true);
|
||||
|
||||
if (irc.connection.registered === false) {
|
||||
const nickLen = parseInt(network.irc.network.options.NICKLEN, 10) || 16;
|
||||
const random = (data.nick || irc.user.nick) + Math.floor(Math.random() * 10);
|
||||
|
||||
// Safeguard nick changes up to allowed length
|
||||
// Some servers may send "nick in use" error even for randomly generated nicks
|
||||
if (random.length <= nickLen) {
|
||||
irc.changeNick(random);
|
||||
}
|
||||
}
|
||||
|
||||
client.emit("nick", {
|
||||
network: network.uuid,
|
||||
|
|
Loading…
Reference in a new issue