thelounge/src/plugins/irc-events/names.js
Reto 8fcd079204
Properly track user modes for context menu (#4267)
* properly track user modes for context menu

The RPL_ISUPPORT response contains a PREFIX element, which not only tracks the
prefix chars ("@", "+" etc) but also their corresponding mode chars (+O, +v)
This commit changes the context menu to not rely on a hardcoded list but rather
user the one given in the prefix response by the server.

Co-authored-by: Max Leiter <maxwell.leiter@gmail.com>
2021-07-21 00:30:07 -07:00

29 lines
535 B
JavaScript

"use strict";
module.exports = function (irc, network) {
const client = this;
irc.on("userlist", function (data) {
const chan = network.getChannel(data.channel);
if (typeof chan === "undefined") {
return;
}
const newUsers = new Map();
data.users.forEach((user) => {
const newUser = chan.getUser(user.nick);
newUser.setModes(user.modes, network.serverOptions.PREFIX);
newUsers.set(user.nick.toLowerCase(), newUser);
});
chan.users = newUsers;
client.emit("users", {
chan: chan.id,
});
});
};