feat: locale-aware command templates, debounced auto-sync, entity pickers
- Locale-aware templates: CommandTemplateSlot now has a locale column, allowing each slot to have per-language variants (EN/RU). Templates are resolved at runtime from the Telegram user's language_code. - Merged system configs: "Default Commands (EN)" and "(RU)" merged into a single "Default Commands" config with locale-aware slots. Migration handles existing data automatically. - Configurable command descriptions: hardcoded COMMAND_DESCRIPTIONS replaced with desc_* template slots (desc_status, desc_help, etc.) that users can customize per locale. setMyCommands registers all locales explicitly. - Removed locale from CommandConfig: no longer needed since locale is derived from the Telegram user's language at runtime. - Debounced command auto-sync: after command config/tracker changes, affected bots are marked dirty and synced after a 30s debounce window. Manual "Sync with Telegram" button still works. - Entity pickers in LinkedTargetsSection: replaced 6 plain <select> elements with EntitySelect components (search, icons, keyboard nav). Added onselect callback and size="sm" props to EntitySelect.
This commit is contained in:
@@ -1,27 +1,7 @@
|
||||
"""Command definitions — descriptions, categories, and rate limit grouping."""
|
||||
"""Command definitions — categories, rate limit grouping, and defaults."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
# Command descriptions for Telegram menu (EN / RU)
|
||||
COMMAND_DESCRIPTIONS: dict[str, dict[str, str]] = {
|
||||
"status": {"en": "Show tracker status", "ru": "Показать статус трекеров"},
|
||||
"albums": {"en": "List tracked albums", "ru": "Список отслеживаемых альбомов"},
|
||||
"events": {"en": "Show recent events", "ru": "Показать последние события"},
|
||||
"summary": {"en": "Send album summary now", "ru": "Отправить сводку альбомов"},
|
||||
"latest": {"en": "Show latest photos", "ru": "Показать последние фото"},
|
||||
"memory": {"en": "On This Day memories", "ru": "Воспоминания за этот день"},
|
||||
"random": {"en": "Send random photo", "ru": "Отправить случайное фото"},
|
||||
"search": {"en": "Smart search (AI)", "ru": "Умный поиск (AI)"},
|
||||
"find": {"en": "Search by filename", "ru": "Поиск по имени файла"},
|
||||
"person": {"en": "Find photos of person", "ru": "Найти фото человека"},
|
||||
"place": {"en": "Find photos by location", "ru": "Найти фото по месту"},
|
||||
"favorites": {"en": "Show favorites", "ru": "Показать избранное"},
|
||||
"people": {"en": "List detected people", "ru": "Список людей"},
|
||||
"help": {"en": "Show available commands", "ru": "Показать доступные команды"},
|
||||
}
|
||||
|
||||
ALL_COMMANDS = list(COMMAND_DESCRIPTIONS.keys())
|
||||
|
||||
# Map commands to rate limit categories
|
||||
_RATE_CATEGORY: dict[str, str] = {
|
||||
"search": "search", "find": "search", "person": "search",
|
||||
@@ -35,7 +15,6 @@ def get_rate_category(cmd: str) -> str:
|
||||
|
||||
DEFAULT_COMMANDS_CONFIG = {
|
||||
"enabled": ["help", "status", "albums", "events", "latest", "random", "favorites", "summary", "memory"],
|
||||
"locale": "en",
|
||||
"response_mode": "media",
|
||||
"default_count": 5,
|
||||
"rate_limits": {"search": 30, "default": 10},
|
||||
|
||||
Reference in New Issue
Block a user