mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-14 21:31:50 +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",
|
||||
"io-ts": "^2.0.0",
|
||||
"js-yaml": "^3.13.1",
|
||||
"knub": "^32.0.0-next.0",
|
||||
"knub": "^31.0.0",
|
||||
"knub-command-manager": "^9.1.0",
|
||||
"last-commit-log": "^2.1.0",
|
||||
"lodash.chunk": "^4.2.0",
|
||||
|
@ -2704,9 +2704,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/knub": {
|
||||
"version": "32.0.0-next.0",
|
||||
"resolved": "https://registry.npmjs.org/knub/-/knub-32.0.0-next.0.tgz",
|
||||
"integrity": "sha512-tT27Qr8qpge+EWonrMyw54mZ67/1WP3oKF7QgTdK6cYArTdERuYxF9X7ngd9JXcVeW9/WYz/62jq42/w9lDzIA==",
|
||||
"version": "31.0.0",
|
||||
"resolved": "https://registry.npmjs.org/knub/-/knub-31.0.0.tgz",
|
||||
"integrity": "sha512-mm2PrtQ9G5UoELfJ4kjWaNQZZRMhwJbCf4FgJj92iDy4pg95XPNWAkwTw8avbkslNjb9m5Va1pp3IeJayvz/ag==",
|
||||
"dependencies": {
|
||||
"discord-api-types": "^0.37.10",
|
||||
"discord.js": "^14",
|
||||
|
@ -7199,9 +7199,9 @@
|
|||
}
|
||||
},
|
||||
"knub": {
|
||||
"version": "32.0.0-next.0",
|
||||
"resolved": "https://registry.npmjs.org/knub/-/knub-32.0.0-next.0.tgz",
|
||||
"integrity": "sha512-tT27Qr8qpge+EWonrMyw54mZ67/1WP3oKF7QgTdK6cYArTdERuYxF9X7ngd9JXcVeW9/WYz/62jq42/w9lDzIA==",
|
||||
"version": "31.0.0",
|
||||
"resolved": "https://registry.npmjs.org/knub/-/knub-31.0.0.tgz",
|
||||
"integrity": "sha512-mm2PrtQ9G5UoELfJ4kjWaNQZZRMhwJbCf4FgJj92iDy4pg95XPNWAkwTw8avbkslNjb9m5Va1pp3IeJayvz/ag==",
|
||||
"requires": {
|
||||
"discord-api-types": "^0.37.10",
|
||||
"discord.js": "^14",
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
"humanize-duration": "^3.15.0",
|
||||
"io-ts": "^2.0.0",
|
||||
"js-yaml": "^3.13.1",
|
||||
"knub": "^32.0.0-next.0",
|
||||
"knub": "^31.0.0",
|
||||
"knub-command-manager": "^9.1.0",
|
||||
"last-commit-log": "^2.1.0",
|
||||
"lodash.chunk": "^4.2.0",
|
||||
|
|
|
@ -354,6 +354,7 @@ connect().then(async () => {
|
|||
sendSuccessMessageFn(channel, body) {
|
||||
const guildId =
|
||||
channel instanceof TextChannel || channel instanceof ThreadChannel ? channel.guild.id : undefined;
|
||||
// @ts-expect-error
|
||||
const emoji = guildId ? bot.getLoadedGuild(guildId)!.config.success_emoji : undefined;
|
||||
channel.send(successMessage(body, emoji));
|
||||
},
|
||||
|
@ -361,6 +362,7 @@ connect().then(async () => {
|
|||
sendErrorMessageFn(channel, body) {
|
||||
const guildId =
|
||||
channel instanceof TextChannel || channel instanceof ThreadChannel ? channel.guild.id : undefined;
|
||||
// @ts-expect-error
|
||||
const emoji = guildId ? bot.getLoadedGuild(guildId)!.config.error_emoji : undefined;
|
||||
channel.send(errorMessage(body, emoji));
|
||||
},
|
||||
|
|
|
@ -93,6 +93,11 @@ export function strictValidationErrorToConfigValidationError(err: StrictValidati
|
|||
|
||||
export function getPluginConfigParser(blueprint: ZeppelinPlugin, customParser?: ZeppelinPlugin["configParser"]) {
|
||||
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
|
||||
const basicOptionsValidation = validate(BasicPluginStructureType, options);
|
||||
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) {
|
||||
options = await customParser(options);
|
||||
}
|
||||
|
@ -156,6 +161,7 @@ export function getPluginConfigParser(blueprint: ZeppelinPlugin, customParser?:
|
|||
? decodeAndValidateStrict(blueprint.configSchema, options.config)
|
||||
: options.config;
|
||||
if (decodedConfig instanceof StrictValidationError) {
|
||||
console.error("4.strict:", blueprint.name);
|
||||
throw strictValidationErrorToConfigValidationError(decodedConfig);
|
||||
}
|
||||
}
|
||||
|
@ -167,6 +173,7 @@ export function getPluginConfigParser(blueprint: ZeppelinPlugin, customParser?:
|
|||
? decodeAndValidateStrict(blueprint.configSchema, overrideConfigMergedWithBaseConfig)
|
||||
: overrideConfigMergedWithBaseConfig;
|
||||
if (decodedOverrideConfig instanceof StrictValidationError) {
|
||||
console.error("4.overrides.strict:", blueprint.name, options, decodedOverrideConfig);
|
||||
throw strictValidationErrorToConfigValidationError(decodedOverrideConfig);
|
||||
}
|
||||
decodedOverrides.push({
|
||||
|
@ -227,11 +234,13 @@ export async function sendErrorMessage(
|
|||
|
||||
export function getBaseUrl(pluginData: AnyPluginData<any>) {
|
||||
const knub = pluginData.getKnubInstance() as TZeppelinKnub;
|
||||
// @ts-expect-error
|
||||
return knub.getGlobalConfig().url;
|
||||
}
|
||||
|
||||
export function isOwner(pluginData: AnyPluginData<any>, userId: string) {
|
||||
const knub = pluginData.getKnubInstance() as TZeppelinKnub;
|
||||
// @ts-expect-error
|
||||
const owners = knub.getGlobalConfig()?.owners;
|
||||
if (!owners) {
|
||||
return false;
|
||||
|
|
|
@ -188,6 +188,7 @@ export const AutomodPlugin = zeppelinGuildPlugin<AutomodPluginType>()({
|
|||
info: pluginInfo,
|
||||
|
||||
// prettier-ignore
|
||||
// @ts-expect-error
|
||||
dependencies: () => [
|
||||
LogsPlugin,
|
||||
ModActionsPlugin,
|
||||
|
@ -256,7 +257,7 @@ export const AutomodPlugin = zeppelinGuildPlugin<AutomodPluginType>()({
|
|||
|
||||
pluginData.state.onMessageUpdateFn = (message) => runAutomodOnMessage(pluginData, message, true);
|
||||
pluginData.state.savedMessages.events.on("update", pluginData.state.onMessageUpdateFn);
|
||||
|
||||
// @ts-expect-error
|
||||
const countersPlugin = pluginData.getPlugin(CountersPlugin);
|
||||
|
||||
pluginData.state.onCounterTrigger = (name, triggerName, channelId, userId) => {
|
||||
|
@ -266,8 +267,9 @@ export const AutomodPlugin = zeppelinGuildPlugin<AutomodPluginType>()({
|
|||
pluginData.state.onCounterReverseTrigger = (name, triggerName, channelId, userId) => {
|
||||
runAutomodOnCounterTrigger(pluginData, name, triggerName, channelId, userId, true);
|
||||
};
|
||||
|
||||
// @ts-expect-error
|
||||
countersPlugin.onCounterEvent("trigger", pluginData.state.onCounterTrigger);
|
||||
// @ts-expect-error
|
||||
countersPlugin.onCounterEvent("reverseTrigger", pluginData.state.onCounterReverseTrigger);
|
||||
|
||||
const modActionsEvents = pluginData.getPlugin(ModActionsPlugin).getEventEmitter();
|
||||
|
@ -309,11 +311,14 @@ export const AutomodPlugin = zeppelinGuildPlugin<AutomodPluginType>()({
|
|||
},
|
||||
|
||||
async beforeUnload(pluginData) {
|
||||
// @ts-expect-error
|
||||
const countersPlugin = pluginData.getPlugin(CountersPlugin);
|
||||
if (pluginData.state.onCounterTrigger) {
|
||||
// @ts-expect-error
|
||||
countersPlugin.offCounterEvent("trigger", pluginData.state.onCounterTrigger);
|
||||
}
|
||||
if (pluginData.state.onCounterReverseTrigger) {
|
||||
// @ts-expect-error
|
||||
countersPlugin.offCounterEvent("reverseTrigger", pluginData.state.onCounterReverseTrigger);
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,9 @@ export const AddToCounterAction = automodAction({
|
|||
defaultConfig: {},
|
||||
|
||||
async apply({ pluginData, contexts, actionConfig, matchResult, ruleName }) {
|
||||
// @ts-expect-error
|
||||
const countersPlugin = pluginData.getPlugin(CountersPlugin);
|
||||
// @ts-expect-error
|
||||
if (!countersPlugin.counterExists(actionConfig.counter)) {
|
||||
pluginData.getPlugin(LogsPlugin).logBotAlert({
|
||||
body: `Unknown counter \`${actionConfig.counter}\` in \`add_to_counter\` action of Automod rule \`${ruleName}\``,
|
||||
|
@ -20,6 +22,7 @@ export const AddToCounterAction = automodAction({
|
|||
return;
|
||||
}
|
||||
|
||||
// @ts-expect-error
|
||||
countersPlugin.changeCounterValue(
|
||||
actionConfig.counter,
|
||||
contexts[0].message?.channel_id || null,
|
||||
|
|
|
@ -12,7 +12,9 @@ export const SetCounterAction = automodAction({
|
|||
defaultConfig: {},
|
||||
|
||||
async apply({ pluginData, contexts, actionConfig, matchResult, ruleName }) {
|
||||
// @ts-expect-error
|
||||
const countersPlugin = pluginData.getPlugin(CountersPlugin);
|
||||
// @ts-expect-error
|
||||
if (!countersPlugin.counterExists(actionConfig.counter)) {
|
||||
pluginData.getPlugin(LogsPlugin).logBotAlert({
|
||||
body: `Unknown counter \`${actionConfig.counter}\` in \`add_to_counter\` action of Automod rule \`${ruleName}\``,
|
||||
|
@ -20,6 +22,7 @@ export const SetCounterAction = automodAction({
|
|||
return;
|
||||
}
|
||||
|
||||
// @ts-expect-error
|
||||
countersPlugin.setCounterValue(
|
||||
actionConfig.counter,
|
||||
contexts[0].message?.channel_id || null,
|
||||
|
|
|
@ -14,9 +14,11 @@ export async function runAutomodOnCounterTrigger(
|
|||
) {
|
||||
const user = userId ? await resolveUser(pluginData.client, userId) : undefined;
|
||||
const member = (userId && (await resolveMember(pluginData.client, pluginData.guild, userId))) || undefined;
|
||||
|
||||
// @ts-expect-error
|
||||
const prettyCounterName = pluginData.getPlugin(CountersPlugin).getPrettyNameForCounter(counterName);
|
||||
// @ts-expect-error
|
||||
const prettyTriggerName = pluginData
|
||||
// @ts-expect-error
|
||||
.getPlugin(CountersPlugin)
|
||||
.getPrettyNameForCounterTrigger(counterName, triggerName);
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@ export const HelpCmd = utilityCmd({
|
|||
if (strTrigger.startsWith(searchStr)) {
|
||||
matchingCommands.push({
|
||||
plugin,
|
||||
// @ts-expect-error
|
||||
command: registeredCommand,
|
||||
});
|
||||
break;
|
||||
|
|
|
@ -136,6 +136,7 @@ export async function getMessageInfoEmbed(
|
|||
}
|
||||
|
||||
if (message.embeds.length) {
|
||||
// @ts-expect-error
|
||||
const prefix = pluginData.fullConfig.prefix || getDefaultPrefix(pluginData.client);
|
||||
embed.fields.push({
|
||||
name: preEmbedPadding + "Embeds",
|
||||
|
|
|
@ -54,7 +54,7 @@ export function zeppelinGuildPlugin(...args) {
|
|||
const blueprint = guildPlugin(
|
||||
...(args as Parameters<typeof guildPlugin>),
|
||||
) as unknown as ZeppelinGuildPluginBlueprint;
|
||||
blueprint.configParser = getPluginConfigParser(blueprint, blueprint.configParser);
|
||||
blueprint.configParser = <any>getPluginConfigParser(blueprint, blueprint.configParser);
|
||||
return blueprint;
|
||||
} else {
|
||||
return zeppelinGuildPlugin as (name, blueprint) => ZeppelinGuildPluginBlueprint;
|
||||
|
@ -89,7 +89,7 @@ export function zeppelinGlobalPlugin(...args) {
|
|||
const blueprint = globalPlugin(
|
||||
...(args as Parameters<typeof globalPlugin>),
|
||||
) 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);
|
||||
return blueprint;
|
||||
} else {
|
||||
|
|
Loading…
Add table
Reference in a new issue