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

28 lines
607 B
JavaScript
Raw Normal View History

2014-09-13 21:29:45 +00: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 14:28:47 +00:00
var chan = network.getChannel(data.channel);
2014-09-13 21:29:45 +00: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 21:29:45 +00:00
});
chan.sortUsers(irc);
2014-09-13 21:29:45 +00:00
client.emit("users", {
chan: chan.id
2014-09-13 21:29:45 +00:00
});
});
};