import { type ChannelDoctorAdapter } from "openclaw/plugin-sdk/channel-contract"; import { type OpenClawConfig } from "openclaw/plugin-sdk/config-runtime"; import { collectProviderDangerousNameMatchingScopes } from "openclaw/plugin-sdk/runtime-doctor"; import { normalizeOptionalString } from "openclaw/plugin-sdk/text-runtime"; import { normalizeCompatibilityConfig as normalizeDiscordCompatibilityConfig } from "./doctor-contract.js"; import { DISCORD_LEGACY_CONFIG_RULES } from "./doctor-shared.js"; import { isDiscordMutableAllowEntry } from "./security-doctor.js";
for (const scope of collectDiscordAccountScopes(cfg)) { for (const ref of collectDiscordIdLists(scope.prefix, scope.account)) {
scanList(ref.pathLabel, ref.holder[ref.key]);
}
} return hits;
}
export function collectDiscordNumericIdWarnings(params: {
hits: DiscordNumericIdHit[];
doctorFixCommand: string;
}): string[] { if (params.hits.length === 0) { return [];
} const hitsByListPath = new Map<string, DiscordNumericIdHit[]>(); for (const hit of params.hits) { const listPath = hit.path.replace(/\[\d+\]$/, ""); const existing = hitsByListPath.get(listPath); if (existing) {
existing.push(hit);
} else {
hitsByListPath.set(listPath, [hit]);
}
}
const repairableHits: DiscordNumericIdHit[] = []; const blockedHits: DiscordNumericIdHit[] = []; for (const hits of hitsByListPath.values()) { if (hits.some((hit) => !hit.safe)) {
blockedHits.push(...hits);
} else {
repairableHits.push(...hits);
}
}
const lines: string[] = []; if (repairableHits.length > 0) { const sample = repairableHits[0];
lines.push(
`- Discord allowlists contain ${repairableHits.length} numeric ${repairableHits.length === 1 ? "entry" : "entries"} (e.g. ${sanitizeForLog(sample.path)}=${sanitizeForLog(String(sample.entry))}).`,
`- Discord IDs must be strings; run "${params.doctorFixCommand}" to convert numeric IDs to quoted strings.`,
);
} if (blockedHits.length > 0) { const sample = blockedHits[0];
lines.push(
`- Discord allowlists contain ${blockedHits.length} numeric ${blockedHits.length === 1 ? "entry" : "entries"} in lists that cannot be auto-repaired (e.g. ${sanitizeForLog(sample.path)}).`,
`- These lists include invalid or precision-losing numeric IDs; manually quote the original values in your config file, then rerun "${params.doctorFixCommand}".`,
);
} return lines;
}
for (const scope of collectDiscordAccountScopes(next)) { for (const ref of collectDiscordIdLists(scope.prefix, scope.account)) {
repairList(ref.pathLabel, ref.holder, ref.key);
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.