2022-06-19 00:25:21 +00:00
|
|
|
import {IrcEventHandler} from "../../client";
|
|
|
|
import {ChanState} from "../../models/chan";
|
2016-10-09 19:14:02 +00:00
|
|
|
|
2022-06-19 00:25:21 +00:00
|
|
|
import Msg, {MessageType} from "../../models/msg";
|
|
|
|
import User from "../../models/user";
|
2014-09-13 21:29:45 +00:00
|
|
|
|
2022-06-19 00:25:21 +00:00
|
|
|
export default <IrcEventHandler>function (irc, network) {
|
2017-11-10 20:44:14 +00:00
|
|
|
const client = this;
|
|
|
|
|
2020-03-21 20:55:36 +00:00
|
|
|
irc.on("kick", function (data) {
|
2022-06-19 00:25:21 +00:00
|
|
|
const chan = network.getChannel(data.channel!);
|
2017-11-10 20:44:14 +00:00
|
|
|
|
2014-09-13 21:29:45 +00:00
|
|
|
if (typeof chan === "undefined") {
|
|
|
|
return;
|
|
|
|
}
|
2014-10-04 12:31:45 +00:00
|
|
|
|
2017-11-10 20:44:14 +00:00
|
|
|
const msg = new Msg({
|
2022-06-19 00:25:21 +00:00
|
|
|
type: MessageType.KICK,
|
2017-11-10 20:44:14 +00:00
|
|
|
time: data.time,
|
|
|
|
from: chan.getUser(data.nick),
|
2022-06-19 00:25:21 +00:00
|
|
|
target: chan.getUser(data.kicked!),
|
2017-11-10 20:44:14 +00:00
|
|
|
text: data.message || "",
|
|
|
|
highlight: data.kicked === irc.user.nick,
|
|
|
|
self: data.nick === irc.user.nick,
|
|
|
|
});
|
|
|
|
chan.pushMessage(client, msg);
|
2017-07-11 14:30:47 +00:00
|
|
|
|
2016-03-08 10:16:20 +00:00
|
|
|
if (data.kicked === irc.user.nick) {
|
2017-11-16 20:32:03 +00:00
|
|
|
chan.users = new Map();
|
2022-06-19 00:25:21 +00:00
|
|
|
chan.state = ChanState.PARTED;
|
2018-07-19 18:03:53 +00:00
|
|
|
|
|
|
|
client.emit("channel:state", {
|
|
|
|
chan: chan.id,
|
|
|
|
state: chan.state,
|
|
|
|
});
|
2014-09-13 21:29:45 +00:00
|
|
|
} else {
|
2022-06-19 00:25:21 +00:00
|
|
|
chan.removeUser(msg.target as User);
|
2014-09-13 21:29:45 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|