add ci for tg bot
Deploy app frontend / app frontend (push) Failing after 54s
Deploy service couchdb / service couchdb (push) Successful in 38s
Deploy db-migrations / db-migrations (push) Failing after 50s
Deploy service message-delivery-method-web-push / service message-delivery-method-web-push (push) Failing after 1m27s
Deploy service tg-bot / service tg-bot (push) Failing after 44s

This commit is contained in:
2024-12-12 17:45:01 +02:00
parent e07d748e87
commit 7df04c0103
24 changed files with 309 additions and 365 deletions
+18 -5
View File
@@ -1,10 +1,11 @@
import { Bot, session } from "grammy";
import { conversations, createConversation } from "@grammyjs/conversations";
import { MyContext } from "@/types/myContext";
import { env } from "@/config/env";
import { startHealthServer } from "@hereconnect/lib-service-health-checkserver";
import { MyContext } from "../types/myContext";
import { env } from "../config/env";
import { CouchDBStorageAdapter } from "./storageAdapters/CouchDBStorageAdapter";
import { loadUserMiddleware } from "./middleware/loadUser";
import { tgBotSessionsDb } from "@/dbs";
import { tgBotSessionsDb } from "../dbs";
import { setupCommands } from "./commands/setupCommands";
import { startCommand } from "./commands/start";
import { helpCommand } from "./commands/help";
@@ -13,12 +14,21 @@ import { manageCommand } from "./commands/manage";
import { callbackQueryHandler } from "./callbackHandlers";
import { newQRCodeConversation } from "./conversations/newQRCodeConversation";
const abortController = new AbortController();
const storage = new CouchDBStorageAdapter(tgBotSessionsDb, {
softDelete: true,
type: "tg_bot_session",
});
// Инициализируем бота с нужным типом контекста
const bot = new Bot<MyContext>(env.TELEGRAM_BOT_TOKEN);
const bot = new Bot<MyContext>(env.TELEGRAM_BOT_TOKEN, {
client: {
baseFetchConfig: {
signal: abortController.signal,
},
},
});
// Подключаем сессии. По необходимости определите initial state для сессии
bot.use(session({ storage, initial: () => ({}) }));
@@ -44,7 +54,10 @@ bot.on("callback_query:data", callbackQueryHandler);
await setupCommands(bot);
// Запуск бота
bot.start();
await bot.start();
await startHealthServer(abortController);
console.log("Бот запущен!");
})();