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

28 lines
607 B
JavaScript
Raw Normal View History

2014-09-13 23:29:45 +02:00
var _ = require("lodash");
var User = require("../../models/user");
module.exports = function(irc, network) {
var client = this;
irc.on("userlist", function(data) {
2016-03-20 15:28:47 +01:00
var chan = network.getChannel(data.channel);
2014-09-13 23:29:45 +02:00
if (typeof chan === "undefined") {
return;
}
chan.users = [];
_.each(data.users, function(u) {
var user = new User(u);
// irc-framework sets characater mode, but lounge works with symbols
if (user.mode) {
user.mode = network.prefixLookup[user.mode];
}
chan.users.push(user);
2014-09-13 23:29:45 +02:00
});
chan.sortUsers(irc);
2014-09-13 23:29:45 +02:00
client.emit("users", {
chan: chan.id
2014-09-13 23:29:45 +02:00
});
});
};