2016-02-12 11:24:13 +00:00
|
|
|
var _ = require("lodash");
|
|
|
|
var Msg = require("../../models/msg");
|
|
|
|
|
|
|
|
module.exports = function(irc, network) {
|
|
|
|
var client = this;
|
|
|
|
irc.on("invite", function(data) {
|
|
|
|
var target = data.to;
|
|
|
|
|
2016-02-25 11:43:32 +00:00
|
|
|
var chan = _.find(network.channels, {name: data.channel});
|
2016-02-12 11:24:13 +00:00
|
|
|
if (typeof chan === "undefined") {
|
|
|
|
chan = network.channels[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
var msg = new Msg({
|
|
|
|
type: Msg.Type.INVITE,
|
|
|
|
from: data.from,
|
|
|
|
target: target,
|
2016-02-28 08:21:19 +00:00
|
|
|
text: data.channel,
|
2016-03-07 21:09:42 +00:00
|
|
|
invitedYou: target === irc.user.nick
|
2016-02-12 11:24:13 +00:00
|
|
|
});
|
|
|
|
chan.messages.push(msg);
|
|
|
|
client.emit("msg", {
|
|
|
|
chan: chan.id,
|
|
|
|
msg: msg
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|