Queue repo Face rumination jobs
This commit is contained in:
parent
ed36561c8d
commit
32b96ce575
14 changed files with 465 additions and 5 deletions
|
|
@ -101,6 +101,7 @@ const envSchema = z.object({
|
|||
.string()
|
||||
.min(1)
|
||||
.default(".voidbot/private/repo-discord-identities.json"),
|
||||
REPO_FACE_RUMINATION_PASSES: z.coerce.number().int().min(0).max(6).default(3),
|
||||
INDEX_ALL_CHANNELS: booleanFromEnv.default(false),
|
||||
INDEXED_CHANNEL_IDS: z.string().default(""),
|
||||
EXCLUDED_CHANNEL_IDS: z.string().default(""),
|
||||
|
|
@ -135,6 +136,7 @@ export interface AppConfig {
|
|||
systemMessagesPath: string;
|
||||
moderationAgentStatePath: string;
|
||||
repoDiscordIdentitiesPath: string;
|
||||
repoFaceRuminationPasses: number;
|
||||
indexAllChannels: boolean;
|
||||
indexedChannelIds: string[];
|
||||
excludedChannelIds: string[];
|
||||
|
|
@ -309,6 +311,7 @@ export function loadConfig(env: NodeJS.ProcessEnv = process.env): AppConfig {
|
|||
systemMessagesPath: resolve(parsed.SYSTEM_MESSAGES_PATH),
|
||||
moderationAgentStatePath: resolve(parsed.MODERATION_AGENT_STATE_PATH),
|
||||
repoDiscordIdentitiesPath: resolve(parsed.REPO_DISCORD_IDENTITIES_PATH),
|
||||
repoFaceRuminationPasses: parsed.REPO_FACE_RUMINATION_PASSES,
|
||||
indexAllChannels: parsed.INDEX_ALL_CHANNELS,
|
||||
indexedChannelIds,
|
||||
excludedChannelIds,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { readFile } from "node:fs/promises";
|
||||
import { resolve } from "node:path";
|
||||
|
||||
import { z } from "zod";
|
||||
|
||||
|
|
@ -9,6 +10,7 @@ const repoDiscordIdentitySchema = z.object({
|
|||
roleId: z.string().trim().min(1).optional(),
|
||||
allowedChannelIds: z.array(z.string().trim().min(1)).default([]),
|
||||
avatarUrl: z.string().trim().url().max(512).optional(),
|
||||
faceStatePath: z.string().trim().min(1).optional(),
|
||||
description: z.string().trim().min(1).optional(),
|
||||
});
|
||||
|
||||
|
|
@ -88,6 +90,17 @@ export function isRepoDiscordIdentityAllowedInChannel(
|
|||
return identity.allowedChannelIds.length === 0 || identity.allowedChannelIds.includes(channelId);
|
||||
}
|
||||
|
||||
export function resolveRepoFaceStatePath(
|
||||
identity: RepoDiscordIdentity,
|
||||
storageRoot: string,
|
||||
): string {
|
||||
if (identity.faceStatePath) {
|
||||
return resolve(identity.faceStatePath);
|
||||
}
|
||||
|
||||
return resolve(storageRoot, "private", "repo-faces", `${sanitizePathSegment(identity.id)}.cc`);
|
||||
}
|
||||
|
||||
function normalizeRepoDiscordIdentities(
|
||||
identities: RepoDiscordIdentity[],
|
||||
): RepoDiscordIdentity[] {
|
||||
|
|
@ -110,11 +123,20 @@ function normalizeRepoDiscordIdentities(
|
|||
roleId: identity.roleId?.trim(),
|
||||
allowedChannelIds: [...new Set(identity.allowedChannelIds.map((entry) => entry.trim()))],
|
||||
avatarUrl: identity.avatarUrl?.trim(),
|
||||
faceStatePath: identity.faceStatePath?.trim(),
|
||||
description: identity.description?.trim(),
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
function sanitizePathSegment(value: string): string {
|
||||
return value
|
||||
.trim()
|
||||
.toLowerCase()
|
||||
.replace(/[^a-z0-9._-]+/g, "-")
|
||||
.replace(/^-+|-+$/g, "") || "repo-face";
|
||||
}
|
||||
|
||||
function normalizeIdentityKey(value: string): string {
|
||||
return value.trim().toLowerCase();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ export const commandNames = [
|
|||
"reindex-channel",
|
||||
"set-style",
|
||||
"repo-identity-mention",
|
||||
"repo-face-rumination",
|
||||
] as const;
|
||||
|
||||
export type CommandName = (typeof commandNames)[number];
|
||||
|
|
|
|||
Loading…
Reference in a new issue