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-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 = [];
|
2016-03-07 21:09:42 +00:00
|
|
|
_.each(data.users, function(u) {
|
2016-03-11 16:34:50 +00:00
|
|
|
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
|
|
|
});
|
2016-03-14 11:44:06 +00:00
|
|
|
chan.sortUsers(irc);
|
2014-09-13 21:29:45 +00:00
|
|
|
client.emit("users", {
|
2016-02-17 02:29:44 +00:00
|
|
|
chan: chan.id
|
2014-09-13 21:29:45 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|