From 7fdd0e90c164c0e11f81afb8b5ea9e02352f722f Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Sun, 3 Apr 2016 13:26:17 +0300 Subject: [PATCH] Generate a random hexadecimal nickname when servers says current nick is invalid --- src/plugins/irc-events/error.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/plugins/irc-events/error.js b/src/plugins/irc-events/error.js index ac01756d..e579be2c 100644 --- a/src/plugins/irc-events/error.js +++ b/src/plugins/irc-events/error.js @@ -40,4 +40,19 @@ module.exports = function(irc, network) { var random = irc.user.nick + Math.floor(10 + (Math.random() * 89)); irc.changeNick(random); }); + + irc.on("nick invalid", function(data) { + var lobby = network.channels[0]; + var msg = new Msg({ + type: Msg.Type.ERROR, + text: "Nickname " + data.nick + " is invalid: " + data.reason, + }); + client.emit("msg", { + chan: lobby.id, + msg: msg + }); + + var random = "i" + Math.random().toString(36).substr(2, 10); // 'i' so it never begins with a number + irc.changeNick(random); + }); };