diff --git a/src/modules/telegram/telegram.updates.ts b/src/modules/telegram/telegram.updates.ts index db33556..4365e3d 100644 --- a/src/modules/telegram/telegram.updates.ts +++ b/src/modules/telegram/telegram.updates.ts @@ -113,6 +113,7 @@ export class TelegramUpdates { async onWizardCommand(@Ctx() ctx: Scenes.SceneContext): Promise { await ctx.scene.enter(WIZARD_COMMENT_SCENE_ID); } + @Command('chatid') async onGetChatId(ctx: Context) { // @ts-ignore @@ -127,12 +128,16 @@ export class TelegramUpdates { await ctx.reply(`vui lòng đưa topic, ví dụ: /${command} LinkX`); return; } - await this.sharedAutoComment(ctx, payload); + await this.sharedAutoComment(ctx, payload, 'realflashkaze'); } - @Action('action_auto_comment') + + @Action(/action_auto_comment_(.+)/) async onDownloadAction(@Ctx() ctx: Context) { await ctx.answerCbQuery(); // Tắt trạng thái loading trên nút bấm + const callbackData = (ctx.callbackQuery as any).data; + const accountX = callbackData.split('_')[1]; + // Ép kiểu để ép TypeScript nhận diện đúng đối tượng tin nhắn chữ // @ts-ignore const message = ctx.callbackQuery.message as any; @@ -142,10 +147,10 @@ export class TelegramUpdates { // await ctx.reply(`Tôi đọc được chữ từ tin nhắn cũ: ${textInMessage}`); - await this.sharedAutoComment(ctx, textInMessage); + await this.sharedAutoComment(ctx, textInMessage, accountX); } - private async sharedAutoComment(ctx: Context, linkX:string): Promise { + private async sharedAutoComment(ctx: Context, linkX: string, accountX: string): Promise { // console.log(ctx); // @ts-ignore if (!linkX) { @@ -164,7 +169,7 @@ export class TelegramUpdates { await this.managerService.triggerAutoGenerateCommentTwitter( linkX, - 'realflashkaze', + accountX, 'en', chatId, ); @@ -956,7 +961,10 @@ export class TelegramUpdates { await ctx.reply(text, { reply_markup: { inline_keyboard: [ - [{ text: '📥 Chạy lệnh auto cmt', callback_data: 'action_auto_comment' }] + [ + {text: '📥 Chạy lệnh auto cmt flashkaze', callback_data: 'action_auto_comment_realflashkaze'}, + {text: '📥 Chạy lệnh auto cmt ech com', callback_data: 'action_auto_comment_echcomvuive'} + ] ] } });