mirror of
https://github.com/thelounge/thelounge.git
synced 2024-06-02 13:52:17 +02:00
35 lines
712 B
TypeScript
35 lines
712 B
TypeScript
"use strict";
|
|
|
|
import Network from "../../models/network";
|
|
|
|
import Msg from "../../models/msg";
|
|
|
|
export default <IrcEventHandler>function (irc, network) {
|
|
const client = this;
|
|
|
|
irc.on("part", function (data) {
|
|
const chan = network.getChannel(data.channel);
|
|
|
|
if (typeof chan === "undefined") {
|
|
return;
|
|
}
|
|
|
|
const user = chan.getUser(data.nick);
|
|
const msg = new Msg({
|
|
type: MessageType.PART,
|
|
time: data.time,
|
|
text: data.message || "",
|
|
hostmask: data.ident + "@" + data.hostname,
|
|
from: user,
|
|
self: data.nick === irc.user.nick,
|
|
});
|
|
chan.pushMessage(client, msg);
|
|
|
|
if (data.nick === irc.user.nick) {
|
|
client.part(network, chan);
|
|
} else {
|
|
chan.removeUser(user);
|
|
}
|
|
});
|
|
};
|