thelounge/src/plugins/inputs/part.js

37 lines
819 B
JavaScript
Raw Normal View History

"use strict";
2014-09-13 23:29:45 +02:00
var _ = require("lodash");
2016-03-20 17:34:36 +01:00
var Msg = require("../../models/msg");
var Chan = require("../../models/chan");
2017-08-18 21:04:16 +02:00
const Helper = require("../../helper");
2014-09-13 23:29:45 +02:00
exports.commands = ["close", "leave", "part"];
exports.allowDisconnected = true;
2016-03-06 10:24:56 +01:00
exports.input = function(network, chan, cmd, args) {
if (chan.type === Chan.Type.LOBBY) {
chan.pushMessage(this, new Msg({
type: Msg.Type.ERROR,
text: "You can not part from networks, use /quit instead."
}));
2016-03-20 17:34:36 +01:00
return;
}
network.channels = _.without(network.channels, chan);
chan.destroy();
this.emit("part", {
chan: chan.id
});
2016-03-06 10:24:56 +01:00
if (chan.type === Chan.Type.CHANNEL) {
2016-05-06 10:37:16 +02:00
this.save();
if (network.irc) {
2017-08-18 21:04:16 +02:00
const partMessage = args[0] ? args.join(" ") : Helper.config.leaveMessage;
network.irc.part(chan.name, partMessage);
2016-05-06 10:37:16 +02:00
}
}
2016-03-06 10:24:56 +01:00
return true;
2014-09-13 23:29:45 +02:00
};