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

27 lines
532 B
JavaScript
Raw Normal View History

2016-02-12 11:24:13 +00:00
var Msg = require("../../models/msg");
module.exports = function(irc, network) {
var client = this;
irc.on("invite", function(data) {
var target = data.to;
2016-03-20 14:28:47 +00:00
var chan = network.getChannel(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
});
});
};