thelounge/lib/plugins/names.js

23 lines
531 B
JavaScript
Raw Normal View History

2014-06-19 15:28:53 +00:00
var _ = require("lodash");
var Chan = require("../models/chan");
var User = require("../models/user");
2014-06-23 17:28:36 +00:00
module.exports = function(slate, network) {
var client = this;
slate.on("names", function(data) {
2014-06-19 15:28:53 +00:00
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();
2014-06-23 17:28:36 +00:00
client.emit("users", {
2014-06-19 15:28:53 +00:00
id: chan.id,
users: chan.users,
});
});
};