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