mirror of
https://github.com/Jerryplusy/rc-plugin.git
synced 2025-10-14 16:19:18 +00:00
✨ feat: 新增实验指令:#ocr 对截图的内容进行总结
This commit is contained in:
parent
b7c11826cd
commit
3b1dad368e
@ -33,6 +33,10 @@ export class tools extends plugin {
|
|||||||
reg: "^(翻|trans)(.*)$",
|
reg: "^(翻|trans)(.*)$",
|
||||||
fnc: "trans",
|
fnc: "trans",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
reg: "^#ocr$",
|
||||||
|
fnc: "ocr2anything",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
reg: "(v.douyin.com)",
|
reg: "(v.douyin.com)",
|
||||||
fnc: "douyin",
|
fnc: "douyin",
|
||||||
@ -137,6 +141,46 @@ export class tools extends plugin {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 图像识别文字
|
||||||
|
async ocr2anything(e) {
|
||||||
|
e.reply(" 👀请发送图片")
|
||||||
|
this.setContext("ocr2anythingContext");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 图像识别文字核心
|
||||||
|
* @link{ocr2anythingContext} 的上下文
|
||||||
|
* @return Promise{void}
|
||||||
|
**/
|
||||||
|
async ocr2anythingContext() {
|
||||||
|
// 当前消息
|
||||||
|
const curMsg = this.e;
|
||||||
|
try {
|
||||||
|
const defaultPath = `${this.defaultPath}${this.e.group_id || this.e.user_id}`
|
||||||
|
await this.downloadImg(curMsg.img, defaultPath, "temp.jpg").then(async _ => {
|
||||||
|
const ocrRst = await Bot.imageOcr(`${defaultPath}/temp.jpg`);
|
||||||
|
const wordList = ocrRst.wordslist;
|
||||||
|
let prompt = wordList.map(item => item.words);
|
||||||
|
logger.info(prompt)
|
||||||
|
if (this.openaiAccessToken) {
|
||||||
|
prompt = "Summarize the key points of this article in Chinese and in a list of points. Choose an appropriate emoji for each bullet point. Each bullet point format is [emoji] - [text]." + prompt.join(" ")
|
||||||
|
const response = await this.chatGptClient.sendMessage(prompt);
|
||||||
|
// 暂时不设计上下文
|
||||||
|
prompt = response.response;
|
||||||
|
} else {
|
||||||
|
prompt = prompt.join("\n")
|
||||||
|
}
|
||||||
|
curMsg.reply(prompt);
|
||||||
|
});
|
||||||
|
} catch (err) {
|
||||||
|
curMsg.reply("OCR失败")
|
||||||
|
} finally {
|
||||||
|
this.finish("ocr2anythingContext")
|
||||||
|
}
|
||||||
|
this.finish("ocr2anythingContext")
|
||||||
|
}
|
||||||
|
|
||||||
// 抖音解析
|
// 抖音解析
|
||||||
async douyin(e) {
|
async douyin(e) {
|
||||||
const urlRex = /(http:|https:)\/\/v.douyin.com\/[A-Za-z\d._?%&+\-=\/#]*/g;
|
const urlRex = /(http:|https:)\/\/v.douyin.com\/[A-Za-z\d._?%&+\-=\/#]*/g;
|
||||||
|
@ -64,3 +64,6 @@
|
|||||||
- icon: update
|
- icon: update
|
||||||
title: "#R插件更新"
|
title: "#R插件更新"
|
||||||
desc: "进行更新R插件"
|
desc: "进行更新R插件"
|
||||||
|
- icon: computer
|
||||||
|
title: "【实验指令】#ocr"
|
||||||
|
desc: "基于gpt的识图总结"
|
Loading…
x
Reference in New Issue
Block a user