added RAG, Multiuser, TG bot

This commit is contained in:
2026-06-13 20:20:56 +00:00
parent 66e1b0e29e
commit c8a9429bed
142 changed files with 19901 additions and 8790 deletions
+33
View File
@@ -0,0 +1,33 @@
from aiogram import Router
from aiogram.filters import Command
from aiogram.types import Message
from bot.access import access_denied_text, is_allowed
from bot.config import Settings
from bot.ha_client import HaClient
from bot.storage import Storage
router = Router()
@router.message(Command("newchat"))
async def cmd_newchat(message: Message, settings: Settings, storage: Storage) -> None:
if not is_allowed(message, settings):
await message.answer(access_denied_text())
return
if not message.from_user:
return
linked = await storage.get_user(message.from_user.id)
if not linked:
await message.answer("Сначала привяжи API-токен (/start).")
return
client = HaClient(settings.ha_api_base_url, linked.api_token)
try:
session = await client.create_session("Telegram")
session_id = int(session["id"])
await storage.set_session_id(message.from_user.id, session_id)
await message.answer(f"Новая сессия создана: #{session_id}. История с прошлой сессии здесь не продолжается.")
except Exception as exc:
await message.answer(f"Не удалось создать сессию: {exc}")