mirror of
https://github.com/Jerryplusy/rc-plugin.git
synced 2025-10-14 16:19:18 +00:00
↩ revert: 退回安全检测
This commit is contained in:
parent
deb5cd52d9
commit
bb5caffb73
@ -54,7 +54,7 @@ export class query extends plugin {
|
|||||||
{
|
{
|
||||||
reg: "^#竹白(.*)",
|
reg: "^#竹白(.*)",
|
||||||
fnc: "zhubaiSearch",
|
fnc: "zhubaiSearch",
|
||||||
},
|
}
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -63,9 +63,7 @@ export class query extends plugin {
|
|||||||
const keyword = e.msg.replace("#医药查询", "").trim();
|
const keyword = e.msg.replace("#医药查询", "").trim();
|
||||||
const url = `https://api2.dayi.org.cn/api/search2?keyword=${keyword}&pageNo=1&pageSize=10`;
|
const url = `https://api2.dayi.org.cn/api/search2?keyword=${keyword}&pageNo=1&pageSize=10`;
|
||||||
try {
|
try {
|
||||||
const res = await fetch(url)
|
const res = await fetch(url).then(resp => resp.json()).then(resp => resp.list);
|
||||||
.then(resp => resp.json())
|
|
||||||
.then(resp => resp.list);
|
|
||||||
const promises = res.map(async element => {
|
const promises = res.map(async element => {
|
||||||
const title = this.removeTag(element.title);
|
const title = this.removeTag(element.title);
|
||||||
const template = `${title}\n标签:${element.secondTitle}\n介绍:${element.introduction}`;
|
const template = `${title}\n标签:${element.secondTitle}\n介绍:${element.introduction}`;
|
||||||
@ -87,14 +85,14 @@ export class query extends plugin {
|
|||||||
return {
|
return {
|
||||||
message: {
|
message: {
|
||||||
type: "text",
|
type: "text",
|
||||||
text: template,
|
text: template
|
||||||
},
|
},
|
||||||
nickname: Bot.nickname,
|
nickname: Bot.nickname,
|
||||||
user_id: Bot.user_id,
|
user_id: Bot.user_id
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
const msg = await Promise.all(promises);
|
const msg = await Promise.all(promises);
|
||||||
e.reply(await Bot.makeForwardMsg(msg));
|
e.reply(await Bot.makeForwardMsg(msg))
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.error(err);
|
logger.error(err);
|
||||||
}
|
}
|
||||||
@ -104,9 +102,7 @@ export class query extends plugin {
|
|||||||
async cat(e) {
|
async cat(e) {
|
||||||
const [shibes, cats] = await Promise.allSettled([
|
const [shibes, cats] = await Promise.allSettled([
|
||||||
fetch(`https://shibe.online/api/cats?count=${CAT_LIMIT}`).then(data => data.json()),
|
fetch(`https://shibe.online/api/cats?count=${CAT_LIMIT}`).then(data => data.json()),
|
||||||
fetch(`https://api.thecatapi.com/v1/images/search?limit=${CAT_LIMIT}`).then(data =>
|
fetch(`https://api.thecatapi.com/v1/images/search?limit=${CAT_LIMIT}`).then(data => data.json()),
|
||||||
data.json(),
|
|
||||||
),
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const shibeUrls = shibes.status === "fulfilled" ? shibes.value : [];
|
const shibeUrls = shibes.status === "fulfilled" ? shibes.value : [];
|
||||||
@ -128,27 +124,25 @@ export class query extends plugin {
|
|||||||
// 接口
|
// 接口
|
||||||
const urls = [
|
const urls = [
|
||||||
"https://www.ghxi.com/ghapi?type=query&n=pc",
|
"https://www.ghxi.com/ghapi?type=query&n=pc",
|
||||||
"https://www.ghxi.com/ghapi?type=query&n=and",
|
"https://www.ghxi.com/ghapi?type=query&n=and"
|
||||||
];
|
];
|
||||||
// 一起请求
|
// 一起请求
|
||||||
const promises = urls.map(url =>
|
const promises = urls.map(url =>
|
||||||
fetch(url)
|
fetch(url)
|
||||||
.then(resp => resp.json())
|
.then(resp => resp.json())
|
||||||
.catch(err => logger.error(err)),
|
.catch(err => logger.error(err))
|
||||||
);
|
);
|
||||||
const results = await Promise.allSettled(promises);
|
const results = await Promise.allSettled(promises);
|
||||||
const msg = results
|
const msg = results
|
||||||
.filter(result => result.status === "fulfilled") // 只保留已解决的 Promise
|
.filter(result => result.status === 'fulfilled') // 只保留已解决的 Promise
|
||||||
.flatMap(result =>
|
.flatMap(result => result.value.data.list.map(element => {
|
||||||
result.value.data.list.map(element => {
|
|
||||||
const template = `推荐软件:${element.title}\n地址:${element.url}\n`;
|
const template = `推荐软件:${element.title}\n地址:${element.url}\n`;
|
||||||
return {
|
return {
|
||||||
message: { type: "text", text: template },
|
message: { type: "text", text: template },
|
||||||
nickname: e.sender.card || e.user_id,
|
nickname: e.sender.card || e.user_id,
|
||||||
user_id: e.user_id,
|
user_id: e.user_id
|
||||||
};
|
};
|
||||||
}),
|
}));
|
||||||
);
|
|
||||||
|
|
||||||
// 异步操作
|
// 异步操作
|
||||||
e.reply(await Bot.makeForwardMsg(msg));
|
e.reply(await Bot.makeForwardMsg(msg));
|
||||||
@ -163,9 +157,7 @@ export class query extends plugin {
|
|||||||
.then(resp => resp.imgurl);
|
.then(resp => resp.imgurl);
|
||||||
|
|
||||||
const results = await Promise.allSettled([p1, p2]);
|
const results = await Promise.allSettled([p1, p2]);
|
||||||
const images = results
|
const images = results.filter(result => result.status === "fulfilled").map(result => result.value);
|
||||||
.filter(result => result.status === "fulfilled")
|
|
||||||
.map(result => result.value);
|
|
||||||
|
|
||||||
for (const img of images) {
|
for (const img of images) {
|
||||||
e.reply(segment.image(img));
|
e.reply(segment.image(img));
|
||||||
@ -274,45 +266,43 @@ export class query extends plugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async cospro(e) {
|
async cospro(e) {
|
||||||
let [res1, res2] = (
|
let [res1, res2] = (await Promise.allSettled([
|
||||||
await Promise.allSettled([
|
|
||||||
fetch("https://imgapi.cn/cos2.php?return=jsonpro").then(resp => resp.json()),
|
fetch("https://imgapi.cn/cos2.php?return=jsonpro").then(resp => resp.json()),
|
||||||
fetch("https://imgapi.cn/cos.php?return=jsonpro").then(resp => resp.json()),
|
fetch("https://imgapi.cn/cos.php?return=jsonpro").then(resp => resp.json())
|
||||||
])
|
]))
|
||||||
)
|
.filter(result => result.status === "fulfilled").map(result => result.value);
|
||||||
.filter(result => result.status === "fulfilled")
|
let req = [
|
||||||
.map(result => result.value);
|
...res1.imgurls,
|
||||||
let req = [...res1.imgurls, ...res2.imgurls];
|
...res2.imgurls
|
||||||
|
];
|
||||||
e.reply("哪天克火掉一定是在这个群里面...");
|
e.reply("哪天克火掉一定是在这个群里面...");
|
||||||
let images = req.map(item => ({
|
let images = req.map(item => ({
|
||||||
message: segment.image(encodeURI(item)),
|
message: segment.image(encodeURI(item)),
|
||||||
nickname: this.e.sender.card || this.e.user_id,
|
nickname: this.e.sender.card || this.e.user_id,
|
||||||
user_id: this.e.user_id,
|
user_id: this.e.user_id,
|
||||||
}));
|
}));
|
||||||
e.reply(await Bot.makeForwardMsg(images));
|
e.reply(await Bot.makeForwardMsg(images))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 搜书
|
// 搜书
|
||||||
async searchBook(e) {
|
async searchBook(e) {
|
||||||
let keyword = e.msg.replace(/#|搜书/g).trim();
|
let keyword = e.msg.replace(/#|搜书/g, "").trim();
|
||||||
if (!keyword) {
|
if (!keyword) {
|
||||||
e.reply("请输入书名,例如:#搜书 非暴力沟通");
|
e.reply("请输入书名,例如:#搜书 非暴力沟通");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// 对输入的书名进行安全过滤
|
|
||||||
const safeKeyword = keyword.replace(/[^\w\s]/g);
|
|
||||||
|
|
||||||
const replyMessage = async msg => {
|
const replyMessage = async (msg) => {
|
||||||
if (msg && msg.length > 0) {
|
if (msg && msg.length > 0) {
|
||||||
await e.reply(await Bot.makeForwardMsg(msg));
|
await e.reply(await Bot.makeForwardMsg(msg));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// const [zHelper, yiBook] = await Promise.all([getZHelper(e, keyword), getYiBook(e, keyword)]);
|
const [/*zHelper, yiBook, */zBook] = await Promise.all([/*getZHelper(e, keyword), getYiBook(e, keyword), */getZBook(e, keyword)]);
|
||||||
|
|
||||||
// replyMessage(yiBook);
|
// replyMessage(yiBook);
|
||||||
const zBook = await getZBook(e, safeKeyword);
|
replyMessage(zBook);
|
||||||
await replyMessage(zBook);
|
|
||||||
|
|
||||||
/*if (zHelper && zHelper.length > 0) {
|
/*if (zHelper && zHelper.length > 0) {
|
||||||
await replyMessage(zHelper);
|
await replyMessage(zHelper);
|
||||||
@ -327,6 +317,7 @@ export class query extends plugin {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 通过id搜书
|
// 通过id搜书
|
||||||
async searchBookById(e) {
|
async searchBookById(e) {
|
||||||
let keyword = e.msg.replace(/#bookid/, "").trim();
|
let keyword = e.msg.replace(/#bookid/, "").trim();
|
||||||
@ -379,35 +370,27 @@ export class query extends plugin {
|
|||||||
e.reply("请输入想了解的内容,例如:#竹白 javascript");
|
e.reply("请输入想了解的内容,例如:#竹白 javascript");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
await axios
|
await axios.post("https://open.zhubai.wiki/a/zb/s/ep/", {
|
||||||
.post(
|
"content": 1,
|
||||||
"https://open.zhubai.wiki/a/zb/s/ep/",
|
"keyword": keyword
|
||||||
{
|
}, {
|
||||||
content: 1,
|
|
||||||
keyword: keyword,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
headers: {
|
headers: {
|
||||||
"User-Agent":
|
"User-Agent":
|
||||||
"Mozilla/5.0 (Linux; Android 5.0; SM-G900P Build/LRX21T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.25 Mobile Safari/537.36",
|
"Mozilla/5.0 (Linux; Android 5.0; SM-G900P Build/LRX21T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.25 Mobile Safari/537.36",
|
||||||
},
|
}
|
||||||
},
|
}).then(async resp => {
|
||||||
)
|
|
||||||
.then(async resp => {
|
|
||||||
const res = resp.data.data;
|
const res = resp.data.data;
|
||||||
const content = await res.map(item => {
|
const content = await res.map(item => {
|
||||||
const { pn, pa, zn, lu, pu, pq, aa, hl } = item;
|
const {pn, pa, zn, lu, pu, pq, aa, hl } = item;
|
||||||
const template = `标题:${pn}\n${pa}\n期刊:${zn}\n发布日期距今:${lu}\n链接1:${pu}\n链接2:${pq}\n\n 大致描述:${hl
|
const template = `标题:${pn}\n${pa}\n期刊:${zn}\n发布日期距今:${lu}\n链接1:${pu}\n链接2:${pq}\n\n 大致描述:${hl.join("\n").replace(/<\/?font[^>]*>/g, '')}`
|
||||||
.join("\n")
|
|
||||||
.replace(/<\/?font[^>]*>/g, "")}`;
|
|
||||||
return {
|
return {
|
||||||
message: [segment.image(aa), template],
|
message: [segment.image(aa), template],
|
||||||
nickname: this.e.sender.card || this.e.user_id,
|
nickname: this.e.sender.card || this.e.user_id,
|
||||||
user_id: this.e.user_id,
|
user_id: this.e.user_id,
|
||||||
};
|
}
|
||||||
});
|
})
|
||||||
e.reply(await Bot.makeForwardMsg(content));
|
e.reply(await Bot.makeForwardMsg(content));
|
||||||
});
|
})
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user