thelounge/server/plugins/irc-events/invite.ts
Max Leiter dd05ee3a65
TypeScript and Vue 3 (#4559)
Co-authored-by: Eric Nemchik <eric@nemchik.com>
Co-authored-by: Pavel Djundik <xPaw@users.noreply.github.com>
2022-06-18 17:25:21 -07:00

28 lines
663 B
TypeScript

import {IrcEventHandler} from "../../client";
import Msg, {MessageType} from "../../models/msg";
export default <IrcEventHandler>function (irc, network) {
const client = this;
irc.on("invite", function (data) {
let chan = network.getChannel(data.channel);
if (typeof chan === "undefined") {
chan = network.channels[0];
}
const invitedYou = data.invited === irc.user.nick;
const msg = new Msg({
type: MessageType.INVITE,
time: data.time,
from: chan.getUser(data.nick),
target: chan.getUser(data.invited),
channel: data.channel,
highlight: invitedYou,
invitedYou: invitedYou,
});
chan.pushMessage(client, msg);
});
};