From 424bc4f7df849393acfbc60673ff8f14cf2cdd57 Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Sun, 15 Mar 2020 20:16:53 +0200 Subject: [PATCH] Fix up first argument not being used as part message --- src/plugins/inputs/part.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/plugins/inputs/part.js b/src/plugins/inputs/part.js index 319feab1..547fbcb2 100644 --- a/src/plugins/inputs/part.js +++ b/src/plugins/inputs/part.js @@ -9,14 +9,16 @@ exports.commands = ["close", "leave", "part"]; exports.allowDisconnected = true; exports.input = function(network, chan, cmd, args) { - let target = args.length === 0 ? chan : _.find(network.channels, {name: args[0]}); - let partMessage = args.length <= 1 ? Helper.config.leaveMessage : args.slice(1).join(" "); + let target = chan; - if (typeof target === "undefined") { - // In this case, we assume that the word args[0] is part of the leave - // message and we part the current chan. - target = chan; - partMessage = args.join(" "); + if (args.length > 0) { + const newTarget = network.getChannel(args[0]); + + if (typeof newTarget !== "undefined") { + // If first argument is a channel user is in, part that channel + target = newTarget; + args.shift(); + } } if (target.type === Chan.Type.LOBBY) { @@ -46,6 +48,7 @@ exports.input = function(network, chan, cmd, args) { }); this.save(); } else { + const partMessage = args.join(" ") || Helper.config.leaveMessage; network.irc.part(target.name, partMessage); }