hardlounge/src/plugins/inputs/part.js

32 lines
672 B
JavaScript
Raw Normal View History

2014-09-13 17:29:45 -04:00
var _ = require("lodash");
2016-03-20 12:34:36 -04:00
var Msg = require("../../models/msg");
var Chan = require("../../models/chan");
2014-09-13 17:29:45 -04:00
exports.commands = ["close", "leave", "part"];
exports.allowDisconnected = true;
2016-03-06 04:24:56 -05: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 12:34:36 -04:00
return;
}
network.channels = _.without(network.channels, chan);
this.emit("part", {
chan: chan.id
});
2016-03-06 04:24:56 -05:00
if (chan.type === Chan.Type.CHANNEL) {
2016-05-06 04:37:16 -04:00
this.save();
if (network.irc) {
network.irc.part(chan.name, args.join(" "));
}
}
2016-03-06 04:24:56 -05:00
return true;
2014-09-13 17:29:45 -04:00
};