2022-06-19 00:25:21 +00:00
|
|
|
import {IrcEventHandler} from "../../client";
|
2016-10-09 19:14:02 +00:00
|
|
|
|
2022-06-19 00:25:21 +00:00
|
|
|
import Msg, {MessageType} from "../../models/msg";
|
2016-02-12 11:24:13 +00:00
|
|
|
|
2022-06-19 00:25:21 +00:00
|
|
|
export default <IrcEventHandler>function (irc, network) {
|
2017-11-10 20:44:14 +00:00
|
|
|
const client = this;
|
|
|
|
|
2020-03-21 20:55:36 +00:00
|
|
|
irc.on("invite", function (data) {
|
2017-11-10 20:44:14 +00:00
|
|
|
let chan = network.getChannel(data.channel);
|
|
|
|
|
2016-02-12 11:24:13 +00:00
|
|
|
if (typeof chan === "undefined") {
|
|
|
|
chan = network.channels[0];
|
|
|
|
}
|
|
|
|
|
2019-02-05 10:03:54 +00:00
|
|
|
const invitedYou = data.invited === irc.user.nick;
|
|
|
|
|
2017-11-10 20:44:14 +00:00
|
|
|
const msg = new Msg({
|
2022-06-19 00:25:21 +00:00
|
|
|
type: MessageType.INVITE,
|
2016-03-25 23:26:53 +00:00
|
|
|
time: data.time,
|
2017-11-10 20:44:14 +00:00
|
|
|
from: chan.getUser(data.nick),
|
2017-11-29 06:22:03 +00:00
|
|
|
target: chan.getUser(data.invited),
|
2016-03-25 23:26:53 +00:00
|
|
|
channel: data.channel,
|
2019-02-05 10:03:54 +00:00
|
|
|
highlight: invitedYou,
|
|
|
|
invitedYou: invitedYou,
|
2016-02-12 11:24:13 +00:00
|
|
|
});
|
2016-04-19 10:20:18 +00:00
|
|
|
chan.pushMessage(client, msg);
|
2016-02-12 11:24:13 +00:00
|
|
|
});
|
|
|
|
};
|