Do not generate random nicks on nick errors if already registered with the network

This commit is contained in:
Pavel Djundik 2016-04-10 11:55:58 +03:00
parent e799cc493c
commit 71a4dde7ad

View File

@ -37,8 +37,10 @@ module.exports = function(irc, network) {
msg: msg msg: msg
}); });
var random = (data.nick || irc.user.nick) + Math.floor(10 + (Math.random() * 89)); if (irc.connection.registered === false) {
irc.changeNick(random); var random = (data.nick || irc.user.nick) + Math.floor(10 + (Math.random() * 89));
irc.changeNick(random);
}
}); });
irc.on("nick invalid", function(data) { irc.on("nick invalid", function(data) {
@ -52,7 +54,9 @@ module.exports = function(irc, network) {
msg: msg msg: msg
}); });
var random = "i" + Math.random().toString(36).substr(2, 10); // 'i' so it never begins with a number if (irc.connection.registered === false) {
irc.changeNick(random); var random = "i" + Math.random().toString(36).substr(2, 10); // 'i' so it never begins with a number
irc.changeNick(random);
}
}); });
}; };