Read SQUID release settings and protect imported repack binaries

This commit is contained in:
Дмитрий committed 2026-10-05 16:56:46 +05:00
1 parent cd3a963f70
commit f8301d7394
23 files changed
+257 -23

No files matched your search

+1
View File
@@ -75,6 +75,7 @@ const de: Partial<Record<keyof typeof en, string>> = {
"btn.restart": "Neustart",
"btn.startWithoutUpdate": "Ohne Update starten",
"btn.playWithoutUpdate": "Ohne Update spielen",
"import.squidRepackWarning": "Dieses SquidBots-Repack prüft den Worldserver-Hash. Ein Austausch kann Start_All_Bots und coa_update deaktivieren. Updates fragen vorher nach.",
"btn.play": "SPIELEN",
"btn.startPlay": "STARTEN & SPIELEN",
"btn.startingCaps": "STARTET …",
+1
View File
@@ -106,6 +106,7 @@ const en = {
"btn.restart": "Restart",
"btn.startWithoutUpdate": "Start without updating",
"btn.playWithoutUpdate": "Play without updating",
"import.squidRepackWarning": "This SquidBots repack checks its worldserver hash. Replacing the binary can stop Start_All_Bots and coa_update from working. Updates will ask before replacing it.",
"btn.play": "PLAY",
"btn.startPlay": "START & PLAY",
"btn.startingCaps": "STARTING…",
+1
View File
@@ -75,6 +75,7 @@ const es: Partial<Record<keyof typeof en, string>> = {
"btn.restart": "Reiniciar",
"btn.startWithoutUpdate": "Iniciar sin actualizar",
"btn.playWithoutUpdate": "Jugar sin actualizar",
"import.squidRepackWarning": "Este repack SquidBots verifica el hash del servidor. Sustituirlo puede impedir el funcionamiento de Start_All_Bots y coa_update. Se solicitará confirmación.",
"btn.play": "JUGAR",
"btn.startPlay": "INICIAR Y JUGAR",
"btn.startingCaps": "INICIANDO…",
+1
View File
@@ -75,6 +75,7 @@ const fr: Partial<Record<keyof typeof en, string>> = {
"btn.restart": "Redémarrer",
"btn.startWithoutUpdate": "Démarrer sans mise à jour",
"btn.playWithoutUpdate": "Jouer sans mise à jour",
"import.squidRepackWarning": "Ce repack SquidBots vérifie le hash du serveur. Le remplacer peut empêcher Start_All_Bots et coa_update de fonctionner. Une confirmation sera demandée.",
"btn.play": "JOUER",
"btn.startPlay": "DÉMARRER ET JOUER",
"btn.startingCaps": "DÉMARRAGE…",
+1
View File
@@ -106,6 +106,7 @@ const ru: Partial<Record<keyof typeof en, string>> = {
"btn.restart": "Перезапустить",
"btn.startWithoutUpdate": "Запустить без обновления",
"btn.playWithoutUpdate": "Играть без обновления",
"import.squidRepackWarning": "Этот репак SquidBots проверяет хеш worldserver. Замена файла может нарушить работу Start_All_Bots и coa_update. Перед заменой менеджер запросит ваше решение.",
"btn.play": "ИГРАТЬ",
"btn.startPlay": "ЗАПУСТИТЬ И ИГРАТЬ",
"btn.startingCaps": "ЗАПУСК…",
+1
View File
@@ -87,6 +87,7 @@ const zh = {
"btn.restart": "重启",
"btn.startWithoutUpdate": "不更新启动服务器",
"btn.playWithoutUpdate": "不更新开始游戏",
"import.squidRepackWarning": "此 SquidBots 整合包会检查 worldserver 哈希。替换程序可能导致 Start_All_Bots 和 coa_update 无法运行。更新前会要求您选择。",
"btn.play": "开始游戏",
"btn.startPlay": "启动并开始游戏",
"btn.startingCaps": "正在启动…",
+2
View File
@@ -193,6 +193,7 @@ export interface RealmProfile {
export interface ModuleView {
id: string;
name: string;
version?: string | null;
description: Record<string, string>;
repo: string;
/** the module is part of this server build (its configuration exists) */
@@ -216,6 +217,7 @@ export interface ModuleSetting {
value: string;
default: string | null;
doc: string;
field?: { key: string; type: string; title: string; description: string; group: string; group_title?: string | null; min?: number | null; max?: number | null } | null;
}
export interface AllSetting {
+2 -1
View File
@@ -173,7 +173,8 @@ for (const [category, categoryNames] of Object.entries(auctionCategories)) {
{ min: 0, max: 1000, advanced: true },
);
}
export function moduleField(key: string, locale: Locale): ModuleField | undefined {
export function moduleField(key: string, locale: Locale, metadata?: ModuleSetting["field"]): ModuleField | undefined {
if (metadata) return { title: metadata.title, description: metadata.description, type: metadata.type, category: metadata.group, advanced: false, min: metadata.min ?? undefined, max: metadata.max ?? undefined };
const field = fields.find(f => f.key === key);
if (field) return { ...field, title: text(field.title, locale), description: text(field.description, locale), category: "general", advanced: field.advanced ?? false, step: field.type === "range" ? 0.05 : undefined, options: field.options?.map(o => ({ value: o.value, label: text(o.label, locale) })) };
const existing = [...bots.settings, ...server.settings].find(s => s.key === key);
+5 -3
View File
@@ -24,7 +24,7 @@ function group(key: string, curated: boolean) {
/** Use the same settings screen as Companions, backed only by shipped SQUID options. */
export function squidSettingsView(items: ModuleSetting[], locale: Locale): SettingsView {
const settings: SettingView[] = items.filter(s => s.key !== "AiPlayerbot.Enabled" && !s.key.startsWith("PlayerbotsDatabase") && !s.key.startsWith("Playerbots.Updates.")).map(s => {
const field = moduleField(s.key, locale);
const field = moduleField(s.key, locale, s.field);
const type = field?.type === "bool" || field?.type === "int" || field?.type === "float" || field?.type === "enum" ? field.type : "string";
const decode = (raw: string): JsonValue => {
const value = raw.trim().replace(/^"|"$/g, "");
@@ -35,11 +35,13 @@ export function squidSettingsView(items: ModuleSetting[], locale: Locale): Setti
const value = decode(s.value), defaultValue = decode(s.default ?? s.value);
return {
key: s.key, type, title: field?.title ?? s.key, description: field?.description ?? s.doc,
category: group(s.key, !!field), advanced: !field || !!field.advanced,
category: s.field?.group ? "squid." + s.field.group : group(s.key, !!field), advanced: !field || !!field.advanced,
min: field?.min, max: field?.max, options: field?.options ?? [],
value, default: defaultValue, is_default: value === defaultValue, present: true, problem: null,
drift: false, restartRequired: "world", dangerous: false,
};
});
return { scope: "bots", categories: groups.map(g => ({ id: g.id, title: g.titles[languages.indexOf(locale)] })), settings, unknown_keys: 0, drift_keys: [], files: ["Core/configs/modules/playerbots.conf"] };
const categories = new Map(groups.map(g => [g.id, g.titles[languages.indexOf(locale)]]));
for (const item of items) if (item.field?.group) categories.set("squid." + item.field.group, item.field.group_title ?? categories.get("squid." + item.field.group) ?? item.field.group);
return { scope: "bots", categories: [...categories].map(([id, title]) => ({ id, title })), settings, unknown_keys: 0, drift_keys: [], files: ["Core/configs/modules/playerbots.conf"] };
}
+1 -1
View File
@@ -145,7 +145,7 @@ export function ImportServer(props: {
{report.notes.map((n) => (
<p key={n} className="mt-3 text-sm text-warn">
{n}
{hasKey(n) ? t(n as Key) : n}
</p>
))}
+9 -8
View File
@@ -133,6 +133,7 @@ export function ModulesPage({ serverId, onChanged }: { serverId: string; onChang
<div className="min-w-0 flex-1">
<div className="flex flex-wrap items-center gap-x-2 gap-y-1">
<h2 className="font-semibold leading-tight">{m.name}</h2>
{m.version && <span className="ml-2 text-xs font-normal text-muted">{m.version}</span>}
<StatusBadge status={m.status} />
</div>
<p className="mt-1.5 line-clamp-2 text-sm text-muted">{m.description[locale] ?? m.description.en}</p>
@@ -210,7 +211,7 @@ function ModuleSettings({ serverId, module, onSaved }: { serverId: string; modul
async function save() {
const errors: Record<string, string> = {};
for (const [key, value] of Object.entries(edits)) {
const field = moduleField(key, locale);
const field = moduleField(key, locale, items?.find(item => item.key === key)?.field);
if (field && ["int", "float", "range"].includes(field.type)) {
const number = Number(value);
const message = !value.trim() || !Number.isFinite(number) ? t("set.enterNumber")
@@ -248,13 +249,13 @@ function ModuleSettings({ serverId, module, onSaved }: { serverId: string; modul
return next;
});
const available = items?.filter(s => s.key !== moduleEnableKey(module.id)) ?? [];
const advancedCount = available.filter(s => !auctionWeightKey(s.key) && (!moduleField(s.key, locale) || moduleField(s.key, locale)?.advanced)).length;
const advancedCount = available.filter(s => !auctionWeightKey(s.key) && (!moduleField(s.key, locale, s.field) || moduleField(s.key, locale, s.field)?.advanced)).length;
const visible = available.filter(s => {
if (module.id === "ah-bot" && auctionWeightKey(s.key)) return false;
const field = moduleField(s.key, locale);
const field = moduleField(s.key, locale, s.field);
if (!advanced && !query.trim() && (!field || field.advanced)) return false;
const title = field ? sx.title({ key: s.key, title: field.title }) : s.key;
const description = field ? sx.description({ key: s.key, description: field.description }) : s.doc;
const title = field ? (s.field ? field.title : sx.title({ key: s.key, title: field.title })) : s.key;
const description = field ? (s.field ? field.description : sx.description({ key: s.key, description: field.description })) : s.doc;
return `${title} ${description} ${s.key}`.toLocaleLowerCase(locale).includes(query.trim().toLocaleLowerCase(locale));
});
return (
@@ -278,9 +279,9 @@ function ModuleSettings({ serverId, module, onSaved }: { serverId: string; modul
{items && !visible.length && !available.some(s => module.id === "ah-bot" && auctionWeightKey(s.key)) && <p className="py-3 text-sm text-muted">{t(available.length ? "all.none" : "mod.noSettings")}</p>}
<ul className="divide-y divide-line">
{visible.map((s) => {
const field = moduleField(s.key, locale);
const title = field ? sx.title({ key: s.key, title: field.title }) : s.key;
const description = field ? sx.description({ key: s.key, description: field.description }) : s.doc;
const field = moduleField(s.key, locale, s.field);
const title = field ? (s.field ? field.title : sx.title({ key: s.key, title: field.title })) : s.key;
const description = field ? (s.field ? field.description : sx.description({ key: s.key, description: field.description })) : s.doc;
const value = edits[s.key] ?? s.value;
const normalized = canonicalModuleValue(s.key, value);
const options = field?.options ?? [];
+5 -2
View File
@@ -178,12 +178,15 @@ export function SettingsPage(props: { serverId: string; scope: Scope; botModule?
const [raw, setRaw] = useState<AllSetting[] | null>(null);
const [rawEdits, setRawEdits] = useState<Record<string, string>>({});
const [onlyChanged, setOnlyChanged] = useState(false);
const [squidVersion, setSquidVersion] = useState<string | null>(null);
const [cols, setCols] = useState<ModuleSetting[]>([]);
const [colEdits, setColEdits] = useState<Record<string, string>>({});
const load = useCallback(async () => {
try {
const v = squid ? squidSettingsView(await api.moduleSettings(serverId, "playerbots"), locale) : await api.settings(serverId, scope);
const data = squid ? await Promise.all([api.moduleSettings(serverId, "playerbots"), api.modulesList(serverId)]) : null;
if (data) setSquidVersion(data[1].find(module => module.id === "playerbots")?.version ?? null);
const v = data ? squidSettingsView(data[0], locale) : await api.settings(serverId, scope);
setView(v);
setDraft({});
setErrors({});
@@ -363,7 +366,7 @@ export function SettingsPage(props: { serverId: string; scope: Scope; botModule?
return (
<div className="max-w-3xl pb-24">
<h1 className="text-2xl font-semibold">{props.title}</h1>
<p className="mt-1 text-muted">{squid ? "SQUID’s Playerbots" : props.question}</p>
<p className="mt-1 text-muted">{squid ? `SQUID’s Playerbots${squidVersion ? " · " + squidVersion : ""}` : props.question}</p>
{scope === "bots" && !squid && <CompanionsCard serverId={serverId} />}