diff --git a/apps/bot/src/bot.module.ts b/apps/bot/src/bot.module.ts index 5733b37..3e51562 100644 --- a/apps/bot/src/bot.module.ts +++ b/apps/bot/src/bot.module.ts @@ -33,4 +33,4 @@ import { HandlersModule } from './handlers/handlers.module'; controllers: [BotController], providers: [BotService], }) -export class BotModule { } +export class BotModule {} diff --git a/apps/bot/src/bot.service.ts b/apps/bot/src/bot.service.ts index b3473be..c1327ee 100644 --- a/apps/bot/src/bot.service.ts +++ b/apps/bot/src/bot.service.ts @@ -43,7 +43,7 @@ export class BotService implements OnModuleInit { Object.values(UpdateEvent).map((event) => { this.bot.on(event, (ctx: Context) => { this.logger.log(`Received ${event} from ${ctx.chat.id}`); - this.updateHandler.handle(ctx); + this.updateHandler.handle(ctx, event); this.questionHandler.handle(ctx); return; }); @@ -119,60 +119,4 @@ export class BotService implements OnModuleInit { await ctx.reply(text, { parse_mode: 'HTML' }); }; - - // protected getSummary = async (ctx: Context) => { - // try { - // const community = await this.temporalClient.execute( - // 'TelegramGetCommunityWorkflow', - // { - // taskQueue: 'TEMPORAL_QUEUE_LIGHT', - // args: [{ chatId: ctx.chat.id }], - // workflowId: `telegram:getcommunity:${ctx.update.update_id}`, - // }, - // ); - // if (!community) { - // console.log('No community found for', ctx.chat.id); - // return; - // } - - // const platform = await this.temporalClient.execute( - // 'TelegramGetPlatformWorkflow', - // { - // taskQueue: 'TEMPORAL_QUEUE_LIGHT', - // args: [{ chatId: ctx.chat.id }], - // workflowId: `telegram:getplatform:${ctx.update.update_id}`, - // }, - // ); - // if (!platform) { - // console.log('No platform found for', ctx.chat.id); - // return; - // } - - // const summary = await this.temporalClient.execute( - // 'PlatformSummariesWorkflow', - // { - // taskQueue: 'TEMPORAL_QUEUE_PYTHON_LIGHT', - // args: [ - // { - // platform_id: platform.id, - // community_id: community.id, - // start_date: null, - // end_date: null, - // extract_text_only: true, - // }, - // ], - // workflowId: `telegram:summaries:${ctx.update.update_id}`, - // }, - // ); - - // if (!summary || summary.length === 0) { - // console.log('No summary found for', ctx.chat.id); - // return; - // } - - // await ctx.reply(summary); - // } catch (error) { - // console.error(error); - // } - // }; } diff --git a/apps/bot/src/handlers/base.handler.ts b/apps/bot/src/handlers/base.handler.ts index 145eb39..313a6e4 100644 --- a/apps/bot/src/handlers/base.handler.ts +++ b/apps/bot/src/handlers/base.handler.ts @@ -11,6 +11,6 @@ export abstract class BaseHandler { @InjectTemporalClient() protected readonly temporalClient: WorkflowClient, protected readonly configService: ConfigService, - ) { } + ) {} abstract handle(ctx: Context, event?: FilterQuery): Promise; } diff --git a/apps/bot/src/handlers/handlers.module.ts b/apps/bot/src/handlers/handlers.module.ts index b7204af..d0b74a3 100644 --- a/apps/bot/src/handlers/handlers.module.ts +++ b/apps/bot/src/handlers/handlers.module.ts @@ -11,4 +11,4 @@ import { SummaryHandler } from './summary.handler'; providers: [QuestionHandler, UpdateHandler, VerifyHandler, SummaryHandler], exports: [QuestionHandler, UpdateHandler, VerifyHandler, SummaryHandler], }) -export class HandlersModule { } +export class HandlersModule {} diff --git a/apps/bot/src/handlers/update.handler.ts b/apps/bot/src/handlers/update.handler.ts index 527150f..0f2f4bc 100644 --- a/apps/bot/src/handlers/update.handler.ts +++ b/apps/bot/src/handlers/update.handler.ts @@ -1,13 +1,13 @@ -import { Context } from 'grammy'; +import { Context, FilterQuery } from 'grammy'; import { BaseHandler } from './base.handler'; export class UpdateHandler extends BaseHandler { - async handle(ctx: Context): Promise { + async handle(ctx: Context, event: FilterQuery): Promise { try { const update = ctx.update; - await this.temporalClient.start('TelegramUpdateWorkflow', { + await this.temporalClient.start('TelegramEventWorkflow', { taskQueue: 'TEMPORAL_QUEUE_LIGHT', - args: [{ update }], + args: [{ update, event }], workflowId: `telegram:update:${update.update_id}`, }); } catch (error) {