thelounge/server/plugins/irc-events/unhandled.ts

38 lines
909 B
TypeScript
Raw Normal View History

import {IrcEventHandler} from "../../client";
import Msg, {MessageType} from "../../models/msg";
export default <IrcEventHandler>function (irc, network) {
const client = this;
irc.on("unknown command", function (command) {
let target = network.getLobby();
// 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 08:20:29 +00:00
if (command.params.length > 0) {
// 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;
}
}
2019-07-17 09:33:59 +00:00
target.pushMessage(
client,
new Msg({
type: MessageType.UNHANDLED,
2019-07-17 09:33:59 +00:00
command: command.command,
params: command.params,
}),
true
);
});
};