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