From 5738642d44c1f4c2dd44b1f67dca35bc8c84c96a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Astori?= Date: Mon, 26 Mar 2018 03:00:46 -0400 Subject: [PATCH] Fix/Improve some nick fallbacks - Rename a forgotten `lounge-user` - Generate nick fallbacks when already in use by appending 0-9 instead of 10-98 (?!). - Generate nick fallbacks when invalid similarly to our config default instead of random string. This is to make it less confusing when fallback gets used. --- src/client.js | 2 +- src/plugins/irc-events/error.js | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/client.js b/src/client.js index 058ff66b..2349ee5c 100644 --- a/src/client.js +++ b/src/client.js @@ -140,7 +140,7 @@ Client.prototype.find = function(channelId) { Client.prototype.connect = function(args) { const client = this; - const nick = args.nick || "lounge-user"; + const nick = args.nick || "thelounge"; let webirc = null; let channels = []; diff --git a/src/plugins/irc-events/error.js b/src/plugins/irc-events/error.js index 6b67f8ae..9908a1fa 100644 --- a/src/plugins/irc-events/error.js +++ b/src/plugins/irc-events/error.js @@ -39,7 +39,7 @@ module.exports = function(irc, network) { lobby.pushMessage(client, msg, true); if (irc.connection.registered === false) { - const random = (data.nick || irc.user.nick) + Math.floor(10 + (Math.random() * 89)); + const random = (data.nick || irc.user.nick) + Math.floor(Math.random() * 10); irc.changeNick(random); } @@ -59,8 +59,7 @@ module.exports = function(irc, network) { lobby.pushMessage(client, msg, true); if (irc.connection.registered === false) { - const random = "i" + Math.random().toString(36).substr(2, 10); // 'i' so it never begins with a number - irc.changeNick(random); + irc.changeNick("thelounge" + Math.floor(Math.random() * 100)); } client.emit("nick", {