Fix up first argument not being used as part message
This commit is contained in:
parent
52002c3e22
commit
424bc4f7df
@ -9,14 +9,16 @@ exports.commands = ["close", "leave", "part"];
|
|||||||
exports.allowDisconnected = true;
|
exports.allowDisconnected = true;
|
||||||
|
|
||||||
exports.input = function(network, chan, cmd, args) {
|
exports.input = function(network, chan, cmd, args) {
|
||||||
let target = args.length === 0 ? chan : _.find(network.channels, {name: args[0]});
|
let target = chan;
|
||||||
let partMessage = args.length <= 1 ? Helper.config.leaveMessage : args.slice(1).join(" ");
|
|
||||||
|
|
||||||
if (typeof target === "undefined") {
|
if (args.length > 0) {
|
||||||
// In this case, we assume that the word args[0] is part of the leave
|
const newTarget = network.getChannel(args[0]);
|
||||||
// message and we part the current chan.
|
|
||||||
target = chan;
|
if (typeof newTarget !== "undefined") {
|
||||||
partMessage = args.join(" ");
|
// If first argument is a channel user is in, part that channel
|
||||||
|
target = newTarget;
|
||||||
|
args.shift();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (target.type === Chan.Type.LOBBY) {
|
if (target.type === Chan.Type.LOBBY) {
|
||||||
@ -46,6 +48,7 @@ exports.input = function(network, chan, cmd, args) {
|
|||||||
});
|
});
|
||||||
this.save();
|
this.save();
|
||||||
} else {
|
} else {
|
||||||
|
const partMessage = args.join(" ") || Helper.config.leaveMessage;
|
||||||
network.irc.part(target.name, partMessage);
|
network.irc.part(target.name, partMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user