generated from tailored/router-template
fix: 添加总结
This commit is contained in:
parent
e2d0720698
commit
42da851c37
17
README.md
17
README.md
@ -1 +1,16 @@
|
|||||||
# router app template
|
# 社交路由功能模块
|
||||||
|
|
||||||
|
## 小红书
|
||||||
|
|
||||||
|
自动获取和上传
|
||||||
|
|
||||||
|
[代理浏览器](https://git.xiongxiao.me/media/social-xhs-api-server)
|
||||||
|
|
||||||
|
### 功能
|
||||||
|
|
||||||
|
#### 获取评论
|
||||||
|
|
||||||
|
#### 获取笔记信息
|
||||||
|
|
||||||
|
#### 返回笔记信息
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import { nanoid } from 'nanoid';
|
import { nanoid } from 'nanoid';
|
||||||
import { agent } from './agent.ts';
|
import { agent } from './agent.ts';
|
||||||
import { ai } from './ai.ts';
|
import { ai } from './ai.ts';
|
||||||
import { cmdList } from './analyze/cmd.ts';
|
|
||||||
/**
|
/**
|
||||||
* 清除文本中的@信息
|
* 清除文本中的@信息
|
||||||
* @param text
|
* @param text
|
||||||
@ -11,14 +10,36 @@ const clearAtInfo = (text: string = '') => {
|
|||||||
return newText.trim();
|
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
|
agent
|
||||||
.route({
|
.route({
|
||||||
path: 'xhs',
|
path: 'xhs',
|
||||||
})
|
})
|
||||||
.define(async (ctx) => {
|
.define(async (ctx) => {
|
||||||
const { text = '' } = ctx.query || {};
|
const { text = '', note = '', hasNote } = ctx.query || {};
|
||||||
const id = nanoid();
|
const id = nanoid();
|
||||||
const no_at_text = clearAtInfo(text);
|
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 some_text = no_at_text.length > 20 ? no_at_text.slice(0, 20) : no_at_text;
|
||||||
const hasCmd = some_text.includes('指令');
|
const hasCmd = some_text.includes('指令');
|
||||||
if (hasCmd) {
|
if (hasCmd) {
|
||||||
@ -36,6 +57,8 @@ agent
|
|||||||
...cmd.action,
|
...cmd.action,
|
||||||
payload: {
|
payload: {
|
||||||
text: no_at_text,
|
text: no_at_text,
|
||||||
|
note: no_tags_text,
|
||||||
|
hasNote: hasNote || false,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
ctx.body = res.body || '';
|
ctx.body = res.body || '';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user