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

28 lines
573 B
JavaScript
Raw Normal View History

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;
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,
text: data.channel,
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
});
});
};