mirror of
https://github.com/Jerryplusy/rc-plugin.git
synced 2025-10-14 16:19:18 +00:00
🎈 pref: 优化代码
This commit is contained in:
parent
25a7c39d91
commit
6f809cd6ee
109
apps/tools.js
109
apps/tools.js
@ -1380,61 +1380,62 @@ export class tools extends plugin {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 网易云登录状态
|
// 网易云登录状态
|
||||||
async neteaseStatus(e, reck) {
|
async neteaseStatus(e, reck) {
|
||||||
// 优先判断是否使用自建 API
|
// 优先判断是否使用自建 API
|
||||||
let autoSelectNeteaseApi
|
let autoSelectNeteaseApi
|
||||||
// 判断海外
|
// 判断海外
|
||||||
const isOversea = await this.isOverseasServer();
|
const isOversea = await this.isOverseasServer();
|
||||||
if (this.useLocalNeteaseAPI) {
|
if (this.useLocalNeteaseAPI) {
|
||||||
// 使用自建 API
|
// 使用自建 API
|
||||||
autoSelectNeteaseApi = this.neteaseCloudAPIServer
|
autoSelectNeteaseApi = this.neteaseCloudAPIServer
|
||||||
} else {
|
} else {
|
||||||
// 自动选择 API
|
// 自动选择 API
|
||||||
autoSelectNeteaseApi = isOversea ? NETEASE_SONG_DOWNLOAD : NETEASE_API_CN;
|
autoSelectNeteaseApi = isOversea ? NETEASE_SONG_DOWNLOAD : NETEASE_API_CN;
|
||||||
}
|
|
||||||
const statusUrl = autoSelectNeteaseApi + '/login/status'
|
|
||||||
axios.get(statusUrl, {
|
|
||||||
headers: {
|
|
||||||
"User-Agent": COMMON_USER_AGENT,
|
|
||||||
"Cookie": reck ? reck : this.neteaseCookie
|
|
||||||
},
|
|
||||||
}).then(res => {
|
|
||||||
// logger.info('登录状态', res.data)
|
|
||||||
const userInfo = res.data.data.profile
|
|
||||||
if (userInfo) {
|
|
||||||
axios.get(`${autoSelectNeteaseApi}/vip/info?uid=${userInfo.userId}`, {
|
|
||||||
headers: {
|
|
||||||
"User-Agent": COMMON_USER_AGENT,
|
|
||||||
"Cookie": reck ? reck : this.neteaseCookie
|
|
||||||
},
|
|
||||||
}).then(res => {
|
|
||||||
// logger.info('vip信息', res.data)
|
|
||||||
const vipInfo = res.data.data
|
|
||||||
if (vipInfo.redplus.vipCode != 0) {
|
|
||||||
const expireTime = new Date(vipInfo.redplus.expireTime);
|
|
||||||
if (expireTime > Date.now()) {
|
|
||||||
e.reply([segment.image(`${userInfo.avatarUrl}?param=170y170`), `网易云已登录:\n${userInfo.nickname}\n会员等级:\nSVIP${vipInfo.redplus.vipLevel}\n最高解析音质:\njymaster(超清母带)\n会员到期时间:\n${expireTime.toLocaleString()}`]);
|
|
||||||
} else {
|
|
||||||
e.reply([segment.image(`${userInfo.avatarUrl}?param=170y170`), `网易云已登录:\n${userInfo.nickname}\n会员等级:\nVIP已过期\n最高解析音质:\standard(标准)`]);
|
|
||||||
}
|
|
||||||
} else if (vipInfo.associator.vipCode != 0) {
|
|
||||||
const expireTime = new Date(vipInfo.associator.expireTime);
|
|
||||||
if (expireTime > Date.now()) {
|
|
||||||
e.reply([segment.image(`${userInfo.avatarUrl}?param=170y170`), `网易云已登录:\n${userInfo.nickname}\n会员等级:\nVIP${vipInfo.associator.vipLevel}\n最高解析音质:\nlossless(无损)\n会员到期时间:\n${expireTime.toLocaleString()}`]);
|
|
||||||
} else {
|
|
||||||
e.reply([segment.image(`${userInfo.avatarUrl}?param=170y170`), `网易云已登录:\n${userInfo.nickname}\n会员等级:\nVIP已过期\n最高解析音质:\standard(标准)`]);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
e.reply([segment.image(`${userInfo.avatarUrl}?param=170y170`), `网易云已登录:\n${userInfo.nickname}\n会员等级:\nVIP已过期\n最高解析音质:\standard(标准)`]);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
// e.reply([segment.image(userInfo.avatarUrl), `网易云已登录:${userInfo.nickname}\n会员等级:\n`,segment.image(vipInfo.iconUrl)]);
|
|
||||||
} else {
|
|
||||||
e.reply('暂未登录,请发#网易云扫码登陆进行登陆绑定ck')
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
const statusUrl = autoSelectNeteaseApi + '/login/status'
|
||||||
|
axios.get(statusUrl, {
|
||||||
|
headers: {
|
||||||
|
"User-Agent": COMMON_USER_AGENT,
|
||||||
|
"Cookie": reck ? reck : this.neteaseCookie
|
||||||
|
},
|
||||||
|
}).then(res => {
|
||||||
|
logger.info('登录状态', res.data)
|
||||||
|
const userInfo = res.data.data.profile
|
||||||
|
if (userInfo) {
|
||||||
|
axios.get(`${autoSelectNeteaseApi}/vip/info?uid=${userInfo.userId}`, {
|
||||||
|
headers: {
|
||||||
|
"User-Agent": COMMON_USER_AGENT,
|
||||||
|
"Cookie": reck ? reck : this.neteaseCookie
|
||||||
|
},
|
||||||
|
}).then(res => {
|
||||||
|
logger.info('vip信息', res.data)
|
||||||
|
const vipInfo = res.data.data
|
||||||
|
const checkVipStatus = (vipLevel, expireTime, nickname, avatarUrl, e) => {
|
||||||
|
const expireDate = new Date(expireTime);
|
||||||
|
if (expireDate > Date.now()) {
|
||||||
|
e.reply([segment.image(`${avatarUrl}?param=170y170`), `网易云已登录:\n${nickname}\n会员等级:\n${vipLevel}\n会员到期时间:\n${expireDate.toLocaleString()}`]);
|
||||||
|
} else {
|
||||||
|
return false; // 返回 false 以继续检查下一个 VIP 状态
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
|
if (vipInfo.redplus.vipCode != 0 && checkVipStatus(`SVIP${vipInfo.redplus.vipLevel}\n最高解析音质:\n jymaster(超清母带)`, vipInfo.redplus.expireTime, userInfo.nickname, userInfo.avatarUrl, e)) {
|
||||||
|
// SVIP 有效,不执行后续逻辑
|
||||||
|
} else if (vipInfo.associator.vipCode != 0 && checkVipStatus(`VIP${vipInfo.associator.vipLevel}\n最高解析音质:\n jyeffect(高清环绕音)`, vipInfo.associator.expireTime, userInfo.nickname, userInfo.avatarUrl, e)) {
|
||||||
|
// VIP 有效,不执行后续逻辑
|
||||||
|
} else {
|
||||||
|
// 如果都已过期,发送 VIP 已过期信息
|
||||||
|
e.reply([segment.image(`${userInfo.avatarUrl}?param=170y170`), `网易云已登录:\n${userInfo.nickname}\n会员等级:\nVIP已过期\n最高解析音质:\nstandard(标准)`]);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
// e.reply([segment.image(userInfo.avatarUrl), `网易云已登录:${userInfo.nickname}\n会员等级:\n`,segment.image(vipInfo.iconUrl)]);
|
||||||
|
} else {
|
||||||
|
e.reply('暂未登录,请发#网易云扫码登陆进行登陆绑定ck')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
// 网易扫码登录
|
// 网易扫码登录
|
||||||
async netease_scan(e) {
|
async netease_scan(e) {
|
||||||
// 优先判断是否使用自建 API
|
// 优先判断是否使用自建 API
|
||||||
|
Loading…
x
Reference in New Issue
Block a user