From 5d560c99b8bca7fcd7b30f605653a6f10520b19c Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Thu, 7 Mar 2019 10:17:03 +0200 Subject: [PATCH 1/2] Send SETNAME command if user edits realname field --- src/models/network.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/models/network.js b/src/models/network.js index 09a06b77..fd151b6f 100644 --- a/src/models/network.js +++ b/src/models/network.js @@ -173,6 +173,7 @@ Network.prototype.createWebIrc = function(client) { Network.prototype.edit = function(client, args) { const oldNick = this.nick; + const oldRealname = this.realname; this.nick = args.nick; this.host = String(args.host || ""); @@ -198,8 +199,10 @@ Network.prototype.edit = function(client, args) { } if (this.irc) { + const connected = this.irc.connection && this.irc.connection.connected; + if (this.nick !== oldNick) { - if (this.irc.connection && this.irc.connection.connected) { + if (connected) { // Send new nick straight away this.irc.raw("NICK", this.nick); } else { @@ -213,6 +216,10 @@ Network.prototype.edit = function(client, args) { } } + if (connected && this.realname !== oldRealname) { + this.irc.raw("SETNAME", this.realname); + } + this.irc.options.host = this.host; this.irc.options.port = this.port; this.irc.options.password = this.password; From 8c10436630fcbb4917a6af00990eaa0ed9c5d8a1 Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Thu, 7 Mar 2019 12:14:34 +0200 Subject: [PATCH 2/2] Only send SETNAME if the cap is enabled --- src/models/network.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/models/network.js b/src/models/network.js index fd151b6f..38fdc131 100644 --- a/src/models/network.js +++ b/src/models/network.js @@ -134,6 +134,7 @@ Network.prototype.createIrcFramework = function(client) { }); this.irc.requestCap([ + "draft/setname", // https://github.com/ircv3/ircv3-specifications/pull/361 "znc.in/self-message", // Legacy echo-message for ZNC ]); @@ -216,7 +217,7 @@ Network.prototype.edit = function(client, args) { } } - if (connected && this.realname !== oldRealname) { + if (connected && this.realname !== oldRealname && this.irc.network.cap.isEnabled("draft/setname")) { this.irc.raw("SETNAME", this.realname); }