From c4c8eaeb8538b648da9a86a1c11ed137483162b8 Mon Sep 17 00:00:00 2001
From: zhiyu1998 <542716863@qq.com>
Date: Thu, 19 Sep 2024 22:56:41 +0800
Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20=E6=96=B0=E5=A2=9E=20`#rso`?=
=?UTF-8?q?=20=E6=90=9C=E7=B4=A2=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 在 config/version.yaml 中新增 rso 搜索功能,优化队列下载和 GPT 功能
- 增加哔哩哔哩下载分辨率设置功能,新增自定义识别功能
- 支持锅巴插件,方便查看和修改配置
- 更新 query.js 文件,增加必应搜索功能支持
- 优化常量配置,增加 BING_SEARCH 常量,支持新的搜索功能
---
apps/query.js | 22 ++++++++++++++++++++++
config/version.yaml | 2 +-
constants/query.js | 8 +++++++-
3 files changed, 30 insertions(+), 2 deletions(-)
diff --git a/apps/query.js b/apps/query.js
index e8459b5..1860a08 100644
--- a/apps/query.js
+++ b/apps/query.js
@@ -4,6 +4,7 @@ import fetch from "node-fetch";
// 常量
import { CAT_LIMIT, COMMON_USER_AGENT } from "../constants/constant.js";
import {
+ BING_SEARCH,
LINUX_AI_PROMPT,
LINUX_QUERY,
RDOC_AI_PROMPT,
@@ -63,6 +64,10 @@ export class query extends plugin {
{
reg: "^#R文档(.*)",
fnc: "intelligentDoc",
+ },
+ {
+ ret: "^#(R|r)so(.*)",
+ fnc: "rso",
}
],
});
@@ -394,6 +399,23 @@ export class query extends plugin {
return;
}
+ async rso(e) {
+ const question = e.msg.replace("#Rso", "").replace("#rso", "").trim();
+ logger.info(question);
+ const resp = await fetch(BING_SEARCH.replace("{}", question), {
+ headers: {
+ "User-Agent": COMMON_USER_AGENT,
+ }
+ });
+ logger.info(await resp);
+ const respJson = (await resp.json()).data;
+ const constructSearchRes = textArrayToMakeForward(e, respJson.map(item =>
+ `标题:《${ item.title }》\n📝 简要:${ item.abstract }\n➡️链接:${ item.href }`
+ ));
+ await e.reply(Bot.makeForwardMsg(constructSearchRes));
+ return;
+ }
+
// 删除标签
removeTag(title) {
const titleRex = /<[^>]+>/g;
diff --git a/config/version.yaml b/config/version.yaml
index 3f53ec7..f8e4610 100644
--- a/config/version.yaml
+++ b/config/version.yaml
@@ -2,10 +2,10 @@
version: 1.9.0,
data:
[
+ 新增rso搜索功能,
优化队列下载和GPT功能,
新增哔哩哔哩下载分辨率设置功能,
新增自定义识别功能,
- 修正油管分辨率降低到720P功能,
支持锅巴插件,方便查看和修改配置,
输入#R帮助获取插件帮助,
输入#R更新更新插件,
diff --git a/constants/query.js b/constants/query.js
index 377caef..bb46db7 100644
--- a/constants/query.js
+++ b/constants/query.js
@@ -2,7 +2,13 @@
* linux 命令查询
* @type {string}
*/
-export const LINUX_QUERY = "https://api.pearktrue.cn/api/linux/?keyword={}"
+export const LINUX_QUERY = "https://api.pearktrue.cn/api/linux/?keyword={}";
+
+/**
+ * 必应搜索
+ * @type {string}
+ */
+export const BING_SEARCH = "https://api.pearktrue.cn/api/bingsearch/?search={}";
export const RDOC_LINK = "https://gitee.com/kyrzy0416/rconsole-plugin/raw/docs/posts/QA%E5%AE%98%E6%96%B9%E8%A7%A3%E7%AD%94.md";