hardlounge/server/plugins/irc-events/names.ts

29 lines
582 B
TypeScript
Raw Normal View History

import {IrcEventHandler} from "../../client";
export default <IrcEventHandler>function (irc, network) {
const client = this;
irc.on("userlist", function (data) {
const chan = network.getChannel(data.channel);
2014-09-13 17:29:45 -04:00
if (typeof chan === "undefined") {
return;
}
2017-11-16 15:32:03 -05:00
const newUsers = new Map();
2017-11-16 15:32:03 -05:00
data.users.forEach((user) => {
const newUser = chan.getUser(user.nick);
newUser.setModes(user.modes, network.serverOptions.PREFIX);
2017-11-16 15:32:03 -05:00
newUsers.set(user.nick.toLowerCase(), newUser);
});
2017-11-16 15:32:03 -05:00
chan.users = newUsers;
2014-09-13 17:29:45 -04:00
client.emit("users", {
chan: chan.id,
2014-09-13 17:29:45 -04:00
});
});
};