2014-06-29 19:41:02 +00:00
|
|
|
var _ = require("lodash");
|
|
|
|
var User = require("../../models/user");
|
|
|
|
|
|
|
|
module.exports = function(irc, network) {
|
|
|
|
var client = this;
|
|
|
|
irc.on("names", function(data) {
|
|
|
|
var chan = _.findWhere(network.channels, {name: data.channel});
|
|
|
|
if (typeof chan === "undefined") {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
chan.users = [];
|
|
|
|
_.each(data.names, function(u) {
|
|
|
|
chan.users.push(new User(u));
|
|
|
|
});
|
|
|
|
chan.sortUsers();
|
|
|
|
client.emit("users", {
|
|
|
|
chan: chan.id,
|
|
|
|
users: chan.users
|
|
|
|
});
|
|
|
|
});
|
2014-06-26 23:05:47 +00:00
|
|
|
};
|