mirror of
https://github.com/Jerryplusy/rc-plugin.git
synced 2025-10-14 16:19:18 +00:00
🦄 refactor: 重构wiki
This commit is contained in:
parent
c7c819878c
commit
5011aa5d3d
@ -396,24 +396,17 @@ export class tools extends plugin {
|
|||||||
async wiki(e) {
|
async wiki(e) {
|
||||||
const key = e.msg.replace(/#|百科|wiki/g, "").trim();
|
const key = e.msg.replace(/#|百科|wiki/g, "").trim();
|
||||||
const url = `https://xiaoapi.cn/API/bk.php?m=json&type=sg&msg=${encodeURI(key)}`;
|
const url = `https://xiaoapi.cn/API/bk.php?m=json&type=sg&msg=${encodeURI(key)}`;
|
||||||
// const url2 = 'https://api.jikipedia.com/go/auto_complete'
|
const bdUrl = `https://xiaoapi.cn/API/bk.php?m=json&type=bd&msg=${encodeURI(key)}`;
|
||||||
Promise.all([
|
const bkRes = await Promise.all([
|
||||||
// axios.post(url2, {
|
axios.get(bdUrl, {
|
||||||
// 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",
|
||||||
// "Content-Type": "application/json",
|
},
|
||||||
// },
|
timeout: 10000,
|
||||||
// timeout: 10000,
|
}).then(resp => {
|
||||||
// "phrase": key,
|
return resp.data;
|
||||||
// })
|
}),
|
||||||
// .then(resp => {
|
|
||||||
// const data = resp.data.data
|
|
||||||
// if (_.isEmpty(data)) {
|
|
||||||
// return data;
|
|
||||||
// }
|
|
||||||
// return data[0].entities[0];
|
|
||||||
// }),
|
|
||||||
axios
|
axios
|
||||||
.get(url, {
|
.get(url, {
|
||||||
headers: {
|
headers: {
|
||||||
@ -425,16 +418,21 @@ export class tools extends plugin {
|
|||||||
.then(resp => {
|
.then(resp => {
|
||||||
return resp.data;
|
return resp.data;
|
||||||
}),
|
}),
|
||||||
]).then(res => {
|
]).then(async res => {
|
||||||
const data = res[0];
|
return res.map(item => {
|
||||||
// const data2 = res[0]
|
return {
|
||||||
const template = `
|
message: `
|
||||||
解释:${_.get(data, "msg")}\n
|
解释:${_.get(item, "msg")}\n
|
||||||
详情:${_.get(data, "more")}\n
|
详情:${_.get(item, "more")}\n
|
||||||
`;
|
`,
|
||||||
|
nickname: e.sender.card || e.user_id,
|
||||||
|
user_id: e.user_id,
|
||||||
|
}
|
||||||
|
})
|
||||||
// 小鸡解释:${ _.get(data2, 'content') }
|
// 小鸡解释:${ _.get(data2, 'content') }
|
||||||
e.reply(template);
|
|
||||||
});
|
});
|
||||||
|
await e.reply(await Bot.makeForwardMsg(bkRes));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user