feat: implement feedback collection system with quest-based interaction
This commit is contained in:
18
src/bot.ts
Normal file
18
src/bot.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import type { FeedbackStore } from './stores/feedback';
|
||||
import type { SessionStore } from './stores/session';
|
||||
import { Telegraf } from 'telegraf';
|
||||
import { onCallback, onStart } from './telegram/handlers';
|
||||
|
||||
export function createBot(token: string, rootDir: string, sessions: SessionStore, feedback: FeedbackStore, signal: AbortSignal): Telegraf {
|
||||
const bot = new Telegraf(token, { handlerTimeout: 10_000 });
|
||||
|
||||
bot.start(onStart(rootDir, sessions));
|
||||
bot.on('callback_query', onCallback(rootDir, sessions, feedback));
|
||||
|
||||
// Graceful shutdown
|
||||
signal.addEventListener('abort', () => {
|
||||
bot.stop('AbortController: abort');
|
||||
});
|
||||
|
||||
return bot;
|
||||
}
|
||||
Reference in New Issue
Block a user