fix: 添加总结

This commit is contained in:
熊潇 2025-06-29 09:05:27 +08:00
parent e2d0720698
commit 42da851c37
2 changed files with 41 additions and 3 deletions

View File

@ -1 +1,16 @@
# router app template
# 社交路由功能模块
## 小红书
自动获取和上传
[代理浏览器](https://git.xiongxiao.me/media/social-xhs-api-server)
### 功能
#### 获取评论
#### 获取笔记信息
#### 返回笔记信息

View File

@ -1,7 +1,6 @@
import { nanoid } from 'nanoid';
import { agent } from './agent.ts';
import { ai } from './ai.ts';
import { cmdList } from './analyze/cmd.ts';
/**
* @信息
* @param text
@ -11,14 +10,36 @@ const clearAtInfo = (text: string = '') => {
return newText.trim();
};
/**
* , #
* @param text
*/
export const pickTagsInfo = (text: string = '') => {
if (!text) {
return {
tags: [],
text: '',
};
}
const _tags = text.match(/#([\u4e00-\u9fa5\w]+)/g) || [];
const validTags = _tags.map((tag) => tag.replace(/#/g, '')).filter((tag) => tag.trim() !== '');
const noTagsText = text.replace(/#([\u4e00-\u9fa5\w]+)/g, '').trim();
return {
tags: validTags,
text: noTagsText,
};
};
agent
.route({
path: 'xhs',
})
.define(async (ctx) => {
const { text = '' } = ctx.query || {};
const { text = '', note = '', hasNote } = ctx.query || {};
const id = nanoid();
const no_at_text = clearAtInfo(text);
const pickNote = pickTagsInfo(note);
const no_tags_text = pickNote.text;
const some_text = no_at_text.length > 20 ? no_at_text.slice(0, 20) : no_at_text;
const hasCmd = some_text.includes('指令');
if (hasCmd) {
@ -36,6 +57,8 @@ agent
...cmd.action,
payload: {
text: no_at_text,
note: no_tags_text,
hasNote: hasNote || false,
},
});
ctx.body = res.body || '';