Merge pull request #3079 from thelounge/xpaw/error-unhandled-target

Put channel errors and unhandled numerics to relevant channel if it exists
This commit is contained in:
Jérémie Astori 2019-02-26 01:34:25 -05:00 committed by GitHub
commit d0421a2541
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 3 deletions

View file

@ -21,13 +21,26 @@ module.exports = function(irc, network) {
text += data.error;
}
const lobby = network.channels[0];
const msg = new Msg({
type: Msg.Type.ERROR,
text: text,
showInActive: true,
});
lobby.pushMessage(client, msg, true);
let target = network.channels[0];
// If this error is channel specific and a channel
// with this name exists, put this error in that channel
if (data.channel) {
const channel = network.getChannel(data.channel);
if (typeof channel !== "undefined") {
target = channel;
msg.showInActive = false;
}
}
target.pushMessage(client, msg, true);
});
irc.on("nick in use", function(data) {

View file

@ -6,12 +6,22 @@ module.exports = function(irc, network) {
const client = this;
irc.on("unknown command", function(command) {
let target = network.channels[0];
// Do not display users own name
if (command.params[0] === network.irc.user.nick) {
command.params.shift();
} else {
// If this numeric starts with a channel name that exists
// put this message in that channel
const channel = network.getChannel(command.params[0]);
if (typeof channel !== "undefined") {
target = channel;
}
}
network.channels[0].pushMessage(client, new Msg({
target.pushMessage(client, new Msg({
type: Msg.Type.UNHANDLED,
command: command.command,
params: command.params,