mirror of
https://github.com/thelounge/thelounge
synced 2024-11-26 14:00:21 +00:00
dd05ee3a65
Co-authored-by: Eric Nemchik <eric@nemchik.com> Co-authored-by: Pavel Djundik <xPaw@users.noreply.github.com>
40 lines
944 B
TypeScript
40 lines
944 B
TypeScript
import {IrcEventHandler} from "../../client";
|
|
import {ChanState} from "../../models/chan";
|
|
|
|
import Msg, {MessageType} from "../../models/msg";
|
|
import User from "../../models/user";
|
|
|
|
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);
|
|
}
|
|
});
|
|
};
|