From 8ca9ee873b422fd5718711aef78d79b27a3cb93b Mon Sep 17 00:00:00 2001 From: Reto Brunner Date: Sat, 4 Mar 2023 18:16:28 +0100 Subject: [PATCH 1/2] use the irc connected helper function We should not mess with irc-framework internals. Technically we shouldn't even access the connection object, it's not part of the documented API surface --- server/models/network.ts | 6 ++---- server/plugins/inputs/connect.ts | 2 +- server/plugins/inputs/nick.ts | 2 +- server/plugins/inputs/part.ts | 4 +--- 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/server/models/network.ts b/server/models/network.ts index 188fa9fe..3d1d04a5 100644 --- a/server/models/network.ts +++ b/server/models/network.ts @@ -416,10 +416,8 @@ class Network { } if (this.irc) { - const connected = this.irc.connection && this.irc.connection.connected; - if (this.nick !== oldNick) { - if (connected) { + if (this.irc.connected) { // Send new nick straight away this.irc.changeNick(this.nick); } else { @@ -434,7 +432,7 @@ class Network { } if ( - connected && + this.irc.connected && this.realname !== oldRealname && this.irc.network.cap.isEnabled("setname") ) { diff --git a/server/plugins/inputs/connect.ts b/server/plugins/inputs/connect.ts index 8ba60c20..394c08e2 100644 --- a/server/plugins/inputs/connect.ts +++ b/server/plugins/inputs/connect.ts @@ -15,7 +15,7 @@ const input: PluginInputHandler = function (network, chan, cmd, args) { return; } - if (irc.connection && irc.connection.connected) { + if (irc.connected) { chan.pushMessage( this, new Msg({ diff --git a/server/plugins/inputs/nick.ts b/server/plugins/inputs/nick.ts index abccf723..645096ab 100644 --- a/server/plugins/inputs/nick.ts +++ b/server/plugins/inputs/nick.ts @@ -47,7 +47,7 @@ const input: PluginInputHandler = function (network, chan, cmd, args) { // If connected to IRC, send to server and wait for ACK // otherwise update the nick and UI straight away if (network.irc) { - if (network.irc.connection && network.irc.connection.connected) { + if (network.irc.connected) { network.irc.changeNick(newNick); return; diff --git a/server/plugins/inputs/part.ts b/server/plugins/inputs/part.ts index bf352ce6..76569889 100644 --- a/server/plugins/inputs/part.ts +++ b/server/plugins/inputs/part.ts @@ -36,9 +36,7 @@ const input: PluginInputHandler = function (network, chan, cmd, args) { if ( target.type !== ChanType.CHANNEL || target.state === ChanState.PARTED || - !network.irc || - !network.irc.connection || - !network.irc.connection.connected + !network.irc.connected ) { this.part(network, target); } else { From 7f6059d5b7e65960812e749733358ee2f760b032 Mon Sep 17 00:00:00 2001 From: Reto Brunner Date: Sat, 4 Mar 2023 18:17:17 +0100 Subject: [PATCH 2/2] input/raw: use the irc-framework api We are not allowed to mess with the connection object directly according to the public api surface of the framework --- server/plugins/inputs/raw.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/plugins/inputs/raw.ts b/server/plugins/inputs/raw.ts index b682255c..4d89bd67 100644 --- a/server/plugins/inputs/raw.ts +++ b/server/plugins/inputs/raw.ts @@ -4,7 +4,7 @@ const commands = ["raw", "send", "quote"]; const input: PluginInputHandler = function ({irc}, chan, cmd, args) { if (args.length !== 0) { - irc.connection.write(args.join(" ")); + irc.raw(...args); } return true;