hardlounge/server/plugins/irc-events/invite.ts

29 lines
662 B
TypeScript
Raw Permalink Normal View History

import {IrcEventHandler} from "../../client";
import Msg, {MessageType} from "../../models/msg";
2016-02-12 11:24:13 +00:00
export default <IrcEventHandler>function (irc, network) {
const client = this;
irc.on("invite", function (data) {
let chan = network.getChannel(data.channel);
2016-02-12 11:24:13 +00:00
if (typeof chan === "undefined") {
chan = network.getLobby();
2016-02-12 11:24:13 +00:00
}
const invitedYou = data.invited === irc.user.nick;
const msg = new Msg({
type: MessageType.INVITE,
2016-03-25 23:26:53 +00:00
time: data.time,
from: chan.getUser(data.nick),
target: chan.getUser(data.invited),
2016-03-25 23:26:53 +00:00
channel: data.channel,
highlight: invitedYou,
invitedYou: invitedYou,
2016-02-12 11:24:13 +00:00
});
chan.pushMessage(client, msg);
2016-02-12 11:24:13 +00:00
});
};