This commit is contained in:
NAME
2026-05-15 07:08:56 +00:00
parent 5f16ed135d
commit 7730c76e08
20 changed files with 945 additions and 316 deletions
+17 -4
View File
@@ -115,12 +115,14 @@ export class TelegramUpdates {
'comvi',
'comen',
'comja',
'comjal',
'comko',
'comcn',
])
async onCommentAsTextCommand(@Ctx() ctx: Scenes.SceneContext): Promise<void> {
let language = 'en';
let xpostreader = 'api'
// @ts-ignore
let {command, payload} = ctx;
if (['comvi', 'comvn', 'com_vi'].includes(command)) {
@@ -129,9 +131,13 @@ export class TelegramUpdates {
if (['comko', 'comkr', 'com_ko'].includes(command)) {
language = 'ko';
}
if (['comja', 'comjp', 'com_ja'].includes(command)) {
if (['comja', 'com_ja',].includes(command)) {
language = 'ja';
}
if (['comjal', 'comjalong' ].includes(command)) {
language = 'ja';
xpostreader = 'browser';
}
if (['comcn'].includes(command)) {
language = 'cn';
}
@@ -149,7 +155,7 @@ export class TelegramUpdates {
const match = _linkX.match(/status\/(\d+)/);
if (match) {
//nêu match => get content x
const xpost = await this.xReaderService.readXPost(_linkX);
const xpost = await this.xReaderService.readXPost(_linkX, xpostreader, chatId);
console.log('==> content text:' + xpost.text);
payload = xpost.text;
tweetId = xpost.tweetId;
@@ -174,6 +180,7 @@ export class TelegramUpdates {
'quoteen',
'quote_ja',
'quoteja',
'quotejal',
'quote_jp',
'quotejp',
'quote_ko',
@@ -183,6 +190,11 @@ export class TelegramUpdates {
async onWizardQuote(@Ctx() ctx: Scenes.SceneContext): Promise<void> {
// @ts-ignore
let {command, payload} = ctx;
let xreaderMode = 'api';
if(['quotejal'].includes(command)) {
command = 'quote_ja';
xreaderMode='browser';
}
if (['quote_jp', 'quotejp', 'quoteja'].includes(command)) {
command = 'quote_ja';
}
@@ -207,6 +219,7 @@ export class TelegramUpdates {
language: preferLanguage,
linkUrl: payload,
quoteText: '',
xreaderMode,
quoteAs: 'quotelink',
});
}
@@ -416,7 +429,7 @@ export class TelegramUpdates {
await ctx.reply(`vui lòng đưa chờ phân tích ....`);
}
@Command(['xreader', 'xreader_browser'])
@Command(['xreader', 'xrbr'])
async onXReader(ctx: Context) {
// @ts-ignore
let {command, payload} = ctx;
@@ -428,7 +441,7 @@ export class TelegramUpdates {
const content = await this.xReaderService.readXPost(
payload,
command === 'xreader_browser' ? 'browser' : 'any'
['xreader_browser','xrbr'].includes(command) ? 'browser' : 'any'
).catch((err) => {
ctx.reply(err.message);
return err;
+33 -30
View File
@@ -2,8 +2,8 @@ import {Action, Command, Ctx, On, Wizard, WizardStep} from "nestjs-telegraf";
import {WIZARD_COMMENT2_SCENE_ID} from "../telegram.constants";
import * as scenes from "telegraf/scenes";
import {ManagerService} from "../../manager/manager.service";
import {TONE_HINTS_TELEGRAM_BUTTON} from "../../content-writer/prompts/templates";
import {ANGLE_HINTS_TELEGRAM_BUTTON} from "../../content-writer/enum/angle.enum";
import {get_TONE_HINTS_TELEGRAM_BUTTON} from "../../content-writer/prompts/templates";
@Wizard(WIZARD_COMMENT2_SCENE_ID)
export class Comment2Wizard {
@@ -29,6 +29,9 @@ export class Comment2Wizard {
await ctx.reply('Không có thông tin về chủ đề bạn cần viết bài');
return ctx.scene.leave();
}
const language = (ctx.wizard.state as any).language;
const TONE_HINTS_TELEGRAM_BUTTON = get_TONE_HINTS_TELEGRAM_BUTTON(language)
// @ts-ignore
const inline_keyboards = [];
Object.keys(TONE_HINTS_TELEGRAM_BUTTON).map(key => {
@@ -195,33 +198,33 @@ export class Comment2Wizard {
await ctx.scene.leave();
}
async doAskTone(ctx: scenes.WizardContext) {
// @ts-ignore
const inline_keyboards = [];
Object.keys(TONE_HINTS_TELEGRAM_BUTTON).map(key => {
// @ts-ignore
inline_keyboards.push([{
text: TONE_HINTS_TELEGRAM_BUTTON[key].text,
callback_data: `comment_tone_${key}`
}]);
return;
})
await ctx.sendMessage(
`🤖 Chọn phong cách viết , bấm \\cancel để huỷ `,
{
parse_mode: 'Markdown',
reply_markup: {
inline_keyboard: [
...inline_keyboards,
[
{text: "🤖AI tự chọn", callback_data: `comment_tone_aineeddetect`},
],
[
{text: "❌Cancel", callback_data: `comment_tone_cancel`},
]
]
}
}
);
}
// async doAskTone(ctx: scenes.WizardContext) {
// // @ts-ignore
// const inline_keyboards = [];
// Object.keys(get_TONE_HINTS_TELEGRAM_BUTTON()).map(key => {
// // @ts-ignore
// inline_keyboards.push([{
// text: TONE_HINTS_TELEGRAM_BUTTON[key].text,
// callback_data: `comment_tone_${key}`
// }]);
// return;
// })
// await ctx.sendMessage(
// `🤖 Chọn phong cách viết , bấm \\cancel để huỷ `,
// {
// parse_mode: 'Markdown',
// reply_markup: {
// inline_keyboard: [
// ...inline_keyboards,
// [
// {text: "🤖AI tự chọn", callback_data: `comment_tone_aineeddetect`},
// ],
// [
// {text: "❌Cancel", callback_data: `comment_tone_cancel`},
// ]
// ]
// }
// }
// );
// }
}
+3 -1
View File
@@ -112,6 +112,7 @@ export class QuoteWizard {
const language = (ctx.wizard.state as any).language;
const quoteAs = (ctx.wizard.state as any).quoteAs;
const xreaderMode = (ctx.wizard.state as any).xreaderMode;
const telegramChatId = ''+ctx?.chat?.id!;
// @ts-ignore
@@ -133,7 +134,8 @@ export class QuoteWizard {
twitterUrl,
quoteType,
language,
telegramChatId
telegramChatId,
xreaderMode
);
}
+4 -1
View File
@@ -2,7 +2,7 @@ import {Action, Command, Ctx, On, Wizard, WizardStep} from "nestjs-telegraf";
import {WIZARD_WRITER_SCENE_ID} from "../telegram.constants";
import * as scenes from "telegraf/scenes";
import {ManagerService} from "../../manager/manager.service";
import {STYLE_HINTS_TELEGRAM_BUTTON, TONE_HINTS_TELEGRAM_BUTTON} from "../../content-writer/prompts/templates";
import {get_TONE_HINTS_TELEGRAM_BUTTON, STYLE_HINTS_TELEGRAM_BUTTON,} from "../../content-writer/prompts/templates";
@Wizard(WIZARD_WRITER_SCENE_ID)
export class WriterWizard {
@@ -28,6 +28,7 @@ export class WriterWizard {
await ctx.reply('Không có thông tin về chủ đề bạn cần viết bài');
return ctx.scene.leave();
}
// @ts-ignore
const inline_keyboards = [];
Object.keys(STYLE_HINTS_TELEGRAM_BUTTON).map(key => {
@@ -99,6 +100,8 @@ export class WriterWizard {
await ctx.deleteMessage();
(ctx.wizard.state as any).writeType = writeType;
const language = (ctx.wizard.state as any).language;
const TONE_HINTS_TELEGRAM_BUTTON = get_TONE_HINTS_TELEGRAM_BUTTON(language)
// @ts-ignore
const inline_keyboards = [];
Object.keys(TONE_HINTS_TELEGRAM_BUTTON).map(key => {