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

29 lines
603 B
JavaScript
Raw Normal View History

"use strict";
const Msg = require("../../models/msg");
2016-02-12 12:24:13 +01:00
module.exports = function (irc, network) {
const client = this;
irc.on("invite", function (data) {
let chan = network.getChannel(data.channel);
2016-02-12 12:24:13 +01:00
if (typeof chan === "undefined") {
chan = network.channels[0];
}
const invitedYou = data.invited === irc.user.nick;
const msg = new Msg({
2016-02-12 12:24:13 +01:00
type: Msg.Type.INVITE,
2016-03-26 00:26:53 +01:00
time: data.time,
from: chan.getUser(data.nick),
target: chan.getUser(data.invited),
2016-03-26 00:26:53 +01:00
channel: data.channel,
highlight: invitedYou,
invitedYou: invitedYou,
2016-02-12 12:24:13 +01:00
});
chan.pushMessage(client, msg);
2016-02-12 12:24:13 +01:00
});
};