Put channel errors and unhandled numerics to relevant channel if it exists

This commit is contained in:
Pavel Djundik 2019-02-22 14:04:33 +02:00
parent 80077b33b8
commit 4d9c01deea
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,