mirror of
https://github.com/Jerryplusy/rc-plugin.git
synced 2025-10-14 16:19:18 +00:00
✨ feat: 1.0.8 增加搜书功能
This commit is contained in:
parent
35654ec0bd
commit
21fe69a74f
108
apps/query.js
108
apps/query.js
@ -54,6 +54,14 @@ export class query extends plugin {
|
|||||||
reg: "^#青年大学习$",
|
reg: "^#青年大学习$",
|
||||||
fnc: "youthLearning",
|
fnc: "youthLearning",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
reg: "^#(搜书)(.*)$$",
|
||||||
|
fnc: "searchBook",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
reg: "^#(bookid)(.*)$$",
|
||||||
|
fnc: "searchBookById",
|
||||||
|
}
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
this.catConfig = config.getConfig("query");
|
this.catConfig = config.getConfig("query");
|
||||||
@ -430,6 +438,106 @@ export class query extends plugin {
|
|||||||
return !!(await this.reply(await Bot.makeForwardMsg(images)));
|
return !!(await this.reply(await Bot.makeForwardMsg(images)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 搜书
|
||||||
|
async searchBook(e) {
|
||||||
|
let keyword = e.msg.replace(/#|搜书/g, "").trim();
|
||||||
|
const thisBookMethod = this
|
||||||
|
const sendTemplate = {
|
||||||
|
nickname: this.e.sender.card || this.e.user_id,
|
||||||
|
user_id: this.e.user_id,
|
||||||
|
};
|
||||||
|
axios.post('https://api.ylibrary.org/api/search/', {
|
||||||
|
headers: {
|
||||||
|
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36 Edg/111.0.1660.14",
|
||||||
|
"referer": "https://search.zhelper.net/"
|
||||||
|
},
|
||||||
|
"keyword": keyword,
|
||||||
|
"page": 1,
|
||||||
|
"sensitive": false
|
||||||
|
}).then(async resp => {
|
||||||
|
const dataBook = resp.data.data;
|
||||||
|
let bookMsg = []
|
||||||
|
await dataBook.forEach(item => {
|
||||||
|
const { title, author, publisher, isbn, extension, filesize, year, id, source } = item
|
||||||
|
bookMsg.push({
|
||||||
|
message: { type: "text", text: `${id}: <${title}>\n`
|
||||||
|
+ `作者:${author}\n`
|
||||||
|
+ `书籍类型:${extension}\n`
|
||||||
|
+ `出版年月:${year}\n`
|
||||||
|
+ `来源:${source}`
|
||||||
|
},
|
||||||
|
...sendTemplate,
|
||||||
|
})
|
||||||
|
})
|
||||||
|
await e.reply(await Bot.makeForwardMsg(bookMsg))
|
||||||
|
await e.reply("请选择一个你想要的ID、来源,例如:11918807 zlibrary(只回复11918807默认zlibrary)")
|
||||||
|
|
||||||
|
thisBookMethod.setContext("searchBookContext");
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 通过id搜书
|
||||||
|
async searchBookById(e) {
|
||||||
|
let keyword = e.msg.replace(/#|bookkey/g, "").trim();
|
||||||
|
let id, source;
|
||||||
|
if (keyword.includes(" ")) {
|
||||||
|
[id, source] = keyword.split(" ")
|
||||||
|
} else {
|
||||||
|
id = /\d+/.exec(keyword)[0];
|
||||||
|
source = ""
|
||||||
|
}
|
||||||
|
await this.getBookDetail(e, id, source)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @link searchBookById 的上下文
|
||||||
|
* @returns {Promise<void>}
|
||||||
|
*/
|
||||||
|
async searchBookContext() {
|
||||||
|
// 当前消息
|
||||||
|
const curMsg = this.e;
|
||||||
|
// 上一个消息
|
||||||
|
// const preMsg = this.getContext();
|
||||||
|
if (!curMsg.msg) {
|
||||||
|
this.e.reply("请回复id和来源!")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// 获取id和来源
|
||||||
|
let id, source;
|
||||||
|
if (curMsg.msg.includes(" ")) {
|
||||||
|
[id, source] = curMsg.msg.split(" ")
|
||||||
|
} else {
|
||||||
|
id = /\d+/.exec(curMsg.msg)[0];
|
||||||
|
source = ""
|
||||||
|
}
|
||||||
|
await this.getBookDetail(curMsg, id, source)
|
||||||
|
this.finish("searchBookContext");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取书籍下载方式
|
||||||
|
* @param e
|
||||||
|
* @param id
|
||||||
|
* @param source
|
||||||
|
* @returns {Promise<AxiosResponse<any>>}
|
||||||
|
*/
|
||||||
|
async getBookDetail(e, id, source) {
|
||||||
|
return axios.post('https://api.ylibrary.org/api/detail/', {
|
||||||
|
headers: {
|
||||||
|
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36 Edg/111.0.1660.14",
|
||||||
|
"referer": "https://search.zhelper.net/"
|
||||||
|
},
|
||||||
|
"id": id,
|
||||||
|
"source": source || "zlibrary",
|
||||||
|
}).then(resp => {
|
||||||
|
const detailData = resp.data;
|
||||||
|
const Libgen = `https://libgendown.1kbtool.com/${detailData.md5}`
|
||||||
|
const ipfs = `https://ipfs-checker.1kbtool.com/${detailData.ipfs_cid}`
|
||||||
|
e.reply(`方式一:${Libgen}\n` +
|
||||||
|
`方式二:${ipfs}`)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// 删除标签
|
// 删除标签
|
||||||
removeTag(title) {
|
removeTag(title) {
|
||||||
const titleRex = /<[^>]+>/g;
|
const titleRex = /<[^>]+>/g;
|
||||||
|
@ -24,6 +24,9 @@
|
|||||||
- icon: youthLearning
|
- icon: youthLearning
|
||||||
title: "#青年大学习"
|
title: "#青年大学习"
|
||||||
desc: 青年大学习答案和截图
|
desc: 青年大学习答案和截图
|
||||||
|
- icon: searchBook
|
||||||
|
title: "#搜书/#bookid"
|
||||||
|
desc: 基于zli的搜书功能
|
||||||
- group: 工具类合集
|
- group: 工具类合集
|
||||||
list:
|
list:
|
||||||
- icon: translate
|
- icon: translate
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
- {
|
- {
|
||||||
version: 1.0.7,
|
version: 1.0.8,
|
||||||
data:
|
data:
|
||||||
[
|
[
|
||||||
|
增加<span class="cmd">#搜书</span>查询,
|
||||||
|
增加<span class="cmd">#青年大学习/span>查询,
|
||||||
增加<span class="cmd">SCI论文</span>解析,
|
增加<span class="cmd">SCI论文</span>解析,
|
||||||
适配<span class="cmd">锅巴</span>插件,方便查看和修改配置,
|
适配<span class="cmd">锅巴</span>插件,方便查看和修改配置,
|
||||||
增加<span class="cmd">小红书</span>的图片解析,
|
增加<span class="cmd">小红书</span>的图片解析,
|
||||||
|
BIN
resources/img/icon/searchBook.png
Normal file
BIN
resources/img/icon/searchBook.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 26 KiB |
Loading…
x
Reference in New Issue
Block a user