hardlounge/src/plugins/irc-events/names.js

29 lines
525 B
JavaScript
Raw Normal View History

"use strict";
2014-09-13 21:29:45 +00:00
module.exports = function(irc, network) {
const client = this;
irc.on("userlist", function(data) {
const chan = network.getChannel(data.channel);
2014-09-13 21:29:45 +00:00
if (typeof chan === "undefined") {
return;
}
2017-11-16 20:32:03 +00:00
const newUsers = new Map();
2017-11-16 20:32:03 +00:00
data.users.forEach((user) => {
const newUser = chan.getUser(user.nick);
newUser.setModes(user.modes, network.prefixLookup);
2017-11-16 20:32:03 +00:00
newUsers.set(user.nick.toLowerCase(), newUser);
});
2017-11-16 20:32:03 +00:00
chan.users = newUsers;
2014-09-13 21:29:45 +00:00
client.emit("users", {
chan: chan.id,
2014-09-13 21:29:45 +00:00
});
});
};