2014-09-13 21:29:45 +00:00
|
|
|
var _ = require("lodash");
|
|
|
|
var User = require("../../models/user");
|
|
|
|
|
|
|
|
module.exports = function(irc, network) {
|
|
|
|
var client = this;
|
2016-03-07 21:09:42 +00:00
|
|
|
irc.on("userlist", function(data) {
|
2016-02-14 17:09:51 +00:00
|
|
|
var chan = _.find(network.channels, {name: data.channel});
|
2014-09-13 21:29:45 +00:00
|
|
|
if (typeof chan === "undefined") {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
chan.users = [];
|
2016-03-07 21:09:42 +00:00
|
|
|
_.each(data.users, function(u) {
|
2014-09-13 21:29:45 +00:00
|
|
|
chan.users.push(new User(u));
|
|
|
|
});
|
|
|
|
chan.sortUsers();
|
|
|
|
client.emit("users", {
|
2016-02-17 02:29:44 +00:00
|
|
|
chan: chan.id
|
2014-09-13 21:29:45 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|