2014-09-13 21:29:45 +00:00
|
|
|
var Chan = require("../../models/chan");
|
|
|
|
var Msg = require("../../models/msg");
|
|
|
|
var User = require("../../models/user");
|
|
|
|
|
|
|
|
module.exports = function(irc, network) {
|
|
|
|
var client = this;
|
|
|
|
irc.on("join", 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") {
|
|
|
|
chan = new Chan({
|
|
|
|
name: data.channel
|
|
|
|
});
|
|
|
|
network.channels.push(chan);
|
2014-10-11 23:59:01 +00:00
|
|
|
client.save();
|
2014-09-13 21:29:45 +00:00
|
|
|
client.emit("join", {
|
|
|
|
network: network.id,
|
|
|
|
chan: chan
|
|
|
|
});
|
|
|
|
}
|
2016-03-07 21:09:42 +00:00
|
|
|
chan.users.push(new User({nick: data.nick, modes: ""}));
|
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
|
|
|
});
|
|
|
|
var msg = new Msg({
|
2016-03-12 09:36:55 +00:00
|
|
|
time: data.time,
|
2014-09-13 21:29:45 +00:00
|
|
|
from: data.nick,
|
2016-03-07 21:09:42 +00:00
|
|
|
hostmask: data.ident + "@" + data.hostname,
|
2014-09-14 17:06:56 +00:00
|
|
|
type: Msg.Type.JOIN,
|
2016-03-07 21:09:42 +00:00
|
|
|
self: data.nick === irc.user.nick
|
2014-09-13 21:29:45 +00:00
|
|
|
});
|
2016-04-19 10:20:18 +00:00
|
|
|
chan.pushMessage(client, msg);
|
2014-09-13 21:29:45 +00:00
|
|
|
});
|
|
|
|
};
|