🌟 feat: 新增少数派链接分享总结 & 整理

This commit is contained in:
zhiyu1998 2024-05-30 16:45:14 +08:00
parent 76c9518d2f
commit 9f6b64a219
2 changed files with 31 additions and 25 deletions

View File

@ -70,6 +70,7 @@ import { mid2id } from "../utils/weibo.js";
import { LagrangeAdapter } from "../utils/lagrange-adapter.js";
import path from "path";
import { OpenaiBuilder } from "../utils/openai-builder.js";
import { contentEstimator } from "../utils/link-share-summary-util.js";
export class tools extends plugin {
/**
@ -1562,7 +1563,7 @@ export class tools extends plugin {
e.reply(`没有配置 Kimi无法为您总结${HELP_DOC}`)
return true;
}
const { name, summaryLink } = this.contentEstimator(e.msg);
const { name, summaryLink } = contentEstimator(e.msg);
const builder = await new OpenaiBuilder()
.setBaseURL(this.aiBaseURL)
.setApiKey(this.aiApiKey)
@ -1579,30 +1580,6 @@ export class tools extends plugin {
return true;
}
/**
* 内容评估器
* @link {weixin}
* @param link 链接
*/
contentEstimator(link) {
const wxReg = /(?:https?:\/\/)?mp\.weixin\.qq\.com\/[A-Za-z\d._?%&+\-=\/#]*/;
const arxivReg = /(?:https?:\/\/)?arxiv.org\/[a-zA-Z\d._?%&+\-=\/#]*/;
if (wxReg.test(link)) {
return {
name: '微信文章',
summaryLink: wxReg.exec(link)?.[0]
};
} else if (arxivReg.test(link)) {
return {
name: 'ArXiv论文',
summaryLink: arxivReg.exec(link)?.[0]
};
} else {
logger.error("[R插件][总结模块] 内容评估出错...");
throw Error("内容评估出错...");
}
}
/**
* 哔哩哔哩下载
* @param title

View File

@ -0,0 +1,29 @@
/**
* 内容评估器
* @link {weixin}
* @param link 链接
*/
export function contentEstimator(link) {
const wxReg = /(?:https?:\/\/)?mp\.weixin\.qq\.com\/[A-Za-z\d._?%&+\-=\/#]*/;
const arxivReg = /(?:https?:\/\/)?arxiv.org\/[a-zA-Z\d._?%&+\-=\/#]*/;
const sspaiReg = /(?:https?:\/\/)?sspai.com\/[a-zA-Z\d._?%&+\-=\/#]*/;
if (wxReg.test(link)) {
return {
name: '微信文章',
summaryLink: wxReg.exec(link)?.[0]
};
} else if (arxivReg.test(link)) {
return {
name: 'ArXiv论文',
summaryLink: arxivReg.exec(link)?.[0]
};
} else if (sspaiReg.test(link)) {
return {
name: '少数派',
summaryLink: sspaiReg.execSync(link)?.[0]
}
} else {
logger.error("[R插件][总结模块] 内容评估出错...");
throw Error("内容评估出错...");
}
}