mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-15 05:41:51 +00:00
+debug build method (revert this)
Signed-off-by: GitHub <noreply@github.com>
This commit is contained in:
parent
1bce5a5090
commit
a80af1e729
12 changed files with 40 additions and 23 deletions
|
@ -1,9 +0,0 @@
|
||||||
{
|
|
||||||
"name": "Zeppelin Development",
|
|
||||||
|
|
||||||
"dockerComposeFile": "../docker-compose.development.yml",
|
|
||||||
|
|
||||||
"service": "devenv",
|
|
||||||
"remoteUser": "ubuntu",
|
|
||||||
"workspaceFolder": "/home/ubuntu/zeppelin"
|
|
||||||
}
|
|
14
backend/package-lock.json
generated
14
backend/package-lock.json
generated
|
@ -23,7 +23,7 @@
|
||||||
"humanize-duration": "^3.15.0",
|
"humanize-duration": "^3.15.0",
|
||||||
"io-ts": "^2.0.0",
|
"io-ts": "^2.0.0",
|
||||||
"js-yaml": "^3.13.1",
|
"js-yaml": "^3.13.1",
|
||||||
"knub": "^32.0.0-next.0",
|
"knub": "^31.0.0",
|
||||||
"knub-command-manager": "^9.1.0",
|
"knub-command-manager": "^9.1.0",
|
||||||
"last-commit-log": "^2.1.0",
|
"last-commit-log": "^2.1.0",
|
||||||
"lodash.chunk": "^4.2.0",
|
"lodash.chunk": "^4.2.0",
|
||||||
|
@ -2704,9 +2704,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/knub": {
|
"node_modules/knub": {
|
||||||
"version": "32.0.0-next.0",
|
"version": "31.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/knub/-/knub-32.0.0-next.0.tgz",
|
"resolved": "https://registry.npmjs.org/knub/-/knub-31.0.0.tgz",
|
||||||
"integrity": "sha512-tT27Qr8qpge+EWonrMyw54mZ67/1WP3oKF7QgTdK6cYArTdERuYxF9X7ngd9JXcVeW9/WYz/62jq42/w9lDzIA==",
|
"integrity": "sha512-mm2PrtQ9G5UoELfJ4kjWaNQZZRMhwJbCf4FgJj92iDy4pg95XPNWAkwTw8avbkslNjb9m5Va1pp3IeJayvz/ag==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"discord-api-types": "^0.37.10",
|
"discord-api-types": "^0.37.10",
|
||||||
"discord.js": "^14",
|
"discord.js": "^14",
|
||||||
|
@ -7199,9 +7199,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"knub": {
|
"knub": {
|
||||||
"version": "32.0.0-next.0",
|
"version": "31.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/knub/-/knub-32.0.0-next.0.tgz",
|
"resolved": "https://registry.npmjs.org/knub/-/knub-31.0.0.tgz",
|
||||||
"integrity": "sha512-tT27Qr8qpge+EWonrMyw54mZ67/1WP3oKF7QgTdK6cYArTdERuYxF9X7ngd9JXcVeW9/WYz/62jq42/w9lDzIA==",
|
"integrity": "sha512-mm2PrtQ9G5UoELfJ4kjWaNQZZRMhwJbCf4FgJj92iDy4pg95XPNWAkwTw8avbkslNjb9m5Va1pp3IeJayvz/ag==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"discord-api-types": "^0.37.10",
|
"discord-api-types": "^0.37.10",
|
||||||
"discord.js": "^14",
|
"discord.js": "^14",
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
"humanize-duration": "^3.15.0",
|
"humanize-duration": "^3.15.0",
|
||||||
"io-ts": "^2.0.0",
|
"io-ts": "^2.0.0",
|
||||||
"js-yaml": "^3.13.1",
|
"js-yaml": "^3.13.1",
|
||||||
"knub": "^32.0.0-next.0",
|
"knub": "^31.0.0",
|
||||||
"knub-command-manager": "^9.1.0",
|
"knub-command-manager": "^9.1.0",
|
||||||
"last-commit-log": "^2.1.0",
|
"last-commit-log": "^2.1.0",
|
||||||
"lodash.chunk": "^4.2.0",
|
"lodash.chunk": "^4.2.0",
|
||||||
|
|
|
@ -354,6 +354,7 @@ connect().then(async () => {
|
||||||
sendSuccessMessageFn(channel, body) {
|
sendSuccessMessageFn(channel, body) {
|
||||||
const guildId =
|
const guildId =
|
||||||
channel instanceof TextChannel || channel instanceof ThreadChannel ? channel.guild.id : undefined;
|
channel instanceof TextChannel || channel instanceof ThreadChannel ? channel.guild.id : undefined;
|
||||||
|
// @ts-expect-error
|
||||||
const emoji = guildId ? bot.getLoadedGuild(guildId)!.config.success_emoji : undefined;
|
const emoji = guildId ? bot.getLoadedGuild(guildId)!.config.success_emoji : undefined;
|
||||||
channel.send(successMessage(body, emoji));
|
channel.send(successMessage(body, emoji));
|
||||||
},
|
},
|
||||||
|
@ -361,6 +362,7 @@ connect().then(async () => {
|
||||||
sendErrorMessageFn(channel, body) {
|
sendErrorMessageFn(channel, body) {
|
||||||
const guildId =
|
const guildId =
|
||||||
channel instanceof TextChannel || channel instanceof ThreadChannel ? channel.guild.id : undefined;
|
channel instanceof TextChannel || channel instanceof ThreadChannel ? channel.guild.id : undefined;
|
||||||
|
// @ts-expect-error
|
||||||
const emoji = guildId ? bot.getLoadedGuild(guildId)!.config.error_emoji : undefined;
|
const emoji = guildId ? bot.getLoadedGuild(guildId)!.config.error_emoji : undefined;
|
||||||
channel.send(errorMessage(body, emoji));
|
channel.send(errorMessage(body, emoji));
|
||||||
},
|
},
|
||||||
|
|
|
@ -93,6 +93,11 @@ export function strictValidationErrorToConfigValidationError(err: StrictValidati
|
||||||
|
|
||||||
export function getPluginConfigParser(blueprint: ZeppelinPlugin, customParser?: ZeppelinPlugin["configParser"]) {
|
export function getPluginConfigParser(blueprint: ZeppelinPlugin, customParser?: ZeppelinPlugin["configParser"]) {
|
||||||
return async (options: PluginOptions<any>, strict?: boolean) => {
|
return async (options: PluginOptions<any>, strict?: boolean) => {
|
||||||
|
const ident = `[getPluginConfigParser.${blueprint.name}] | `;
|
||||||
|
if (blueprint.name === "mutes") {
|
||||||
|
console.log(ident, "options => ", JSON.stringify(options));
|
||||||
|
}
|
||||||
|
|
||||||
// 1. Validate the basic structure of plugin config
|
// 1. Validate the basic structure of plugin config
|
||||||
const basicOptionsValidation = validate(BasicPluginStructureType, options);
|
const basicOptionsValidation = validate(BasicPluginStructureType, options);
|
||||||
if (basicOptionsValidation instanceof StrictValidationError) {
|
if (basicOptionsValidation instanceof StrictValidationError) {
|
||||||
|
@ -142,7 +147,7 @@ export function getPluginConfigParser(blueprint: ZeppelinPlugin, customParser?:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. Run custom preprocessor, if any
|
// 3. Run custom parser, if any
|
||||||
if (customParser) {
|
if (customParser) {
|
||||||
options = await customParser(options);
|
options = await customParser(options);
|
||||||
}
|
}
|
||||||
|
@ -156,6 +161,7 @@ export function getPluginConfigParser(blueprint: ZeppelinPlugin, customParser?:
|
||||||
? decodeAndValidateStrict(blueprint.configSchema, options.config)
|
? decodeAndValidateStrict(blueprint.configSchema, options.config)
|
||||||
: options.config;
|
: options.config;
|
||||||
if (decodedConfig instanceof StrictValidationError) {
|
if (decodedConfig instanceof StrictValidationError) {
|
||||||
|
console.error("4.strict:", blueprint.name);
|
||||||
throw strictValidationErrorToConfigValidationError(decodedConfig);
|
throw strictValidationErrorToConfigValidationError(decodedConfig);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -167,6 +173,7 @@ export function getPluginConfigParser(blueprint: ZeppelinPlugin, customParser?:
|
||||||
? decodeAndValidateStrict(blueprint.configSchema, overrideConfigMergedWithBaseConfig)
|
? decodeAndValidateStrict(blueprint.configSchema, overrideConfigMergedWithBaseConfig)
|
||||||
: overrideConfigMergedWithBaseConfig;
|
: overrideConfigMergedWithBaseConfig;
|
||||||
if (decodedOverrideConfig instanceof StrictValidationError) {
|
if (decodedOverrideConfig instanceof StrictValidationError) {
|
||||||
|
console.error("4.overrides.strict:", blueprint.name, options, decodedOverrideConfig);
|
||||||
throw strictValidationErrorToConfigValidationError(decodedOverrideConfig);
|
throw strictValidationErrorToConfigValidationError(decodedOverrideConfig);
|
||||||
}
|
}
|
||||||
decodedOverrides.push({
|
decodedOverrides.push({
|
||||||
|
@ -227,11 +234,13 @@ export async function sendErrorMessage(
|
||||||
|
|
||||||
export function getBaseUrl(pluginData: AnyPluginData<any>) {
|
export function getBaseUrl(pluginData: AnyPluginData<any>) {
|
||||||
const knub = pluginData.getKnubInstance() as TZeppelinKnub;
|
const knub = pluginData.getKnubInstance() as TZeppelinKnub;
|
||||||
|
// @ts-expect-error
|
||||||
return knub.getGlobalConfig().url;
|
return knub.getGlobalConfig().url;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isOwner(pluginData: AnyPluginData<any>, userId: string) {
|
export function isOwner(pluginData: AnyPluginData<any>, userId: string) {
|
||||||
const knub = pluginData.getKnubInstance() as TZeppelinKnub;
|
const knub = pluginData.getKnubInstance() as TZeppelinKnub;
|
||||||
|
// @ts-expect-error
|
||||||
const owners = knub.getGlobalConfig()?.owners;
|
const owners = knub.getGlobalConfig()?.owners;
|
||||||
if (!owners) {
|
if (!owners) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -188,6 +188,7 @@ export const AutomodPlugin = zeppelinGuildPlugin<AutomodPluginType>()({
|
||||||
info: pluginInfo,
|
info: pluginInfo,
|
||||||
|
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
|
// @ts-expect-error
|
||||||
dependencies: () => [
|
dependencies: () => [
|
||||||
LogsPlugin,
|
LogsPlugin,
|
||||||
ModActionsPlugin,
|
ModActionsPlugin,
|
||||||
|
@ -256,7 +257,7 @@ export const AutomodPlugin = zeppelinGuildPlugin<AutomodPluginType>()({
|
||||||
|
|
||||||
pluginData.state.onMessageUpdateFn = (message) => runAutomodOnMessage(pluginData, message, true);
|
pluginData.state.onMessageUpdateFn = (message) => runAutomodOnMessage(pluginData, message, true);
|
||||||
pluginData.state.savedMessages.events.on("update", pluginData.state.onMessageUpdateFn);
|
pluginData.state.savedMessages.events.on("update", pluginData.state.onMessageUpdateFn);
|
||||||
|
// @ts-expect-error
|
||||||
const countersPlugin = pluginData.getPlugin(CountersPlugin);
|
const countersPlugin = pluginData.getPlugin(CountersPlugin);
|
||||||
|
|
||||||
pluginData.state.onCounterTrigger = (name, triggerName, channelId, userId) => {
|
pluginData.state.onCounterTrigger = (name, triggerName, channelId, userId) => {
|
||||||
|
@ -266,8 +267,9 @@ export const AutomodPlugin = zeppelinGuildPlugin<AutomodPluginType>()({
|
||||||
pluginData.state.onCounterReverseTrigger = (name, triggerName, channelId, userId) => {
|
pluginData.state.onCounterReverseTrigger = (name, triggerName, channelId, userId) => {
|
||||||
runAutomodOnCounterTrigger(pluginData, name, triggerName, channelId, userId, true);
|
runAutomodOnCounterTrigger(pluginData, name, triggerName, channelId, userId, true);
|
||||||
};
|
};
|
||||||
|
// @ts-expect-error
|
||||||
countersPlugin.onCounterEvent("trigger", pluginData.state.onCounterTrigger);
|
countersPlugin.onCounterEvent("trigger", pluginData.state.onCounterTrigger);
|
||||||
|
// @ts-expect-error
|
||||||
countersPlugin.onCounterEvent("reverseTrigger", pluginData.state.onCounterReverseTrigger);
|
countersPlugin.onCounterEvent("reverseTrigger", pluginData.state.onCounterReverseTrigger);
|
||||||
|
|
||||||
const modActionsEvents = pluginData.getPlugin(ModActionsPlugin).getEventEmitter();
|
const modActionsEvents = pluginData.getPlugin(ModActionsPlugin).getEventEmitter();
|
||||||
|
@ -309,11 +311,14 @@ export const AutomodPlugin = zeppelinGuildPlugin<AutomodPluginType>()({
|
||||||
},
|
},
|
||||||
|
|
||||||
async beforeUnload(pluginData) {
|
async beforeUnload(pluginData) {
|
||||||
|
// @ts-expect-error
|
||||||
const countersPlugin = pluginData.getPlugin(CountersPlugin);
|
const countersPlugin = pluginData.getPlugin(CountersPlugin);
|
||||||
if (pluginData.state.onCounterTrigger) {
|
if (pluginData.state.onCounterTrigger) {
|
||||||
|
// @ts-expect-error
|
||||||
countersPlugin.offCounterEvent("trigger", pluginData.state.onCounterTrigger);
|
countersPlugin.offCounterEvent("trigger", pluginData.state.onCounterTrigger);
|
||||||
}
|
}
|
||||||
if (pluginData.state.onCounterReverseTrigger) {
|
if (pluginData.state.onCounterReverseTrigger) {
|
||||||
|
// @ts-expect-error
|
||||||
countersPlugin.offCounterEvent("reverseTrigger", pluginData.state.onCounterReverseTrigger);
|
countersPlugin.offCounterEvent("reverseTrigger", pluginData.state.onCounterReverseTrigger);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,9 @@ export const AddToCounterAction = automodAction({
|
||||||
defaultConfig: {},
|
defaultConfig: {},
|
||||||
|
|
||||||
async apply({ pluginData, contexts, actionConfig, matchResult, ruleName }) {
|
async apply({ pluginData, contexts, actionConfig, matchResult, ruleName }) {
|
||||||
|
// @ts-expect-error
|
||||||
const countersPlugin = pluginData.getPlugin(CountersPlugin);
|
const countersPlugin = pluginData.getPlugin(CountersPlugin);
|
||||||
|
// @ts-expect-error
|
||||||
if (!countersPlugin.counterExists(actionConfig.counter)) {
|
if (!countersPlugin.counterExists(actionConfig.counter)) {
|
||||||
pluginData.getPlugin(LogsPlugin).logBotAlert({
|
pluginData.getPlugin(LogsPlugin).logBotAlert({
|
||||||
body: `Unknown counter \`${actionConfig.counter}\` in \`add_to_counter\` action of Automod rule \`${ruleName}\``,
|
body: `Unknown counter \`${actionConfig.counter}\` in \`add_to_counter\` action of Automod rule \`${ruleName}\``,
|
||||||
|
@ -20,6 +22,7 @@ export const AddToCounterAction = automodAction({
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @ts-expect-error
|
||||||
countersPlugin.changeCounterValue(
|
countersPlugin.changeCounterValue(
|
||||||
actionConfig.counter,
|
actionConfig.counter,
|
||||||
contexts[0].message?.channel_id || null,
|
contexts[0].message?.channel_id || null,
|
||||||
|
|
|
@ -12,7 +12,9 @@ export const SetCounterAction = automodAction({
|
||||||
defaultConfig: {},
|
defaultConfig: {},
|
||||||
|
|
||||||
async apply({ pluginData, contexts, actionConfig, matchResult, ruleName }) {
|
async apply({ pluginData, contexts, actionConfig, matchResult, ruleName }) {
|
||||||
|
// @ts-expect-error
|
||||||
const countersPlugin = pluginData.getPlugin(CountersPlugin);
|
const countersPlugin = pluginData.getPlugin(CountersPlugin);
|
||||||
|
// @ts-expect-error
|
||||||
if (!countersPlugin.counterExists(actionConfig.counter)) {
|
if (!countersPlugin.counterExists(actionConfig.counter)) {
|
||||||
pluginData.getPlugin(LogsPlugin).logBotAlert({
|
pluginData.getPlugin(LogsPlugin).logBotAlert({
|
||||||
body: `Unknown counter \`${actionConfig.counter}\` in \`add_to_counter\` action of Automod rule \`${ruleName}\``,
|
body: `Unknown counter \`${actionConfig.counter}\` in \`add_to_counter\` action of Automod rule \`${ruleName}\``,
|
||||||
|
@ -20,6 +22,7 @@ export const SetCounterAction = automodAction({
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @ts-expect-error
|
||||||
countersPlugin.setCounterValue(
|
countersPlugin.setCounterValue(
|
||||||
actionConfig.counter,
|
actionConfig.counter,
|
||||||
contexts[0].message?.channel_id || null,
|
contexts[0].message?.channel_id || null,
|
||||||
|
|
|
@ -14,9 +14,11 @@ export async function runAutomodOnCounterTrigger(
|
||||||
) {
|
) {
|
||||||
const user = userId ? await resolveUser(pluginData.client, userId) : undefined;
|
const user = userId ? await resolveUser(pluginData.client, userId) : undefined;
|
||||||
const member = (userId && (await resolveMember(pluginData.client, pluginData.guild, userId))) || undefined;
|
const member = (userId && (await resolveMember(pluginData.client, pluginData.guild, userId))) || undefined;
|
||||||
|
// @ts-expect-error
|
||||||
const prettyCounterName = pluginData.getPlugin(CountersPlugin).getPrettyNameForCounter(counterName);
|
const prettyCounterName = pluginData.getPlugin(CountersPlugin).getPrettyNameForCounter(counterName);
|
||||||
|
// @ts-expect-error
|
||||||
const prettyTriggerName = pluginData
|
const prettyTriggerName = pluginData
|
||||||
|
// @ts-expect-error
|
||||||
.getPlugin(CountersPlugin)
|
.getPlugin(CountersPlugin)
|
||||||
.getPrettyNameForCounterTrigger(counterName, triggerName);
|
.getPrettyNameForCounterTrigger(counterName, triggerName);
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,7 @@ export const HelpCmd = utilityCmd({
|
||||||
if (strTrigger.startsWith(searchStr)) {
|
if (strTrigger.startsWith(searchStr)) {
|
||||||
matchingCommands.push({
|
matchingCommands.push({
|
||||||
plugin,
|
plugin,
|
||||||
|
// @ts-expect-error
|
||||||
command: registeredCommand,
|
command: registeredCommand,
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -136,6 +136,7 @@ export async function getMessageInfoEmbed(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (message.embeds.length) {
|
if (message.embeds.length) {
|
||||||
|
// @ts-expect-error
|
||||||
const prefix = pluginData.fullConfig.prefix || getDefaultPrefix(pluginData.client);
|
const prefix = pluginData.fullConfig.prefix || getDefaultPrefix(pluginData.client);
|
||||||
embed.fields.push({
|
embed.fields.push({
|
||||||
name: preEmbedPadding + "Embeds",
|
name: preEmbedPadding + "Embeds",
|
||||||
|
|
|
@ -54,7 +54,7 @@ export function zeppelinGuildPlugin(...args) {
|
||||||
const blueprint = guildPlugin(
|
const blueprint = guildPlugin(
|
||||||
...(args as Parameters<typeof guildPlugin>),
|
...(args as Parameters<typeof guildPlugin>),
|
||||||
) as unknown as ZeppelinGuildPluginBlueprint;
|
) as unknown as ZeppelinGuildPluginBlueprint;
|
||||||
blueprint.configParser = getPluginConfigParser(blueprint, blueprint.configParser);
|
blueprint.configParser = <any>getPluginConfigParser(blueprint, blueprint.configParser);
|
||||||
return blueprint;
|
return blueprint;
|
||||||
} else {
|
} else {
|
||||||
return zeppelinGuildPlugin as (name, blueprint) => ZeppelinGuildPluginBlueprint;
|
return zeppelinGuildPlugin as (name, blueprint) => ZeppelinGuildPluginBlueprint;
|
||||||
|
@ -89,7 +89,7 @@ export function zeppelinGlobalPlugin(...args) {
|
||||||
const blueprint = globalPlugin(
|
const blueprint = globalPlugin(
|
||||||
...(args as Parameters<typeof globalPlugin>),
|
...(args as Parameters<typeof globalPlugin>),
|
||||||
) as unknown as ZeppelinGlobalPluginBlueprint;
|
) as unknown as ZeppelinGlobalPluginBlueprint;
|
||||||
// @ts-ignore FIXME: Check the types here
|
// @ts-expect-error FIXME: Check the types here
|
||||||
blueprint.configParser = getPluginConfigParser(blueprint, blueprint.configParser);
|
blueprint.configParser = getPluginConfigParser(blueprint, blueprint.configParser);
|
||||||
return blueprint;
|
return blueprint;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Reference in a new issue