🐞 fix: 解决netease登录后无法识别问题

This commit is contained in:
zhiyu1998 2023-03-17 23:38:42 +08:00
parent 3bd735571b
commit ec147c0317

View File

@ -30,7 +30,7 @@ export class neteasepro extends plugin {
rule: [ rule: [
{ {
/** 命令正则匹配 */ /** 命令正则匹配 */
reg: "#网易云登", reg: "#网易云登",
/** 执行方法 */ /** 执行方法 */
fnc: "neteaseCloudLogin", fnc: "neteaseCloudLogin",
}, },
@ -72,7 +72,7 @@ export class neteasepro extends plugin {
} else { } else {
// 已经登陆过的直接从redis取出 // 已经登陆过的直接从redis取出
neteaseCookie = await store2ha1( neteaseCookie = await store2ha1(
JSON.parse(await redis.get(await this.getRedisKey(e.user_id))).cookie, JSON.parse(await redis.get(await this.getRedisKey(e.user_id))).cookie
); );
} }
// 获取用户信息 // 获取用户信息
@ -151,8 +151,8 @@ export class neteasepro extends plugin {
const musicUrlReg = /(http:|https:)\/\/music.163.com\/song\/media\/outer\/url\?id=(\d+)/; 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 musicUrlReg2 = /(http:|https:)\/\/y.music.163.com\/m\/song\?(.*)&id=(\d+)/;
const id = const id =
musicUrlReg2.exec(message)[3] || musicUrlReg2.exec(message)?.[3] ||
musicUrlReg.exec(message)[2] || musicUrlReg.exec(message)?.[2] ||
/id=(\d+)/.exec(message)[1]; /id=(\d+)/.exec(message)[1];
// 是游客 // 是游客
if (!(await redis.get(await this.getRedisKey(e.user_id)))) { if (!(await redis.get(await this.getRedisKey(e.user_id)))) {
@ -212,7 +212,7 @@ export class neteasepro extends plugin {
async aopBefore(e) { async aopBefore(e) {
// 取出cookie // 取出cookie
let userInfo = JSON.parse(await redis.get(await this.getRedisKey(e.user_id))); let userInfo = JSON.parse(await redis.get(await this.getRedisKey(e.user_id)));
const cookie = userInfo.cookie; const cookie = userInfo?.cookie;
// 如果不存在cookie // 如果不存在cookie
if (!cookie) { if (!cookie) {
e.reply("请先#网易云登录"); e.reply("请先#网易云登录");