mirror of
https://github.com/thelounge/thelounge.git
synced 2024-06-07 08:12:19 +02:00
[ts-migrate][src] Init tsconfig.json file
Co-authored-by: ts-migrate <>
This commit is contained in:
parent
facde53b09
commit
70fae2ee3f
|
@ -46,7 +46,7 @@ class Chan {
|
|||
this.dereferencePreviews(this.messages);
|
||||
}
|
||||
|
||||
pushMessage(client: Client, msg: Msg, increasesUnread: boolean) {
|
||||
pushMessage(client: Client, msg: Msg, increasesUnread = false) {
|
||||
const chan = this.id;
|
||||
const obj = {chan, msg} as any;
|
||||
|
||||
|
@ -164,7 +164,7 @@ class Chan {
|
|||
* If true, channel is assumed active.
|
||||
* @param {int} lastMessage - Last message id seen by active client to avoid sending duplicates.
|
||||
*/
|
||||
getFilteredClone(lastActiveChannel: number | boolean, lastMessage: number): FilteredChannel {
|
||||
getFilteredClone(lastActiveChannel: number | boolean, lastMessage?: number): FilteredChannel {
|
||||
return Object.keys(this).reduce((newChannel, prop) => {
|
||||
if (prop === "users") {
|
||||
// Do not send users, client requests updated user list whenever needed
|
||||
|
|
|
@ -21,6 +21,7 @@ class Msg {
|
|||
showInActive: boolean;
|
||||
new_ident: string;
|
||||
new_host: string;
|
||||
ctcpMessage: string;
|
||||
|
||||
constructor(attr: Partial<Msg>) {
|
||||
// Some properties need to be copied in the Msg object instead of referenced
|
||||
|
|
|
@ -12,7 +12,7 @@ import STSPolicies from "../plugins/sts";
|
|||
import ClientCertificate from "../plugins/clientCertificate";
|
||||
import {Channel, ChanType} from "src/types/models/channel";
|
||||
import Client from "src/client";
|
||||
import {NetworkStatus} from "src/types/models/network";
|
||||
import {IgnoreList, NetworkStatus} from "src/types/models/network";
|
||||
import {MessageType} from "src/types/models/message";
|
||||
import {WebIRC} from "src/types/config";
|
||||
|
||||
|
@ -81,7 +81,7 @@ class Network {
|
|||
};
|
||||
|
||||
chanCache: Chan[];
|
||||
ignoreList: string[];
|
||||
ignoreList: IgnoreList;
|
||||
keepNick?: string;
|
||||
|
||||
status: NetworkStatus;
|
||||
|
|
|
@ -1,16 +1,17 @@
|
|||
"use strict";
|
||||
|
||||
const Chan = require("../../models/chan");
|
||||
const Msg = require("../../models/msg");
|
||||
import Network from "src/models/network";
|
||||
import {MessageType} from "src/types/models/message";
|
||||
import Chan from "../../models/chan";
|
||||
import Msg from "../../models/msg";
|
||||
|
||||
exports.commands = ["slap", "me"];
|
||||
|
||||
exports.input = function ({irc}, chan, cmd, args) {
|
||||
const commands = ["slap", "me"];
|
||||
const input = function ({irc}: Network, chan: Chan, cmd: string, args: string[]) {
|
||||
if (chan.type !== ChanType.CHANNEL && chan.type !== ChanType.QUERY) {
|
||||
chan.pushMessage(
|
||||
this,
|
||||
new Msg({
|
||||
type: Msg.Type.ERROR,
|
||||
type: MessageType.ERROR,
|
||||
text: `${cmd} command can only be used in channels and queries.`,
|
||||
})
|
||||
);
|
||||
|
@ -46,3 +47,8 @@ exports.input = function ({irc}, chan, cmd, args) {
|
|||
|
||||
return true;
|
||||
};
|
||||
|
||||
export default {
|
||||
commands,
|
||||
input,
|
||||
};
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
"use strict";
|
||||
|
||||
exports.commands = ["away", "back"];
|
||||
import Network from "src/models/network";
|
||||
import {Channel} from "src/types/models/channel";
|
||||
|
||||
exports.input = function (network, chan, cmd, args) {
|
||||
const commands = ["away", "back"];
|
||||
|
||||
const input = function (network: Network, chan: Channel, cmd: string, args: string[]) {
|
||||
let reason = "";
|
||||
|
||||
if (cmd === "away") {
|
||||
|
@ -18,3 +21,8 @@ exports.input = function (network, chan, cmd, args) {
|
|||
|
||||
this.save();
|
||||
};
|
||||
|
||||
export default {
|
||||
commands,
|
||||
input,
|
||||
};
|
||||
|
|
|
@ -1,16 +1,18 @@
|
|||
"use strict";
|
||||
|
||||
const Chan = require("../../models/chan");
|
||||
const Msg = require("../../models/msg");
|
||||
import Network from "src/models/network";
|
||||
import Chan from "src/models/chan";
|
||||
import Msg from "src/models/msg";
|
||||
import {MessageType} from "src/types/models/message";
|
||||
|
||||
exports.commands = ["ban", "unban", "banlist", "kickban"];
|
||||
const commands = ["ban", "unban", "banlist", "kickban"];
|
||||
|
||||
exports.input = function ({irc}, chan, cmd, args) {
|
||||
const input = function ({irc}: Network, chan: Chan, cmd: string, args: string[]) {
|
||||
if (chan.type !== ChanType.CHANNEL) {
|
||||
chan.pushMessage(
|
||||
this,
|
||||
new Msg({
|
||||
type: Msg.Type.ERROR,
|
||||
type: MessageType.ERROR,
|
||||
text: `${cmd} command can only be used in channels.`,
|
||||
})
|
||||
);
|
||||
|
@ -23,7 +25,7 @@ exports.input = function ({irc}, chan, cmd, args) {
|
|||
chan.pushMessage(
|
||||
this,
|
||||
new Msg({
|
||||
type: Msg.Type.ERROR,
|
||||
type: MessageType.ERROR,
|
||||
text: `Usage: /${cmd} <nick>`,
|
||||
})
|
||||
);
|
||||
|
@ -47,3 +49,8 @@ exports.input = function ({irc}, chan, cmd, args) {
|
|||
break;
|
||||
}
|
||||
};
|
||||
|
||||
export default {
|
||||
commands,
|
||||
input,
|
||||
};
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
"use strict";
|
||||
|
||||
const Msg = require("../../models/msg");
|
||||
import Network from "src/models/network";
|
||||
import {Channel} from "src/types/models/channel";
|
||||
import {MessageType} from "src/types/models/message";
|
||||
import Msg from "../../models/msg";
|
||||
|
||||
exports.commands = ["connect", "server"];
|
||||
exports.allowDisconnected = true;
|
||||
const commands = ["connect", "server"];
|
||||
const allowDisconnected = true;
|
||||
|
||||
exports.input = function (network, chan, cmd, args) {
|
||||
const input = function (network: Network, chan: Channel, cmd: string, args: string[]) {
|
||||
if (args.length === 0) {
|
||||
network.userDisconnected = false;
|
||||
this.save();
|
||||
|
@ -20,7 +23,7 @@ exports.input = function (network, chan, cmd, args) {
|
|||
chan.pushMessage(
|
||||
this,
|
||||
new Msg({
|
||||
type: Msg.Type.ERROR,
|
||||
type: MessageType.ERROR,
|
||||
text: "You are already connected.",
|
||||
})
|
||||
);
|
||||
|
@ -44,3 +47,8 @@ exports.input = function (network, chan, cmd, args) {
|
|||
|
||||
return true;
|
||||
};
|
||||
|
||||
export default {
|
||||
commands,
|
||||
input,
|
||||
};
|
||||
|
|
|
@ -1,15 +1,18 @@
|
|||
"use strict";
|
||||
|
||||
const Msg = require("../../models/msg");
|
||||
import Chan from "src/models/chan";
|
||||
import Network from "src/models/network";
|
||||
import {MessageType} from "src/types/models/message";
|
||||
import Msg from "../../models/msg";
|
||||
|
||||
exports.commands = ["ctcp"];
|
||||
const commands = ["ctcp"];
|
||||
|
||||
exports.input = function ({irc}, chan, cmd, args) {
|
||||
const input = function ({irc}: Network, chan: Chan, cmd: string, args: string[]) {
|
||||
if (args.length < 2) {
|
||||
chan.pushMessage(
|
||||
this,
|
||||
new Msg({
|
||||
type: Msg.Type.ERROR,
|
||||
type: MessageType.ERROR,
|
||||
text: "Usage: /ctcp <nick> <ctcp_type>",
|
||||
})
|
||||
);
|
||||
|
@ -19,11 +22,17 @@ exports.input = function ({irc}, chan, cmd, args) {
|
|||
chan.pushMessage(
|
||||
this,
|
||||
new Msg({
|
||||
type: Msg.Type.CTCP_REQUEST,
|
||||
type: MessageType.CTCP_REQUEST,
|
||||
ctcpMessage: `"${args.slice(1).join(" ")}" to ${args[0]}`,
|
||||
from: chan.getUser(irc.user.nick),
|
||||
})
|
||||
);
|
||||
|
||||
irc.ctcpRequest(...args);
|
||||
// TODO: check. Was ctcpRequest(...args)
|
||||
irc.ctcpRequest(args.shift(), args.shift(), ...args);
|
||||
};
|
||||
|
||||
export default {
|
||||
commands,
|
||||
input,
|
||||
};
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
"use strict";
|
||||
|
||||
exports.commands = ["disconnect"];
|
||||
exports.allowDisconnected = true;
|
||||
import Chan from "src/models/chan";
|
||||
import Network from "src/models/network";
|
||||
|
||||
exports.input = function (network, chan, cmd, args) {
|
||||
const commands = ["disconnect"];
|
||||
const allowDisconnected = true;
|
||||
|
||||
const input = function (network: Network, chan: Chan, cmd: string, args: string[]) {
|
||||
const quitMessage = args[0] ? args.join(" ") : null;
|
||||
|
||||
network.quit(quitMessage);
|
||||
|
@ -11,3 +14,9 @@ exports.input = function (network, chan, cmd, args) {
|
|||
|
||||
this.save();
|
||||
};
|
||||
|
||||
export default {
|
||||
commands,
|
||||
input,
|
||||
allowDisconnected,
|
||||
};
|
||||
|
|
|
@ -1,21 +1,26 @@
|
|||
"use strict";
|
||||
|
||||
const Chan = require("../../models/chan");
|
||||
const Msg = require("../../models/msg");
|
||||
const Helper = require("../../helper");
|
||||
import Network from "src/models/network";
|
||||
import {MessageType} from "src/types/models/message";
|
||||
|
||||
exports.commands = ["ignore", "unignore", "ignorelist"];
|
||||
import Chan from "src/models/chan";
|
||||
import Msg from "src/models/msg";
|
||||
import Helper from "src/helper";
|
||||
import {IgnoreListItem} from "src/types/models/network";
|
||||
import {SpecialChanType} from "src/types/models/channel";
|
||||
|
||||
exports.input = function (network, chan, cmd, args) {
|
||||
const commands = ["ignore", "unignore", "ignorelist"];
|
||||
|
||||
const input = function (network: Network, chan: Chan, cmd: string, args: string[]) {
|
||||
const client = this;
|
||||
let target;
|
||||
let hostmask;
|
||||
let target: string;
|
||||
let hostmask: IgnoreListItem;
|
||||
|
||||
if (cmd !== "ignorelist" && (args.length === 0 || args[0].trim().length === 0)) {
|
||||
chan.pushMessage(
|
||||
client,
|
||||
new Msg({
|
||||
type: Msg.Type.ERROR,
|
||||
type: MessageType.ERROR,
|
||||
text: `Usage: /${cmd} <nick>[!ident][@host]`,
|
||||
})
|
||||
);
|
||||
|
@ -26,7 +31,7 @@ exports.input = function (network, chan, cmd, args) {
|
|||
if (cmd !== "ignorelist") {
|
||||
// Trim to remove any spaces from the hostmask
|
||||
target = args[0].trim();
|
||||
hostmask = Helper.parseHostmask(target);
|
||||
hostmask = Helper.parseHostmask(target) as IgnoreListItem;
|
||||
}
|
||||
|
||||
switch (cmd) {
|
||||
|
@ -36,7 +41,7 @@ exports.input = function (network, chan, cmd, args) {
|
|||
chan.pushMessage(
|
||||
client,
|
||||
new Msg({
|
||||
type: Msg.Type.ERROR,
|
||||
type: MessageType.ERROR,
|
||||
text: "You can't ignore yourself",
|
||||
})
|
||||
);
|
||||
|
@ -52,7 +57,7 @@ exports.input = function (network, chan, cmd, args) {
|
|||
chan.pushMessage(
|
||||
client,
|
||||
new Msg({
|
||||
type: Msg.Type.ERROR,
|
||||
type: MessageType.ERROR,
|
||||
text: `\u0002${hostmask.nick}!${hostmask.ident}@${hostmask.hostname}\u000f added to ignorelist`,
|
||||
})
|
||||
);
|
||||
|
@ -60,7 +65,7 @@ exports.input = function (network, chan, cmd, args) {
|
|||
chan.pushMessage(
|
||||
client,
|
||||
new Msg({
|
||||
type: Msg.Type.ERROR,
|
||||
type: MessageType.ERROR,
|
||||
text: "The specified user/hostmask is already ignored",
|
||||
})
|
||||
);
|
||||
|
@ -83,7 +88,7 @@ exports.input = function (network, chan, cmd, args) {
|
|||
chan.pushMessage(
|
||||
client,
|
||||
new Msg({
|
||||
type: Msg.Type.ERROR,
|
||||
type: MessageType.ERROR,
|
||||
text: `Successfully removed \u0002${hostmask.nick}!${hostmask.ident}@${hostmask.hostname}\u000f from ignorelist`,
|
||||
})
|
||||
);
|
||||
|
@ -91,7 +96,7 @@ exports.input = function (network, chan, cmd, args) {
|
|||
chan.pushMessage(
|
||||
client,
|
||||
new Msg({
|
||||
type: Msg.Type.ERROR,
|
||||
type: MessageType.ERROR,
|
||||
text: "The specified user/hostmask is not ignored",
|
||||
})
|
||||
);
|
||||
|
@ -105,7 +110,7 @@ exports.input = function (network, chan, cmd, args) {
|
|||
chan.pushMessage(
|
||||
client,
|
||||
new Msg({
|
||||
type: Msg.Type.ERROR,
|
||||
type: MessageType.ERROR,
|
||||
text: "Ignorelist is empty",
|
||||
})
|
||||
);
|
||||
|
@ -120,7 +125,7 @@ exports.input = function (network, chan, cmd, args) {
|
|||
if (typeof newChan === "undefined") {
|
||||
newChan = client.createChannel({
|
||||
type: ChanType.SPECIAL,
|
||||
special: Chan.SpecialType.IGNORELIST,
|
||||
special: SpecialChanType.IGNORELIST,
|
||||
name: chanName,
|
||||
data: ignored,
|
||||
});
|
||||
|
@ -130,6 +135,8 @@ exports.input = function (network, chan, cmd, args) {
|
|||
index: network.addChannel(newChan),
|
||||
});
|
||||
} else {
|
||||
// TODO: add type for this chan/event
|
||||
//@ts-expect-error
|
||||
newChan.data = ignored;
|
||||
|
||||
client.emit("msg:special", {
|
||||
|
@ -142,3 +149,8 @@ exports.input = function (network, chan, cmd, args) {
|
|||
break;
|
||||
}
|
||||
};
|
||||
|
||||
export default {
|
||||
commands,
|
||||
input,
|
||||
};
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
import Chan from "src/models/chan";
|
||||
import Network from "src/models/network";
|
||||
|
||||
const clientSideCommands = ["/collapse", "/expand", "/search"];
|
||||
|
||||
const passThroughCommands = [
|
||||
|
@ -37,8 +40,12 @@ const userInputs = [
|
|||
"whois",
|
||||
"mute",
|
||||
].reduce(function (plugins, name) {
|
||||
const plugin = require(`./${name}`);
|
||||
plugin.commands.forEach((command) => plugins.set(command, plugin));
|
||||
const plugin = require(`./${name}`) as {
|
||||
commands: string[];
|
||||
input: (network: Network, chan: Chan, cmd: string, args: string[]) => void;
|
||||
allowDisconnected?: boolean;
|
||||
};
|
||||
plugin.commands.forEach((command: string) => plugins.set(command, plugin));
|
||||
return plugins;
|
||||
}, new Map());
|
||||
|
||||
|
@ -57,7 +64,7 @@ const addPluginCommand = (packageInfo, command, func) => {
|
|||
pluginCommands.set(command, func);
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
addPluginCommand,
|
||||
getCommands,
|
||||
pluginCommands,
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
"use strict";
|
||||
|
||||
const Chan = require("../../models/chan");
|
||||
const Msg = require("../../models/msg");
|
||||
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";
|
||||
|
||||
exports.commands = ["invite", "invitelist"];
|
||||
const commands = ["invite", "invitelist"];
|
||||
|
||||
exports.input = function ({irc}, chan, cmd, args) {
|
||||
const input = function ({irc}: Network, chan: Chan, cmd: string, args: string[]) {
|
||||
if (cmd === "invitelist") {
|
||||
irc.inviteList(chan.name);
|
||||
return;
|
||||
|
@ -19,9 +22,14 @@ exports.input = function ({irc}, chan, cmd, args) {
|
|||
chan.pushMessage(
|
||||
this,
|
||||
new Msg({
|
||||
type: Msg.Type.ERROR,
|
||||
type: MessageType.ERROR,
|
||||
text: `${cmd} command can only be used in channels or by specifying a target.`,
|
||||
})
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
export default {
|
||||
commands,
|
||||
input,
|
||||
};
|
||||
|
|
|
@ -1,16 +1,19 @@
|
|||
"use strict";
|
||||
|
||||
const Chan = require("../../models/chan");
|
||||
const Msg = require("../../models/msg");
|
||||
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";
|
||||
|
||||
exports.commands = ["kick"];
|
||||
const commands = ["kick"];
|
||||
|
||||
exports.input = function ({irc}, chan, cmd, args) {
|
||||
const input = function ({irc}: Network, chan: Chan, cmd: string, args: string[]) {
|
||||
if (chan.type !== ChanType.CHANNEL) {
|
||||
chan.pushMessage(
|
||||
this,
|
||||
new Msg({
|
||||
type: Msg.Type.ERROR,
|
||||
type: MessageType.ERROR,
|
||||
text: `${cmd} command can only be used in channels.`,
|
||||
})
|
||||
);
|
||||
|
@ -24,3 +27,8 @@ exports.input = function ({irc}, chan, cmd, args) {
|
|||
|
||||
return true;
|
||||
};
|
||||
|
||||
export default {
|
||||
commands,
|
||||
input,
|
||||
};
|
||||
|
|
|
@ -1,11 +1,19 @@
|
|||
"use strict";
|
||||
|
||||
exports.commands = ["kill"];
|
||||
import Chan from "src/models/chan";
|
||||
import Network from "src/models/network";
|
||||
|
||||
exports.input = function ({irc}, chan, cmd, args) {
|
||||
const commands = ["kill"];
|
||||
|
||||
const input = function ({irc}: Network, chan: Chan, cmd: string, args: string[]) {
|
||||
if (args.length !== 0) {
|
||||
irc.raw("KILL", args[0], args.slice(1).join(" "));
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
export default {
|
||||
commands,
|
||||
input,
|
||||
};
|
||||
|
|
|
@ -1,9 +1,17 @@
|
|||
"use strict";
|
||||
|
||||
exports.commands = ["list"];
|
||||
import Chan from "src/models/chan";
|
||||
import Network from "src/models/network";
|
||||
|
||||
exports.input = function (network, chan, cmd, args) {
|
||||
const commands = ["list"];
|
||||
|
||||
const input = function (network: Network, chan: Chan, cmd: string, args: string[]) {
|
||||
network.chanCache = [];
|
||||
network.irc.list(...args);
|
||||
return true;
|
||||
};
|
||||
|
||||
export default {
|
||||
commands,
|
||||
input,
|
||||
};
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
"use strict";
|
||||
|
||||
const Chan = require("../../models/chan");
|
||||
const Msg = require("../../models/msg");
|
||||
import {ChanType} from "src/types/models/channel";
|
||||
import {MessageType} from "src/types/models/message";
|
||||
import Chan from "../../models/chan";
|
||||
import Msg from "../../models/msg";
|
||||
|
||||
exports.commands = ["mode", "umode", "op", "deop", "hop", "dehop", "voice", "devoice"];
|
||||
const commands = ["mode", "umode", "op", "deop", "hop", "dehop", "voice", "devoice"];
|
||||
|
||||
exports.input = function ({irc, nick}, chan, cmd, args) {
|
||||
const input = function ({irc, nick}, chan, cmd, args) {
|
||||
if (cmd === "umode") {
|
||||
irc.raw("MODE", nick, ...args);
|
||||
|
||||
|
@ -15,7 +17,7 @@ exports.input = function ({irc, nick}, chan, cmd, args) {
|
|||
chan.pushMessage(
|
||||
this,
|
||||
new Msg({
|
||||
type: Msg.Type.ERROR,
|
||||
type: MessageType.ERROR,
|
||||
text: `${cmd} command can only be used in channels.`,
|
||||
})
|
||||
);
|
||||
|
@ -29,7 +31,7 @@ exports.input = function ({irc, nick}, chan, cmd, args) {
|
|||
chan.pushMessage(
|
||||
this,
|
||||
new Msg({
|
||||
type: Msg.Type.ERROR,
|
||||
type: MessageType.ERROR,
|
||||
text: `Usage: /${cmd} <nick> [...nick]`,
|
||||
})
|
||||
);
|
||||
|
@ -65,3 +67,8 @@ exports.input = function ({irc, nick}, chan, cmd, args) {
|
|||
|
||||
irc.raw("MODE", ...args);
|
||||
};
|
||||
|
||||
export default {
|
||||
commands,
|
||||
input,
|
||||
};
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
"use strict";
|
||||
|
||||
const {ChanType} = require("src/types/models/channel");
|
||||
const Chan = require("../../models/chan");
|
||||
const Msg = require("../../models/msg");
|
||||
import Network from "src/models/network";
|
||||
import {ChanType} from "src/types/models/channel";
|
||||
import {MessageType} from "src/types/models/message";
|
||||
import Chan from "src/models/chan";
|
||||
import Msg from "src/models/msg";
|
||||
|
||||
exports.commands = ["query", "msg", "say"];
|
||||
const commands = ["query", "msg", "say"];
|
||||
|
||||
function getTarget(cmd, args, chan) {
|
||||
switch (cmd) {
|
||||
|
@ -16,7 +18,7 @@ function getTarget(cmd, args, chan) {
|
|||
}
|
||||
}
|
||||
|
||||
exports.input = function (network, chan, cmd, args) {
|
||||
const input = function (network: Network, chan: Chan, cmd: string, args: string[]) {
|
||||
let targetName = getTarget(cmd, args, chan);
|
||||
|
||||
if (cmd === "query") {
|
||||
|
@ -24,7 +26,7 @@ exports.input = function (network, chan, cmd, args) {
|
|||
chan.pushMessage(
|
||||
this,
|
||||
new Msg({
|
||||
type: Msg.Type.ERROR,
|
||||
type: MessageType.ERROR,
|
||||
text: "You cannot open a query window without an argument.",
|
||||
})
|
||||
);
|
||||
|
@ -43,7 +45,7 @@ exports.input = function (network, chan, cmd, args) {
|
|||
chan.pushMessage(
|
||||
this,
|
||||
new Msg({
|
||||
type: Msg.Type.ERROR,
|
||||
type: MessageType.ERROR,
|
||||
text: "You can not open query windows for channels, use /join instead.",
|
||||
})
|
||||
);
|
||||
|
@ -55,7 +57,7 @@ exports.input = function (network, chan, cmd, args) {
|
|||
chan.pushMessage(
|
||||
this,
|
||||
new Msg({
|
||||
type: Msg.Type.ERROR,
|
||||
type: MessageType.ERROR,
|
||||
text: "You can not open query windows for names starting with a user prefix.",
|
||||
})
|
||||
);
|
||||
|
@ -116,3 +118,8 @@ exports.input = function (network, chan, cmd, args) {
|
|||
|
||||
return true;
|
||||
};
|
||||
|
||||
export default {
|
||||
commands,
|
||||
input,
|
||||
};
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
"use strict";
|
||||
const Msg = require("../../models/msg");
|
||||
import Chan from "src/models/chan";
|
||||
import Network from "src/models/network";
|
||||
import {MessageType} from "src/types/models/message";
|
||||
import Msg from "../../models/msg";
|
||||
|
||||
exports.commands = ["mute", "unmute"];
|
||||
const commands = ["mute", "unmute"];
|
||||
const allowDisconnected = true;
|
||||
|
||||
function args_to_channels(network, args) {
|
||||
const targets = [];
|
||||
|
@ -29,7 +33,7 @@ function change_mute_state(client, target, valueToSet) {
|
|||
});
|
||||
}
|
||||
|
||||
exports.input = function (network, chan, cmd, args) {
|
||||
const input = function (network: Network, chan: Chan, cmd: string, args: string[]) {
|
||||
const valueToSet = cmd === "mute" ? true : false;
|
||||
const client = this;
|
||||
|
||||
|
@ -46,7 +50,7 @@ exports.input = function (network, chan, cmd, args) {
|
|||
chan.pushMessage(
|
||||
client,
|
||||
new Msg({
|
||||
type: Msg.Type.ERROR,
|
||||
type: MessageType.ERROR,
|
||||
text: `No open ${
|
||||
missing.length === 1 ? "channel or user" : "channels or users"
|
||||
} found for ${missing.join(",")}`,
|
||||
|
@ -59,3 +63,9 @@ exports.input = function (network, chan, cmd, args) {
|
|||
change_mute_state(client, target, valueToSet);
|
||||
}
|
||||
};
|
||||
|
||||
export default {
|
||||
commands,
|
||||
input,
|
||||
allowDisconnected,
|
||||
};
|
||||
|
|
|
@ -1,16 +1,19 @@
|
|||
"use strict";
|
||||
|
||||
const Msg = require("../../models/msg");
|
||||
import Chan from "src/models/chan";
|
||||
import Network from "src/models/network";
|
||||
import {MessageType} from "src/types/models/message";
|
||||
import Msg from "../../models/msg";
|
||||
|
||||
exports.commands = ["nick"];
|
||||
exports.allowDisconnected = true;
|
||||
const commands = ["nick"];
|
||||
const allowDisconnected = true;
|
||||
|
||||
exports.input = function (network, chan, cmd, args) {
|
||||
const input = function (network: Network, chan: Chan, cmd: string, args: string[]) {
|
||||
if (args.length === 0) {
|
||||
chan.pushMessage(
|
||||
this,
|
||||
new Msg({
|
||||
type: Msg.Type.ERROR,
|
||||
type: MessageType.ERROR,
|
||||
text: "Usage: /nick <your new nick>",
|
||||
})
|
||||
);
|
||||
|
@ -21,7 +24,7 @@ exports.input = function (network, chan, cmd, args) {
|
|||
chan.pushMessage(
|
||||
this,
|
||||
new Msg({
|
||||
type: Msg.Type.ERROR,
|
||||
type: MessageType.ERROR,
|
||||
text: "Nicknames may not contain spaces.",
|
||||
})
|
||||
);
|
||||
|
@ -34,7 +37,7 @@ exports.input = function (network, chan, cmd, args) {
|
|||
chan.pushMessage(
|
||||
this,
|
||||
new Msg({
|
||||
type: Msg.Type.ERROR,
|
||||
type: MessageType.ERROR,
|
||||
text: "Nicknames may not be this long.",
|
||||
})
|
||||
);
|
||||
|
@ -65,3 +68,9 @@ exports.input = function (network, chan, cmd, args) {
|
|||
|
||||
this.save();
|
||||
};
|
||||
|
||||
export default {
|
||||
commands,
|
||||
input,
|
||||
allowDisconnected,
|
||||
};
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
"use strict";
|
||||
|
||||
exports.commands = ["notice"];
|
||||
import Chan from "src/models/chan";
|
||||
import Network from "src/models/network";
|
||||
|
||||
exports.input = function (network, chan, cmd, args) {
|
||||
const commands = ["notice"];
|
||||
|
||||
const input = function (network: Network, chan: Chan, cmd: string, args: string[]) {
|
||||
if (!args[1]) {
|
||||
return;
|
||||
}
|
||||
|
@ -37,3 +40,8 @@ exports.input = function (network, chan, cmd, args) {
|
|||
|
||||
return true;
|
||||
};
|
||||
|
||||
export default {
|
||||
commands,
|
||||
input,
|
||||
};
|
||||
|
|
|
@ -1,13 +1,16 @@
|
|||
"use strict";
|
||||
|
||||
const Msg = require("../../models/msg");
|
||||
const Chan = require("../../models/chan");
|
||||
const Config = require("../../config");
|
||||
import Msg from "src/models/msg";
|
||||
import Chan from "src/models/chan";
|
||||
import Config from "src/config";
|
||||
import Network from "src/models/network";
|
||||
import {MessageType} from "src/types/models/message";
|
||||
import {ChanState, ChanType} from "src/types/models/channel";
|
||||
|
||||
exports.commands = ["close", "leave", "part"];
|
||||
exports.allowDisconnected = true;
|
||||
const commands = ["close", "leave", "part"];
|
||||
const allowDisconnected = true;
|
||||
|
||||
exports.input = function (network, chan, cmd, args) {
|
||||
const input = function (network: Network, chan: Chan, cmd: string, args: string[]) {
|
||||
let target = chan;
|
||||
|
||||
if (args.length > 0) {
|
||||
|
@ -24,7 +27,7 @@ exports.input = function (network, chan, cmd, args) {
|
|||
chan.pushMessage(
|
||||
this,
|
||||
new Msg({
|
||||
type: Msg.Type.ERROR,
|
||||
type: MessageType.ERROR,
|
||||
text: "You can not part from networks, use /quit instead.",
|
||||
})
|
||||
);
|
||||
|
@ -35,7 +38,7 @@ exports.input = function (network, chan, cmd, args) {
|
|||
// Otherwise send part to the server and wait for response
|
||||
if (
|
||||
target.type !== ChanType.CHANNEL ||
|
||||
target.state === Chan.State.PARTED ||
|
||||
target.state === ChanState.PARTED ||
|
||||
!network.irc ||
|
||||
!network.irc.connection ||
|
||||
!network.irc.connection.connected
|
||||
|
@ -48,3 +51,9 @@ exports.input = function (network, chan, cmd, args) {
|
|||
|
||||
return true;
|
||||
};
|
||||
|
||||
export default {
|
||||
commands,
|
||||
input,
|
||||
allowDisconnected,
|
||||
};
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
"use strict";
|
||||
|
||||
const _ = require("lodash");
|
||||
const ClientCertificate = require("../clientCertificate");
|
||||
import _ from "lodash";
|
||||
import Chan from "src/models/chan";
|
||||
import Network from "src/models/network";
|
||||
import ClientCertificate from "../clientCertificate";
|
||||
|
||||
exports.commands = ["quit"];
|
||||
exports.allowDisconnected = true;
|
||||
const commands = ["quit"];
|
||||
const allowDisconnected = true;
|
||||
|
||||
exports.input = function (network, chan, cmd, args) {
|
||||
const input = function (network: Network, chan: Chan, cmd: string, args: string[]) {
|
||||
const client = this;
|
||||
|
||||
client.networks = _.without(client.networks, network);
|
||||
|
@ -23,3 +25,9 @@ exports.input = function (network, chan, cmd, args) {
|
|||
|
||||
return true;
|
||||
};
|
||||
|
||||
export default {
|
||||
commands,
|
||||
input,
|
||||
allowDisconnected,
|
||||
};
|
||||
|
|
|
@ -1,11 +1,19 @@
|
|||
"use strict";
|
||||
|
||||
exports.commands = ["raw", "send", "quote"];
|
||||
import Chan from "src/models/chan";
|
||||
import Network from "src/models/network";
|
||||
|
||||
exports.input = function ({irc}, chan, cmd, args) {
|
||||
const commands = ["raw", "send", "quote"];
|
||||
|
||||
const input = function ({irc}: Network, chan: Chan, cmd: string, args: string[]) {
|
||||
if (args.length !== 0) {
|
||||
irc.connection.write(args.join(" "));
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
export default {
|
||||
commands,
|
||||
input,
|
||||
};
|
||||
|
|
|
@ -1,16 +1,19 @@
|
|||
"use strict";
|
||||
|
||||
const Msg = require("../../models/msg");
|
||||
const Chan = require("../../models/chan");
|
||||
import Msg from "../../models/msg";
|
||||
import Chan from "../../models/chan";
|
||||
import {ChanType} from "src/types/models/channel";
|
||||
import {MessageType} from "src/types/models/message";
|
||||
import Network from "src/models/network";
|
||||
|
||||
exports.commands = ["cycle", "rejoin"];
|
||||
const commands = ["cycle", "rejoin"];
|
||||
|
||||
exports.input = function ({irc}, chan) {
|
||||
const input = function ({irc}: Network, chan: Chan) {
|
||||
if (chan.type !== ChanType.CHANNEL) {
|
||||
chan.pushMessage(
|
||||
this,
|
||||
new Msg({
|
||||
type: Msg.Type.ERROR,
|
||||
type: MessageType.ERROR,
|
||||
text: "You can only rejoin channels.",
|
||||
})
|
||||
);
|
||||
|
@ -22,3 +25,8 @@ exports.input = function ({irc}, chan) {
|
|||
|
||||
return true;
|
||||
};
|
||||
|
||||
export default {
|
||||
commands,
|
||||
input,
|
||||
};
|
||||
|
|
|
@ -1,16 +1,19 @@
|
|||
"use strict";
|
||||
|
||||
const Chan = require("../../models/chan");
|
||||
const Msg = require("../../models/msg");
|
||||
import Network from "src/models/network";
|
||||
import Chan from "src/models/chan";
|
||||
import Msg from "src/models/msg";
|
||||
import {ChanType} from "src/types/models/channel";
|
||||
import {MessageType} from "src/types/models/message";
|
||||
|
||||
exports.commands = ["topic"];
|
||||
const commands = ["topic"];
|
||||
|
||||
exports.input = function ({irc}, chan, cmd, args) {
|
||||
const input = function ({irc}: Network, chan: Chan, cmd: string, args: string[]) {
|
||||
if (chan.type !== ChanType.CHANNEL) {
|
||||
chan.pushMessage(
|
||||
this,
|
||||
new Msg({
|
||||
type: Msg.Type.ERROR,
|
||||
type: MessageType.ERROR,
|
||||
text: `${cmd} command can only be used in channels.`,
|
||||
})
|
||||
);
|
||||
|
@ -21,3 +24,8 @@ exports.input = function ({irc}, chan, cmd, args) {
|
|||
irc.setTopic(chan.name, args.join(" "));
|
||||
return true;
|
||||
};
|
||||
|
||||
export default {
|
||||
commands,
|
||||
input,
|
||||
};
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
"use strict";
|
||||
|
||||
exports.commands = ["whois"];
|
||||
import Chan from "src/models/chan";
|
||||
import Network from "src/models/network";
|
||||
|
||||
exports.input = function ({irc}, chan, cmd, args) {
|
||||
const commands = ["whois"];
|
||||
|
||||
const input = function ({irc}: Network, chan: Chan, cmd: string, args: string[]) {
|
||||
if (args.length === 1) {
|
||||
// This queries server of the other user and not of the current user, which
|
||||
// does not know idle time.
|
||||
|
@ -13,3 +16,8 @@ exports.input = function ({irc}, chan, cmd, args) {
|
|||
irc.raw(`${cmd} ${args.join(" ")}`);
|
||||
}
|
||||
};
|
||||
|
||||
export default {
|
||||
commands,
|
||||
input,
|
||||
};
|
||||
|
|
6
src/types/models/network.d.ts
vendored
6
src/types/models/network.d.ts
vendored
|
@ -6,3 +6,9 @@ export type NetworkStatus = {
|
|||
connected: boolean;
|
||||
secure: boolean;
|
||||
};
|
||||
|
||||
type IgnoreListItem = Hostmask & {
|
||||
when?: number;
|
||||
};
|
||||
|
||||
type IgnoreList = IgnoreListItem[];
|
||||
|
|
16
src/types/modules/irc-framework.d.ts
vendored
16
src/types/modules/irc-framework.d.ts
vendored
|
@ -1,5 +1,6 @@
|
|||
// https://raw.githubusercontent.com/eternagame/HTML-Chat/vue-rewrite/src/app/types/modules/irc-framework/irc-framework.d.ts
|
||||
|
||||
// TODO: Fix this
|
||||
type Event = any;
|
||||
declare module "irc-framework" {
|
||||
import {EventEmitter} from "eventemitter3";
|
||||
// import { DuplexStream } from 'stream';
|
||||
|
@ -15,6 +16,7 @@ declare module "irc-framework" {
|
|||
registered: boolean;
|
||||
|
||||
transport: any;
|
||||
write: (data: string) => void;
|
||||
};
|
||||
|
||||
export class Client extends EventEmitter {
|
||||
|
@ -98,7 +100,7 @@ declare module "irc-framework" {
|
|||
|
||||
mode(channel: string, mode: string, extra_args?: string[]): void;
|
||||
|
||||
inviteList(channel: string, cb: (e: Event) => any): void;
|
||||
inviteList(channel: string, cb?: (e: Event) => any): void;
|
||||
|
||||
// TODO: typeof e?
|
||||
invite(channel: string, nick: string): void;
|
||||
|
@ -107,7 +109,7 @@ declare module "irc-framework" {
|
|||
|
||||
removeInvite(channel: string, mask: string): void;
|
||||
|
||||
banlist(channel: string, cb: (e: Event) => any): void;
|
||||
banlist(channel: string, cb?: (e: Event) => any): void;
|
||||
|
||||
ban(channel: string, mask: string): void;
|
||||
|
||||
|
@ -115,13 +117,13 @@ declare module "irc-framework" {
|
|||
|
||||
setTopic(channel: string, newTopic: string): void;
|
||||
|
||||
ctcpRequest(target: string, type: string /* , ...params: Array<any> */): void;
|
||||
ctcpRequest(target: string, type: string, ...params: Array<string>): void;
|
||||
|
||||
ctcpResponse(target: string, type: string /* , params: Array<any> */): void;
|
||||
ctcpResponse(target: string, type: string, ...params: Array<string>): void;
|
||||
|
||||
action(target: string, message: string): string[];
|
||||
|
||||
whowas(target: string, cb: (event: Event) => any): void;
|
||||
whowas(target: string, cb?: (event: Event) => any): void;
|
||||
|
||||
whois(nick: string, cb: (event: any) => void): void;
|
||||
|
||||
|
@ -132,7 +134,7 @@ declare module "irc-framework" {
|
|||
*/
|
||||
who(target: string, cb: (event: any) => void): void;
|
||||
|
||||
list(/* params: Array<string> */): void;
|
||||
list(...params: Array<string>): void;
|
||||
|
||||
channel(channel_name: string): IrcChannel;
|
||||
|
||||
|
|
Loading…
Reference in a new issue