Telegram-бот Boltun AI на grammY + Mastra

- Отвечает только администраторам из ADMIN_IDS
- Личности на чат: встроенные и пользовательские (/personas, /persona, /persona_add, /persona_del)
- Вопросы через /ask, упоминание, ответ боту или личку
- Сохраняет сообщения чата в SQLite; агент по просьбе читает их инструментом read_chat_messages
- Модели через OpenRouter (по умолчанию DeepSeek)
- Слои: libs, repositories, services, bot/handlers
- Dockerfile для деплоя в Dokploy

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
yunogasai
2026-09-24 18:31:44 +02:00
commit 99c4660da9
32 changed files with 3173 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
import type { ChatMessage } from "../../types.js";
const formatTime = (unixSeconds: number): string =>
new Date(unixSeconds * 1000).toISOString().slice(0, 16).replace("T", " ");
/** Сообщения чата в текстовом виде для контекста модели. */
export const formatChatMessages = (messages: ChatMessage[]): string =>
messages
.map((m) => {
const reply = m.replyToMessageId ? ` (ответ на #${m.replyToMessageId})` : "";
return `#${m.messageId} [${formatTime(m.date)} UTC] ${m.author}${reply}: ${m.text}`;
})
.join("\n");