mirror of
https://git.sr.ht/~emersion/gamja
synced 2024-11-14 19:25:26 -05:00
state: handle WHO replies in bulk
This commit is contained in:
parent
2d651ef901
commit
2f627eecad
1 changed files with 22 additions and 17 deletions
25
state.js
25
state.js
|
@ -453,9 +453,18 @@ export const State = {
|
|||
return { members };
|
||||
});
|
||||
break;
|
||||
case irc.RPL_WHOREPLY:
|
||||
case irc.RPL_WHOSPCRPL:
|
||||
who = client.parseWhoReply(msg);
|
||||
case irc.RPL_ENDOFWHO:
|
||||
target = msg.params[1];
|
||||
if (msg.list.length == 0 && !client.isChannel(target) && target.indexOf("*") < 0) {
|
||||
// Not a channel nor a mask, likely a nick
|
||||
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
|
||||
|
@ -469,13 +478,9 @@ export const State = {
|
|||
|
||||
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) {
|
||||
// Not a channel nor a mask, likely a nick
|
||||
return updateUser(target, (user) => {
|
||||
return { offline: true };
|
||||
users.set(who.nick, who);
|
||||
}
|
||||
return { users };
|
||||
});
|
||||
}
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue