hardlounge/lib/plugins/names.js
2014-06-23 19:28:49 +02:00

23 lines
531 B
JavaScript

var _ = require("lodash");
var Chan = require("../models/chan");
var User = require("../models/user");
module.exports = function(slate, network) {
var client = this;
slate.on("names", function(data) {
var chan = _.findWhere(network.channels, {name: data.channel});
if (typeof chan === "undefined") {
return;
}
chan.users = [];
_.each(data.names, function(n) {
chan.addUser(new User(n));
});
chan.sortUsers();
client.emit("users", {
id: chan.id,
users: chan.users,
});
});
};