mirror of
https://github.com/Jerryplusy/rc-plugin.git
synced 2025-10-14 16:19:18 +00:00
✨ feat: 增强wiki
This commit is contained in:
parent
46a1e209b7
commit
9d387df11f
@ -43,7 +43,7 @@ export class tools extends plugin {
|
|||||||
// 视频保存路径
|
// 视频保存路径
|
||||||
this.defaultPath = `./data/rcmp4/`
|
this.defaultPath = `./data/rcmp4/`
|
||||||
// redis的key
|
// redis的key
|
||||||
this.redisKey = `Yz:tools:cache:${this.e.group_id}`
|
this.redisKey = `Yz:tools:cache:${this.group_id}`
|
||||||
}
|
}
|
||||||
|
|
||||||
// 翻译插件
|
// 翻译插件
|
||||||
@ -153,18 +153,39 @@ 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=bd&msg=${ encodeURI(key) }`
|
const url = `https://xiaoapi.cn/API/bk.php?m=json&type=bd&msg=${ encodeURI(key) }`
|
||||||
await axios.get(url, {
|
const url2 = 'https://api.jikipedia.com/go/auto_complete'
|
||||||
headers: {
|
Promise.all([
|
||||||
"User-Agent":
|
axios.post(url2, {
|
||||||
"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",
|
headers: {
|
||||||
},
|
"User-Agent":
|
||||||
timeout: 10000,
|
"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",
|
||||||
.then(resp => {
|
},
|
||||||
const data = resp.data
|
timeout: 10000,
|
||||||
|
"phrase": key,
|
||||||
|
})
|
||||||
|
.then(resp => {
|
||||||
|
const data = resp.data.data
|
||||||
|
return data[0].entities[0];
|
||||||
|
}),
|
||||||
|
axios.get(url, {
|
||||||
|
headers: {
|
||||||
|
"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",
|
||||||
|
},
|
||||||
|
timeout: 10000,
|
||||||
|
})
|
||||||
|
.then(resp => {
|
||||||
|
return resp.data
|
||||||
|
})
|
||||||
|
])
|
||||||
|
.then(res => {
|
||||||
|
const data = res[1]
|
||||||
|
const data2 = res[0]
|
||||||
const template = `
|
const template = `
|
||||||
解释:${ _.isUndefined(data.msg) ? '暂无' : data.msg }\n
|
解释:${ _.isUndefined(data.msg) ? '暂无' : data.msg }\n
|
||||||
详情:${ _.isUndefined(data.more) ? '暂无' : data.more }\n
|
详情:${ _.isUndefined(data.more) ? '暂无' : data.more }\n
|
||||||
|
小鸡解释:${ _.isUndefined(data2.content) ? '暂无' : data2.content }
|
||||||
`;
|
`;
|
||||||
e.reply(template)
|
e.reply(template)
|
||||||
})
|
})
|
||||||
@ -198,7 +219,6 @@ export class tools extends plugin {
|
|||||||
if (!fs.existsSync(this.defaultPath)) {
|
if (!fs.existsSync(this.defaultPath)) {
|
||||||
mkdirsSync(this.defaultPath);
|
mkdirsSync(this.defaultPath);
|
||||||
}
|
}
|
||||||
const redisObj = get(this.redisKey)
|
|
||||||
const target = this.defaultPath + `${ this.e.group_id || this.e.user_id }/temp.mp4`
|
const target = this.defaultPath + `${ this.e.group_id || this.e.user_id }/temp.mp4`
|
||||||
// 待优化
|
// 待优化
|
||||||
if (fs.existsSync(target)) {
|
if (fs.existsSync(target)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user