thelounge/src/plugins/inputs/invite.ts

36 lines
885 B
TypeScript
Raw Normal View History

"use strict";
import Network from "src/models/network";
import {ChanType} from "src/types/models/channel";
import {MessageType} from "src/types/models/message";
import Chan from "../../models/chan";
import Msg from "../../models/msg";
const commands = ["invite", "invitelist"];
const input = function ({irc}: Network, chan: Chan, cmd: string, args: string[]) {
2019-04-14 13:44:44 +02:00
if (cmd === "invitelist") {
irc.inviteList(chan.name);
return;
}
2014-09-13 23:29:45 +02:00
if (args.length === 2) {
2016-03-08 14:36:25 +01:00
irc.raw("INVITE", args[0], args[1]); // Channel provided in the command
2022-05-02 07:56:38 +02:00
} else if (args.length === 1 && chan.type === ChanType.CHANNEL) {
2016-03-08 14:36:25 +01:00
irc.raw("INVITE", args[0], chan.name); // Current channel
} else {
2019-07-17 11:33:59 +02:00
chan.pushMessage(
this,
new Msg({
type: MessageType.ERROR,
2019-07-17 11:33:59 +02:00
text: `${cmd} command can only be used in channels or by specifying a target.`,
})
);
2014-09-13 23:29:45 +02:00
}
};
export default {
commands,
input,
};