mirror of
https://github.com/thelounge/thelounge
synced 2024-12-02 16:59:16 +00:00
41 lines
993 B
TypeScript
41 lines
993 B
TypeScript
import {IrcEventHandler} from "../../client";
|
|
|
|
import Msg from "../../models/msg";
|
|
import User from "../../models/user";
|
|
import {MessageType} from "../../../shared/types/msg";
|
|
import {ChanState} from "../../../shared/types/chan";
|
|
|
|
export default <IrcEventHandler>function (irc, network) {
|
|
const client = this;
|
|
|
|
irc.on("kick", function (data) {
|
|
const chan = network.getChannel(data.channel!);
|
|
|
|
if (typeof chan === "undefined") {
|
|
return;
|
|
}
|
|
|
|
const msg = new Msg({
|
|
type: MessageType.KICK,
|
|
time: data.time,
|
|
from: chan.getUser(data.nick),
|
|
target: chan.getUser(data.kicked!),
|
|
text: data.message || "",
|
|
highlight: data.kicked === irc.user.nick,
|
|
self: data.nick === irc.user.nick,
|
|
});
|
|
chan.pushMessage(client, msg);
|
|
|
|
if (data.kicked === irc.user.nick) {
|
|
chan.users = new Map();
|
|
chan.state = ChanState.PARTED;
|
|
|
|
client.emit("channel:state", {
|
|
chan: chan.id,
|
|
state: chan.state,
|
|
});
|
|
} else {
|
|
chan.removeUser(msg.target as User);
|
|
}
|
|
});
|
|
};
|