aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2023-04-19 13:04:58 +0200
committerSimon Ser <contact@emersion.fr>2023-04-19 13:04:58 +0200
commit2f627eecad6836ee49821535fb16267ca33b046e (patch)
tree09450f284f853c88375ca4a1abc8940405964171
parent2d651ef901b2c19679651d201d4da4ce157c5ebb (diff)
downloadgamja-2f627eecad6836ee49821535fb16267ca33b046e.tar.gz
gamja-2f627eecad6836ee49821535fb16267ca33b046e.zip
state: handle WHO replies in bulk
-rw-r--r--state.js39
1 files changed, 22 insertions, 17 deletions
diff --git a/state.js b/state.js
index 438f6aa..1c1bc5a 100644
--- a/state.js
+++ b/state.js
@@ -453,23 +453,6 @@ export const State = {
return { members };
});
break;
- case irc.RPL_WHOREPLY:
- case irc.RPL_WHOSPCRPL:
- who = client.parseWhoReply(msg);
-
- if (who.flags !== undefined) {
- who.away = who.flags.indexOf("G") >= 0; // H for here, G for gone
- who.operator = who.flags.indexOf("*") >= 0;
- let botFlag = client.isupport.bot();
- if (botFlag) {
- who.bot = who.flags.indexOf(botFlag) >= 0;
- }
- delete who.flags;
- }
-
- who.offline = false;
-
- return updateUser(who.nick, who);
case irc.RPL_ENDOFWHO:
target = msg.params[1];
if (msg.list.length == 0 && !client.isChannel(target) && target.indexOf("*") < 0) {
@@ -477,6 +460,28 @@ export const State = {
return updateUser(target, (user) => {
return { offline: true };
});
+ } else {
+ return updateServer((server) => {
+ let users = new irc.CaseMapMap(server.users);
+ for (let reply of msg.list) {
+ let who = client.parseWhoReply(reply);
+
+ if (who.flags !== undefined) {
+ who.away = who.flags.indexOf("G") >= 0; // H for here, G for gone
+ who.operator = who.flags.indexOf("*") >= 0;
+ let botFlag = client.isupport.bot();
+ if (botFlag) {
+ who.bot = who.flags.indexOf(botFlag) >= 0;
+ }
+ delete who.flags;
+ }
+
+ who.offline = false;
+
+ users.set(who.nick, who);
+ }
+ return { users };
+ });
}
break;
case "JOIN":