mirror of
https://github.com/Jerryplusy/rc-plugin.git
synced 2025-10-14 08:09:19 +00:00
✨ feat: V1.4.5 恢复网易云解析
1. 调整wiki功能的位置 2. 恢复netease music解析
This commit is contained in:
parent
146add24a0
commit
ce2729d5c6
@ -58,6 +58,10 @@ export class query extends plugin {
|
||||
reg: "^#竹白(.*)",
|
||||
fnc: "zhubaiSearch",
|
||||
},
|
||||
{
|
||||
reg: "^#(wiki|百科)(.*)$",
|
||||
fnc: "wiki",
|
||||
}
|
||||
],
|
||||
});
|
||||
}
|
||||
@ -372,6 +376,51 @@ export class query extends plugin {
|
||||
return true;
|
||||
}
|
||||
|
||||
// 百科
|
||||
async wiki(e) {
|
||||
const key = e.msg.replace(/#|百科|wiki/g, "").trim();
|
||||
const url = `https://xiaoapi.cn/API/bk.php?m=json&type=sg&msg=${ encodeURI(key) }`;
|
||||
const bdUrl = `https://xiaoapi.cn/API/bk.php?m=json&type=bd&msg=${ encodeURI(key) }`;
|
||||
const bkRes = await Promise.all([
|
||||
axios
|
||||
.get(bdUrl, {
|
||||
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;
|
||||
}),
|
||||
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(async res => {
|
||||
return res.map(item => {
|
||||
return {
|
||||
message: `
|
||||
解释:${ _.get(item, "msg") }\n
|
||||
详情:${ _.get(item, "more") }\n
|
||||
`,
|
||||
nickname: e.sender.card || e.user_id,
|
||||
user_id: e.user_id,
|
||||
};
|
||||
});
|
||||
// 小鸡解释:${ _.get(data2, 'content') }
|
||||
});
|
||||
await e.reply(await Bot.makeForwardMsg(bkRes));
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 限制用户调用(默认1分钟1次)
|
||||
* @param e
|
||||
|
111
apps/tools.js
111
apps/tools.js
@ -26,7 +26,14 @@ import {
|
||||
TWITTER_BEARER_TOKEN,
|
||||
XHS_NO_WATERMARK_HEADER,
|
||||
} from "../constants/constant.js";
|
||||
import { containsChinese, downloadImg, formatBiliInfo, getIdVideo, secondsToTime } from "../utils/common.js";
|
||||
import {
|
||||
containsChinese,
|
||||
downloadImg,
|
||||
downloadMp3,
|
||||
formatBiliInfo,
|
||||
getIdVideo,
|
||||
secondsToTime
|
||||
} from "../utils/common.js";
|
||||
import config from "../model/index.js";
|
||||
import Translate from "../utils/trans-strategy.js";
|
||||
import * as xBogus from "../utils/x-bogus.cjs";
|
||||
@ -87,10 +94,6 @@ export class tools extends plugin {
|
||||
reg: "(bilibili.com|b23.tv|t.bilibili.com)",
|
||||
fnc: "bili",
|
||||
},
|
||||
{
|
||||
reg: "^#(wiki|百科)(.*)$",
|
||||
fnc: "wiki",
|
||||
},
|
||||
{
|
||||
reg: "(x.com)",
|
||||
fnc: "twitter_x",
|
||||
@ -140,6 +143,10 @@ export class tools extends plugin {
|
||||
{
|
||||
reg: "(miyoushe.com)",
|
||||
fnc: "miyoushe"
|
||||
},
|
||||
{
|
||||
reg: "(music.163.com|163cn.tv)",
|
||||
fnc: "netease",
|
||||
}
|
||||
],
|
||||
});
|
||||
@ -492,51 +499,6 @@ export class tools extends plugin {
|
||||
})
|
||||
}
|
||||
|
||||
// 百科
|
||||
async wiki(e) {
|
||||
const key = e.msg.replace(/#|百科|wiki/g, "").trim();
|
||||
const url = `https://xiaoapi.cn/API/bk.php?m=json&type=sg&msg=${ encodeURI(key) }`;
|
||||
const bdUrl = `https://xiaoapi.cn/API/bk.php?m=json&type=bd&msg=${ encodeURI(key) }`;
|
||||
const bkRes = await Promise.all([
|
||||
axios
|
||||
.get(bdUrl, {
|
||||
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;
|
||||
}),
|
||||
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(async res => {
|
||||
return res.map(item => {
|
||||
return {
|
||||
message: `
|
||||
解释:${ _.get(item, "msg") }\n
|
||||
详情:${ _.get(item, "more") }\n
|
||||
`,
|
||||
nickname: e.sender.card || e.user_id,
|
||||
user_id: e.user_id,
|
||||
};
|
||||
});
|
||||
// 小鸡解释:${ _.get(data2, 'content') }
|
||||
});
|
||||
await e.reply(await Bot.makeForwardMsg(bkRes));
|
||||
return true;
|
||||
}
|
||||
|
||||
// 例子:https://twitter.com/chonkyanimalx/status/1595834168000204800
|
||||
async twitter(e) {
|
||||
// 配置参数及解析
|
||||
@ -915,6 +877,55 @@ export class tools extends plugin {
|
||||
return true;
|
||||
}
|
||||
|
||||
// 网易云解析
|
||||
async netease(e) {
|
||||
let message =
|
||||
e.msg === undefined ? e.message.shift().data.replaceAll("\\", "") : e.msg.trim();
|
||||
const musicUrlReg = /(http:|https:)\/\/music.163.com\/song\/media\/outer\/url\?id=(\d+)/;
|
||||
const musicUrlReg2 = /(http:|https:)\/\/y.music.163.com\/m\/song\?(.*)&id=(\d+)/;
|
||||
const id =
|
||||
musicUrlReg2.exec(message)?.[3] ||
|
||||
musicUrlReg.exec(message)?.[2] ||
|
||||
/id=(\d+)/.exec(message)[1];
|
||||
// 如果没有下载地址跳出if
|
||||
if (_.isEmpty(id)) {
|
||||
e.reply(`识别:网易云音乐,解析失败!`);
|
||||
return
|
||||
}
|
||||
if (typeof message !== "string") {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
// 小程序
|
||||
const musicJson = JSON.parse(message);
|
||||
const { preview, title, desc } = musicJson.meta.music || musicJson.meta.news;
|
||||
e.reply([`识别:网易云音乐,${title}--${desc}`, segment.image(preview)]);
|
||||
JSON.parse(message);
|
||||
return true;
|
||||
} catch (err) {
|
||||
axios.get(`https://www.oranges1.top/neteaseapi.do/song/url?id=${id}`, {
|
||||
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",
|
||||
},
|
||||
}).then(async resp => {
|
||||
const url = await resp.data.data?.[0].url;
|
||||
const title = await axios.get(`https://www.oranges1.top/neteaseapi.do/song/detail?ids=${id}`).then(res => {
|
||||
const song = res.data.songs[0];
|
||||
return `${song?.name}-${song?.ar?.[0].name}`.replace(/[\/\?<>\\:\*\|".… ]/g, "");
|
||||
});
|
||||
e.reply(`识别:网易云音乐,${title}`);
|
||||
downloadMp3(url, 'follow').then(path => {
|
||||
Bot.acquireGfs(e.group_id).upload(fs.readFileSync(path), '/', `${title.replace(/[\/\?<>\\:\*\|".… ]/g, '')}.mp3`)
|
||||
})
|
||||
.catch(err => {
|
||||
console.error(`下载音乐失败,错误信息为: ${err.message}`);
|
||||
});
|
||||
})
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 快手解析
|
||||
* @param e
|
||||
|
@ -24,14 +24,14 @@
|
||||
- icon: zhubai
|
||||
title: "#竹白"
|
||||
desc: 基于竹白百科的搜索
|
||||
- icon: 百科
|
||||
title: "#百科/wiki xxx"
|
||||
desc: 百度百科/搜狗百科
|
||||
- group: 工具类合集
|
||||
list:
|
||||
- icon: translate
|
||||
title: "翻中/英/日 xxx"
|
||||
desc: 百度翻译,例如:翻中 I want it!
|
||||
- icon: 百科
|
||||
title: "#百科/wiki xxx"
|
||||
desc: 百度百科/搜狗百科
|
||||
desc: R插件翻译引擎
|
||||
- icon: tiktok
|
||||
title: "xxxv.douyin.com"
|
||||
desc: 抖音分享实时下载
|
||||
|
@ -1,5 +1,5 @@
|
||||
- {
|
||||
version: 1.4.4,
|
||||
version: 1.4.5,
|
||||
data:
|
||||
[
|
||||
新增<span class="cmd">米游社解析</span>功能,
|
||||
|
Loading…
x
Reference in New Issue
Block a user