parent
376e7a60fb
commit
f26c2dad0f
@ -787,10 +787,13 @@
|
|||||||
|
|
||||||
<div class="help-item">
|
<div class="help-item">
|
||||||
<div class="subject">
|
<div class="subject">
|
||||||
<code>/part</code>
|
<code>/part [channel]</code>
|
||||||
</div>
|
</div>
|
||||||
<div class="description">
|
<div class="description">
|
||||||
<p>Close the current channel or private message window.</p>
|
<p>
|
||||||
|
Close the specified channel or private message window, or the
|
||||||
|
current channel if <code>channel</code> is ommitted.
|
||||||
|
</p>
|
||||||
<p>Aliases: <code>/close</code>, <code>/leave</code></p>
|
<p>Aliases: <code>/close</code>, <code>/leave</code></p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -9,7 +9,17 @@ 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) {
|
||||||
if (chan.type === Chan.Type.LOBBY) {
|
let target = args.length === 0 ? chan : _.find(network.channels, {name: args[0]});
|
||||||
|
let partMessage = args.length <= 1 ? Helper.config.leaveMessage : args.slice(1).join(" ");
|
||||||
|
|
||||||
|
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 (target.type === Chan.Type.LOBBY) {
|
||||||
chan.pushMessage(this, new Msg({
|
chan.pushMessage(this, new Msg({
|
||||||
type: Msg.Type.ERROR,
|
type: Msg.Type.ERROR,
|
||||||
text: "You can not part from networks, use /quit instead."
|
text: "You can not part from networks, use /quit instead."
|
||||||
@ -17,18 +27,17 @@ exports.input = function(network, chan, cmd, args) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
network.channels = _.without(network.channels, chan);
|
network.channels = _.without(network.channels, target);
|
||||||
chan.destroy();
|
target.destroy();
|
||||||
this.emit("part", {
|
this.emit("part", {
|
||||||
chan: chan.id
|
chan: target.id
|
||||||
});
|
});
|
||||||
|
|
||||||
if (chan.type === Chan.Type.CHANNEL) {
|
if (target.type === Chan.Type.CHANNEL) {
|
||||||
this.save();
|
this.save();
|
||||||
|
|
||||||
if (network.irc) {
|
if (network.irc) {
|
||||||
const partMessage = args[0] ? args.join(" ") : Helper.config.leaveMessage;
|
network.irc.part(target.name, partMessage);
|
||||||
network.irc.part(chan.name, partMessage);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user