From 55361c5a2b1db232b22922fb9a4094dbe5b0b768 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Wed, 10 Nov 2021 10:32:23 +0100 Subject: [PATCH] Store WHO list in RPL_ENDOFWHO This allows the state-tracker to figure out whether a WHO query returned no result. --- lib/client.js | 7 +++++++ state.js | 7 +------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/client.js b/lib/client.js index 416b513..89d9ed4 100644 --- a/lib/client.js +++ b/lib/client.js @@ -303,6 +303,13 @@ export default class Client extends EventTarget { case irc.RPL_ENDOFWHOIS: this.endPendingList("WHOIS " + msg.params[1], msg); break; + case irc.RPL_WHOREPLY: + case irc.RPL_WHOSPCRPL: + this.pushPendingList("WHO", msg); + break; + case irc.RPL_ENDOFWHO: + this.endPendingList("WHO", msg); + break; case irc.ERR_NICKLOCKED: case irc.ERR_SASLFAIL: case irc.ERR_SASLTOOLONG: diff --git a/state.js b/state.js index 008bd8f..04e4eea 100644 --- a/state.js +++ b/state.js @@ -384,14 +384,9 @@ export const State = { return updateUser(who.nick, who); case irc.RPL_ENDOFWHO: target = msg.params[1]; - if (!client.isChannel(target) && target.indexOf("*") < 0) { + if (msg.list.length == 0 && !client.isChannel(target) && target.indexOf("*") < 0) { // Not a channel nor a mask, likely a nick return updateUser(target, (user) => { - // TODO: mark user offline if we have old WHO info but this - // WHO reply is empty - if (user) { - return; - } return { offline: true }; }); }