From d2496603e74b1789c8ebc0f592832c051351036d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=BC=D0=B8=D1=82=D1=80=D0=B8=D0=B9?= Date: Sun, 4 Oct 2026 20:40:36 +0500 Subject: [PATCH] Configure both bot systems exclusively in the shared Bots tab --- changelog.d/20261004-squid-playerbots.md | 2 +- modules/catalog.json | 3 +- src/dev/mock.ts | 2 +- src/lib/squidSettings.ts | 45 ++++++++++++++++++++++++ src/screens/ModulesPage.tsx | 4 +-- src/screens/SettingsPage.tsx | 27 ++++++++------ src/screens/Shell.tsx | 11 ++++-- tools/check-module-settings.mjs | 22 ++++++++++++ 8 files changed, 98 insertions(+), 18 deletions(-) create mode 100644 src/lib/squidSettings.ts diff --git a/changelog.d/20261004-squid-playerbots.md b/changelog.d/20261004-squid-playerbots.md index 3fd45e4..a77e5b1 100644 --- a/changelog.d/20261004-squid-playerbots.md +++ b/changelog.d/20261004-squid-playerbots.md @@ -4,4 +4,4 @@ type: added audience: admins title: Configure SQUID Playerbots and prevent conflicting bot systems --- -SQUID Playerbots has translated controls for its existing settings. Enable one bot system at a time; the Manager checks manual config changes before starting the server. Recovery points also include the SQUID database when installed. +The Bots tab shows translated settings for the active bot system. Bot module cards only offer enable switches, without duplicate settings. Enable one bot system at a time; the Manager checks manual config changes before starting the server. Recovery points also include the SQUID database when installed. diff --git a/modules/catalog.json b/modules/catalog.json index 5ad4ff1..e1db3bf 100644 --- a/modules/catalog.json +++ b/modules/catalog.json @@ -118,7 +118,8 @@ "status": "early", "icon": "swords", "enable_key": "AiPlayerbot.Enabled", - "default_on": false + "default_on": false, + "page": "bots" }, { "id": "client-compat", diff --git a/src/dev/mock.ts b/src/dev/mock.ts index ba417f5..74d1a79 100644 --- a/src/dev/mock.ts +++ b/src/dev/mock.ts @@ -65,7 +65,7 @@ export {}; if(cmd==="realmlist_save"){const w=window as any;const rl=w.__rl;if(args.profileId){const p=rl.profiles.find((x: any)=>x.id===args.profileId);p.name=args.name;p.data=args.data;return p;}if(rl.profiles.some((x: any)=>x.name.toLowerCase()===String(args.name).toLowerCase()))throw {human:{code:"unknown",title:"",message:"",actions:[]},technical:"A realmlist with that name already exists."};const p={id:String(args.name).toLowerCase().replace(/[^a-z0-9]+/g,"-"),name:args.name,data:(/\s/.test(args.data.trim())?args.data.trim():"set realmlist "+args.data.trim())+"\r\n"};rl.profiles.push(p);return p;} if(cmd==="realmlist_delete"){const rl=(window as any).__rl;rl.profiles=rl.profiles.filter((x: any)=>x.id!==args.profileId);return null;} if(cmd==="account_delete") return null; - if(cmd==="modules_list") return [{id:"companions",name:"CoA Companions",description:{en:"Companion bots for groups, dungeons and your guild.",ru:"Боты-компаньоны для групп, подземелий и гильдии."},repo:"https://github.com/Corfirean/mod-coa-playerbots",installed:true,enabled:modState["companions"],switchable:true,status:"beta",icon:"bot",page:"bots"},{id:"content-scaling",name:"Content Scaling",description:{en:"Scales dungeons and raids to your group, with solo modes.",ru:"Подстраивает подземелья и рейды под вашу группу, есть соло-режимы."},repo:"https://github.com/Corfirean/mod-coa-content-scaling",installed:true,enabled:modState["content-scaling"],switchable:true,status:"early",icon:"scaling",page:null},{id:"tbc-content",name:"TBC Content",description:{en:"Outland dungeons and raids, scaled to your level range.",ru:"Подземелья и рейды Запределья, подогнанные под ваши уровни."},repo:"https://github.com/Corfirean/mod-coa-content-scaling/tree/main/content-packs/mod-coa-tbc-content",installed:true,enabled:modState["tbc-content"],switchable:true,status:"early",icon:"tbc",page:null},{id:"wotlk-content",name:"WotLK Content",description:{en:"Northrend dungeons and raids, scaled to your level range.",ru:"Подземелья и рейды Нордскола, подогнанные под ваши уровни."},repo:"https://github.com/Corfirean/mod-coa-content-scaling/tree/main/content-packs/mod-coa-wotlk-content",installed:true,enabled:modState["wotlk-content"],switchable:true,status:"early",icon:"wotlk",page:null},{id:"ah-bot",name:"Auction House Bot",description:{en:"Fills the auction house with realistic, adjustable listings.",ru:"Наполняет аукцион реалистичными настраиваемыми лотами."},repo:"https://github.com/Corfirean/azerothcore-wotlk-coa",installed:true,enabled:modState["ah-bot"] ?? false,switchable:true,status:"early",icon:"gavel",page:null,hidden:false},{id:"npc-enchanter",name:"NPC Enchanter",description:{en:"An NPC that enchants your gear for you.",ru:"НПС, который зачаровывает ваше снаряжение."},repo:"https://github.com/azerothcore/mod-npc-enchanter",installed:true,enabled:modState["npc-enchanter"],switchable:true,status:"early",icon:"sparkles",page:null,hidden:false},{id:"playerbots",name:"SQUID's Playerbots",description:{en:"An alternative bot system with random bots and full AI.",ru:"Альтернативная система ботов со случайными ботами и полным ИИ."},repo:"https://github.com/Zyth45/mod-playerbots",installed:true,enabled:modState["playerbots"] ?? false,switchable:true,status:"early",icon:"swords",page:null,hidden:false},{id:"client-compat",name:"Client compatibility",description:{en:"Client-server link and appearance unlocks.",ru:"Связь клиента с сервером и разблокировка внешних видов."},repo:"https://github.com/Corfirean/azerothcore-wotlk-coa",installed:true,enabled:modState["client-compat"],switchable:false,status:"release",icon:"plug",page:null,hidden:true}].map(m => ({...m, has_settings: !["tbc-content", "wotlk-content"].includes(m.id), compatibility: realm === "wildcard" ? (["companions", "playerbots"].includes(m.id) ? "unsupported" : m.id === "client-compat" ? "compatible" : "experimental") : "compatible", switchable: realm === "wildcard" && ["companions", "playerbots"].includes(m.id) ? false : m.switchable})); + if(cmd==="modules_list") return [{id:"companions",name:"CoA Companions",description:{en:"Companion bots for groups, dungeons and your guild.",ru:"Боты-компаньоны для групп, подземелий и гильдии."},repo:"https://github.com/Corfirean/mod-coa-playerbots",installed:true,enabled:modState["companions"],switchable:true,status:"beta",icon:"bot",page:"bots"},{id:"content-scaling",name:"Content Scaling",description:{en:"Scales dungeons and raids to your group, with solo modes.",ru:"Подстраивает подземелья и рейды под вашу группу, есть соло-режимы."},repo:"https://github.com/Corfirean/mod-coa-content-scaling",installed:true,enabled:modState["content-scaling"],switchable:true,status:"early",icon:"scaling",page:null},{id:"tbc-content",name:"TBC Content",description:{en:"Outland dungeons and raids, scaled to your level range.",ru:"Подземелья и рейды Запределья, подогнанные под ваши уровни."},repo:"https://github.com/Corfirean/mod-coa-content-scaling/tree/main/content-packs/mod-coa-tbc-content",installed:true,enabled:modState["tbc-content"],switchable:true,status:"early",icon:"tbc",page:null},{id:"wotlk-content",name:"WotLK Content",description:{en:"Northrend dungeons and raids, scaled to your level range.",ru:"Подземелья и рейды Нордскола, подогнанные под ваши уровни."},repo:"https://github.com/Corfirean/mod-coa-content-scaling/tree/main/content-packs/mod-coa-wotlk-content",installed:true,enabled:modState["wotlk-content"],switchable:true,status:"early",icon:"wotlk",page:null},{id:"ah-bot",name:"Auction House Bot",description:{en:"Fills the auction house with realistic, adjustable listings.",ru:"Наполняет аукцион реалистичными настраиваемыми лотами."},repo:"https://github.com/Corfirean/azerothcore-wotlk-coa",installed:true,enabled:modState["ah-bot"] ?? false,switchable:true,status:"early",icon:"gavel",page:null,hidden:false},{id:"npc-enchanter",name:"NPC Enchanter",description:{en:"An NPC that enchants your gear for you.",ru:"НПС, который зачаровывает ваше снаряжение."},repo:"https://github.com/azerothcore/mod-npc-enchanter",installed:true,enabled:modState["npc-enchanter"],switchable:true,status:"early",icon:"sparkles",page:null,hidden:false},{id:"playerbots",name:"SQUID's Playerbots",description:{en:"An alternative bot system with random bots and full AI.",ru:"Альтернативная система ботов со случайными ботами и полным ИИ."},repo:"https://github.com/Zyth45/mod-playerbots",installed:true,enabled:modState["playerbots"] ?? false,switchable:true,status:"early",icon:"swords",page:"bots",hidden:false},{id:"client-compat",name:"Client compatibility",description:{en:"Client-server link and appearance unlocks.",ru:"Связь клиента с сервером и разблокировка внешних видов."},repo:"https://github.com/Corfirean/azerothcore-wotlk-coa",installed:true,enabled:modState["client-compat"],switchable:false,status:"release",icon:"plug",page:null,hidden:true}].map(m => ({...m, has_settings: !["tbc-content", "wotlk-content"].includes(m.id), compatibility: realm === "wildcard" ? (["companions", "playerbots"].includes(m.id) ? "unsupported" : m.id === "client-compat" ? "compatible" : "experimental") : "compatible", switchable: realm === "wildcard" && ["companions", "playerbots"].includes(m.id) ? false : m.switchable})); if(cmd==="module_set_enabled"){ if(args.enabled && ["companions","playerbots"].includes(args.module) && modState[args.module === "companions" ? "playerbots" : "companions"]) throw {human:{code:"bot_modules_conflict",title:"",message:"",actions:[]},technical:"Only one bot system may be enabled."}; modState[args.module]=args.enabled; return null; } if(cmd==="all_settings") return [{key:"Visibility.Distance.Continents",value:"100",default:"90",doc:"Description: Visibility distance on continents. Range: 45-250 Default: 90",changed:true},{key:"Death.SicknessLevel",value:"11",default:"11",doc:"Description: Character level up to which characters get resurrection sickness. Default: 11",changed:false},{key:"Rate.Drop.Item.Epic",value:"3",default:"1",doc:"Description: Drop rates for money and items based on quality. Default: 1",changed:true},{key:"Instance.ResetTimeHour",value:"4",default:"4",doc:"Description: Hour of the day when the global instance reset occurs. Range: 0-23 Default: 4 - (04:00 AM)",changed:false},{key:"PlayerLimit",value:"1000",default:"1000",doc:"Description: Maximum number of players in the world.",changed:false}]; if(cmd==="all_settings_save") return Object.keys(args&&args.changes||{}); diff --git a/src/lib/squidSettings.ts b/src/lib/squidSettings.ts new file mode 100644 index 0000000..b7a2fd7 --- /dev/null +++ b/src/lib/squidSettings.ts @@ -0,0 +1,45 @@ +import type { JsonValue, ModuleSetting, SettingsView, SettingView } from "@/lib/api"; +import type { Locale } from "@/i18n"; +import { moduleField } from "@/lib/moduleSettings"; + +const languages: Locale[] = ["en", "ru", "de", "fr", "es", "zh"]; +const groups = [ + { id: "squid.population", titles: ["Population", "Население мира", "Bevölkerung", "Population", "Población", "世界人口"] }, + { id: "squid.party", titles: ["Groups", "Группы", "Gruppen", "Groupes", "Grupos", "队伍"] }, + { id: "squid.combat", titles: ["Combat", "Бой", "Kampf", "Combat", "Combate", "战斗"] }, + { id: "squid.activities", titles: ["Dungeons and PvP", "Подземелья и PvP", "Dungeons und PvP", "Donjons et JcJ", "Mazmorras y JcJ", "地下城与PvP"] }, + { id: "squid.chat", titles: ["Chat", "Общение", "Chat", "Discussion", "Chat", "聊天"] }, + { id: "squid.other", titles: ["Other settings", "Другие настройки", "Weitere Einstellungen", "Autres réglages", "Otros ajustes", "其他设置"] }, +]; + +function group(key: string, curated: boolean) { + if (!curated) return "squid.other"; + if (/Talk|Emote|Suggest/.test(key)) return "squid.chat"; + if (/Lfg|JoinBG/.test(key)) return "squid.activities"; + if (/Smart|SpecRotations|Interrupt/.test(key)) return "squid.combat"; + if (/AddedBots|BotAutologin$|Invite|AddClassCommand|KeepAlts|Recruit|FollowDistance/.test(key) && !key.endsWith("RandomBotAutologin")) return "squid.party"; + return "squid.population"; +} + +/** 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 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, ""); + if (type === "bool") return !["0", "false", "no", "off"].includes(value.toLowerCase()); + if (type === "int" || type === "float") return Number(value); + return value; + }; + 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, + 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"] }; +} diff --git a/src/screens/ModulesPage.tsx b/src/screens/ModulesPage.tsx index 4a7123d..c3da379 100644 --- a/src/screens/ModulesPage.tsx +++ b/src/screens/ModulesPage.tsx @@ -162,7 +162,7 @@ export function ModulesPage({ serverId, onChanged }: { serverId: string; onChang > - {m.installed && m.has_settings && m.status !== "soon" && m.compatibility !== "unsupported" && ( + {!m.page && m.installed && m.has_settings && m.status !== "soon" && m.compatibility !== "unsupported" && ( @@ -170,7 +170,7 @@ export function ModulesPage({ serverId, onChanged }: { serverId: string; onChang {/* The settings open right under the row of the card they belong to, so they are never out of sight below a long grid. */} - {selected?.has_settings && selectedAt >= 0 && Math.floor(selectedAt / 2) === Math.floor(i / 2) && (i % 2 === 1 || i === modules.length - 1) && ( + {selected?.has_settings && !selected.page && selectedAt >= 0 && Math.floor(selectedAt / 2) === Math.floor(i / 2) && (i % 2 === 1 || i === modules.length - 1) && (

{t("mod.settingsOf", { name: selected.name })}

setChanged(true)} /> diff --git a/src/screens/SettingsPage.tsx b/src/screens/SettingsPage.tsx index 09f8f0d..29bce36 100644 --- a/src/screens/SettingsPage.tsx +++ b/src/screens/SettingsPage.tsx @@ -15,6 +15,7 @@ import { type SettingView, type UiError, } from "@/lib/api"; +import { squidSettingsView } from "@/lib/squidSettings"; import { cn } from "@/lib/utils"; import { Button } from "@/components/ui/button"; import { Card } from "@/components/ui/card"; @@ -153,9 +154,10 @@ function Row(props: { s: SettingView; value: JsonValue; error: string | null; on ); } -export function SettingsPage(props: { serverId: string; scope: Scope; title: string; question: string }) { +export function SettingsPage(props: { serverId: string; scope: Scope; botModule?: "companions" | "playerbots"; title: string; question: string }) { const { serverId, scope } = props; - const { t, tn } = useI18n(); + const { t, tn, locale } = useI18n(); + const squid = scope === "bots" && props.botModule === "playerbots"; const sx = useSchemaText(); const human = useHuman(); const [view, setView] = useState(null); @@ -181,7 +183,7 @@ export function SettingsPage(props: { serverId: string; scope: Scope; title: str const load = useCallback(async () => { try { - const v = await api.settings(serverId, scope); + const v = squid ? squidSettingsView(await api.moduleSettings(serverId, "playerbots"), locale) : await api.settings(serverId, scope); setView(v); setDraft({}); setErrors({}); @@ -190,14 +192,14 @@ export function SettingsPage(props: { serverId: string; scope: Scope; title: str } catch (e) { setFatal(asUiError(e)); } - }, [serverId, scope]); + }, [serverId, scope, squid, locale]); useEffect(() => { setView(null); setSaved(null); setCategory(""); void load(); - void api.presets(scope).then(setPresets); + if (squid) setPresets([]); else void api.presets(scope).then(setPresets); void api.status(serverId).then((s) => setRunning(s.observed.world.state === "running")); setQuery(""); setRaw(null); @@ -290,7 +292,10 @@ export function SettingsPage(props: { serverId: string; scope: Scope; title: str setBusy(true); setSaveErr(null); try { - const report = await api.save(serverId, scope, changes); + const report: SaveReport = squid ? { + changed: (await api.moduleSaveSettings(serverId, "playerbots", Object.fromEntries(Object.entries(changes).map(([key, value]) => [key, typeof value === "boolean" ? value ? "1" : "0" : String(value)])))).map(key => ({ key, title: view!.settings.find(s => s.key === key)!.title, restart: "world", dangerous: false })), + restart: "world", snapshot: null, + } : await api.save(serverId, scope, changes); setSaved(report); setPreview(null); await load(); @@ -338,7 +343,9 @@ export function SettingsPage(props: { serverId: string; scope: Scope; title: str async function openPreset(id: string) { setSaved(null); - setPreview(await api.previewPreset(serverId, scope, id)); + if (squid) { + setPreview({ id: "defaults", title: t("set.restoreDefaults"), description: "", changes: view!.settings.filter(s => s.value !== s.default).map(s => ({ key: s.key, title: s.title, from: s.value, to: s.default, dangerous: false })) }); + } else setPreview(await api.previewPreset(serverId, scope, id)); } async function restartNow() { @@ -356,9 +363,9 @@ export function SettingsPage(props: { serverId: string; scope: Scope; title: str return (

{props.title}

-

{props.question}

+

{squid ? "SQUID’s Playerbots" : props.question}

- {scope === "bots" && } + {scope === "bots" && !squid && } {view.drift_keys.length > 0 && ( @@ -372,7 +379,7 @@ export function SettingsPage(props: { serverId: string; scope: Scope; title: str )}
- {t("set.presets")} + {presets.length > 0 && {t("set.presets")}} {presets.map((p) => (