Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/bot/src/bot.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ import { HandlersModule } from './handlers/handlers.module';
controllers: [BotController],
providers: [BotService],
})
export class BotModule { }
export class BotModule {}
58 changes: 1 addition & 57 deletions apps/bot/src/bot.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
Expand Down Expand Up @@ -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);
// }
// };
}
2 changes: 1 addition & 1 deletion apps/bot/src/handlers/base.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ export abstract class BaseHandler {
@InjectTemporalClient()
protected readonly temporalClient: WorkflowClient,
protected readonly configService: ConfigService,
) { }
) {}
abstract handle(ctx: Context, event?: FilterQuery): Promise<void>;
}
2 changes: 1 addition & 1 deletion apps/bot/src/handlers/handlers.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
8 changes: 4 additions & 4 deletions apps/bot/src/handlers/update.handler.ts
Original file line number Diff line number Diff line change
@@ -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<void> {
async handle(ctx: Context, event: FilterQuery): Promise<void> {
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) {
Expand Down
Loading