2016-10-09 21:14:02 +02:00
|
|
|
"use strict";
|
|
|
|
|
2017-11-10 21:44:14 +01:00
|
|
|
const Msg = require("../../models/msg");
|
2016-04-24 17:12:54 +02:00
|
|
|
|
2020-03-21 21:55:36 +01:00
|
|
|
module.exports = function (irc, network) {
|
2017-11-10 21:44:14 +01:00
|
|
|
const client = this;
|
2016-04-24 17:12:54 +02:00
|
|
|
|
2020-03-21 21:55:36 +01:00
|
|
|
irc.on("unknown command", function (command) {
|
2019-02-22 13:04:33 +01:00
|
|
|
let target = network.channels[0];
|
|
|
|
|
2020-03-03 10:47:09 +01:00
|
|
|
// Do not display users own name
|
|
|
|
if (command.params.length > 0 && command.params[0] === network.irc.user.nick) {
|
|
|
|
command.params.shift();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check the length again because we may shift the nick above
|
2019-07-03 10:20:29 +02:00
|
|
|
if (command.params.length > 0) {
|
2020-03-03 10:47:09 +01:00
|
|
|
// If this numeric starts with a channel name that exists
|
|
|
|
// put this message in that channel
|
|
|
|
const channel = network.getChannel(command.params[0]);
|
2019-02-22 13:04:33 +01:00
|
|
|
|
2020-03-03 10:47:09 +01:00
|
|
|
if (typeof channel !== "undefined") {
|
|
|
|
target = channel;
|
2019-02-22 13:04:33 +01:00
|
|
|
}
|
2016-04-24 17:12:54 +02:00
|
|
|
}
|
|
|
|
|
2019-07-17 11:33:59 +02:00
|
|
|
target.pushMessage(
|
|
|
|
client,
|
|
|
|
new Msg({
|
|
|
|
type: Msg.Type.UNHANDLED,
|
|
|
|
command: command.command,
|
|
|
|
params: command.params,
|
|
|
|
}),
|
|
|
|
true
|
|
|
|
);
|
2016-04-24 17:12:54 +02:00
|
|
|
});
|
|
|
|
};
|