feat: remove hardcoded command templates, enforce template system exclusively
- Remove ALL hardcoded EN/RU fallback strings from handler.py — every command response now renders through CommandTemplateSlot templates - _render_cmd_template now returns error placeholder instead of None when template is missing, ensuring no silent failures - Fix register_commands_with_telegram tuple unpacking bug (was ignoring cmd_template_slots from _resolve_command_context) - Auto-assign system default template (matching locale) on command config creation when none specified - Add command_template_config_id to CommandConfigCreate model - Remove "no template" option from frontend dropdown — template is now required for command configs - Auto-select first matching template when creating new command config - Fix || vs ?? for command_template_config_id, default_count, and rate_limits in frontend edit function (0 was treated as falsy)
This commit is contained in:
@@ -62,7 +62,14 @@
|
||||
finally { loaded = true; }
|
||||
}
|
||||
|
||||
function openNew() { form = defaultForm(); editing = null; showForm = true; }
|
||||
function openNew() {
|
||||
form = defaultForm();
|
||||
// Auto-select first matching template for the default provider_type
|
||||
const match = cmdTemplateConfigs.find((c: any) => c.provider_type === form.provider_type);
|
||||
if (match) form.command_template_config_id = match.id;
|
||||
editing = null;
|
||||
showForm = true;
|
||||
}
|
||||
function editConfig(cfg: any) {
|
||||
form = {
|
||||
name: cfg.name,
|
||||
@@ -71,9 +78,9 @@
|
||||
enabled_commands: [...(cfg.enabled_commands || [])],
|
||||
locale: cfg.locale || 'en',
|
||||
response_mode: cfg.response_mode || 'media',
|
||||
default_count: cfg.default_count || 5,
|
||||
rate_limits: { search: cfg.rate_limits?.search || 30, default: cfg.rate_limits?.default || 10 },
|
||||
command_template_config_id: cfg.command_template_config_id || null,
|
||||
default_count: cfg.default_count ?? 5,
|
||||
rate_limits: { search: cfg.rate_limits?.search ?? 30, default: cfg.rate_limits?.default ?? 10 },
|
||||
command_template_config_id: cfg.command_template_config_id ?? null,
|
||||
};
|
||||
editing = cfg.id;
|
||||
showForm = true;
|
||||
@@ -167,7 +174,6 @@
|
||||
<label for="cc-template" class="block text-sm font-medium mb-1">{t('commandConfig.responseTemplate')}</label>
|
||||
<select id="cc-template" bind:value={form.command_template_config_id}
|
||||
class="w-full px-3 py-2 border border-[var(--color-border)] rounded-md text-sm bg-[var(--color-background)]">
|
||||
<option value={null}>— {t('commandConfig.noTemplate')} —</option>
|
||||
{#each cmdTemplateConfigs.filter((c: any) => c.provider_type === form.provider_type) as tpl}
|
||||
<option value={tpl.id}>{tpl.name}{tpl.user_id === 0 ? ' (System)' : ''}</option>
|
||||
{/each}
|
||||
|
||||
Reference in New Issue
Block a user