Phase 9: Telegram bot management with chat discovery
Some checks failed
Validate / Hassfest (push) Has been cancelled

New entity + API:
- TelegramBot model (name, token, bot_username, bot_id)
- CRUD at /api/telegram-bots with token validation via getMe
- GET /{id}/chats: discover active chats via getUpdates
- GET /{id}/token: retrieve full token (for target config)

Frontend:
- /telegram-bots page: register bots, view discovered chats
  per bot (expandable), refresh on demand
- Targets page: select from registered bots (dropdown) instead
  of raw token input. Chat selector shows discovered chats
  when bot is selected, falls back to manual input.
  Bot token resolved server-side on save.

Nav icon uses monochrome symbol for consistency.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-19 17:45:58 +03:00
parent 5dee7c55ca
commit cf987cbfb4
9 changed files with 440 additions and 10 deletions

View File

@@ -7,6 +7,7 @@ from .models import (
EventLog,
ImmichServer,
NotificationTarget,
TelegramBot,
TemplateConfig,
TrackingConfig,
User,

View File

@@ -36,6 +36,20 @@ class ImmichServer(SQLModel, table=True):
created_at: datetime = Field(default_factory=_utcnow)
class TelegramBot(SQLModel, table=True):
"""Registered Telegram bot."""
__tablename__ = "telegram_bot"
id: int | None = Field(default=None, primary_key=True)
user_id: int = Field(foreign_key="user.id")
name: str # User-given display name
token: str # Bot API token
bot_username: str = Field(default="") # @username from getMe
bot_id: int = Field(default=0) # Numeric bot ID from getMe
created_at: datetime = Field(default_factory=_utcnow)
class TrackingConfig(SQLModel, table=True):
"""Tracking configuration: what events/assets to react to and scheduled modes."""