mirror of
https://github.com/ctrlcvs/xiaoyao-cvs-plugin.git
synced 2025-01-22 22:11:22 +08:00
修改方法名避免冲突
This commit is contained in:
parent
c5d50a9919
commit
a45c3c404e
@ -215,20 +215,19 @@ export async function delSign(e) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
export async function updCookie(e) {
|
export async function updCookie(e) {
|
||||||
let stoken=await gsCfg.getBingStoken(e.user_id);
|
let stoken=await gsCfg.getUserStoken(e.user_id);
|
||||||
if (Object.keys(stoken).length==0) {
|
if (Object.keys(stoken).length==0) {
|
||||||
e.reply("请先绑定stoken")
|
e.reply("请先绑定stoken")
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
let stokenData=stoken[0]
|
|
||||||
let miHoYoApi = new MihoYoApi(e);
|
let miHoYoApi = new MihoYoApi(e);
|
||||||
let sendMsg = [];
|
let sendMsg = [];
|
||||||
e._reply = e.reply;
|
e._reply = e.reply;
|
||||||
e.reply = (msg) => {
|
e.reply = (msg) => {
|
||||||
sendMsg.push(msg)
|
sendMsg.push(msg)
|
||||||
}
|
}
|
||||||
for(let item of Object.keys(stokenData)){
|
for(let item of Object.keys(stoken)){
|
||||||
miHoYoApi.cookies= `stuid=${stokenData[item].stuid};stoken=${stokenData[item].stoken};ltoken=${stokenData[item].ltoken};`;
|
miHoYoApi.cookies= `stuid=${stoken[item].stuid};stoken=${stoken[item].stoken};ltoken=${stoken[item].ltoken};`;
|
||||||
let resObj = await miHoYoApi.updCookie();
|
let resObj = await miHoYoApi.updCookie();
|
||||||
if (!resObj?.data) {
|
if (!resObj?.data) {
|
||||||
e._reply(`请求异常:${resObj.message}`)
|
e._reply(`请求异常:${resObj.message}`)
|
||||||
|
@ -15,13 +15,13 @@ import {
|
|||||||
import utils from './mys/utils.js';
|
import utils from './mys/utils.js';
|
||||||
const plugin = "xiaoyao-cvs-plugin"
|
const plugin = "xiaoyao-cvs-plugin"
|
||||||
const pathPlugin=`./plugins/${plugin}/data/`
|
const pathPlugin=`./plugins/${plugin}/data/`
|
||||||
/**
|
/**
|
||||||
* 配置文件
|
* 配置文件
|
||||||
* 主要用于处理 stoken以及云原神账号数据
|
* 主要用于处理 stoken以及云原神账号数据
|
||||||
*/
|
*/
|
||||||
class GsCfg {
|
class GsCfg {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
|
||||||
}
|
}
|
||||||
/** 通用yaml读取*/
|
/** 通用yaml读取*/
|
||||||
getfileYaml(path, name) {
|
getfileYaml(path, name) {
|
||||||
@ -35,15 +35,15 @@ class GsCfg {
|
|||||||
let ckQQ = {}
|
let ckQQ = {}
|
||||||
let dir = './data/MysCookie/'
|
let dir = './data/MysCookie/'
|
||||||
let files = fs.readdirSync(dir).filter(file => file.endsWith('.yaml'))
|
let files = fs.readdirSync(dir).filter(file => file.endsWith('.yaml'))
|
||||||
|
|
||||||
const readFile = promisify(fs.readFile)
|
const readFile = promisify(fs.readFile)
|
||||||
|
|
||||||
let promises = []
|
let promises = []
|
||||||
|
|
||||||
files.forEach((v) => promises.push(readFile(`${dir}${v}`, 'utf8')))
|
files.forEach((v) => promises.push(readFile(`${dir}${v}`, 'utf8')))
|
||||||
|
|
||||||
const res = await Promise.all(promises)
|
const res = await Promise.all(promises)
|
||||||
|
|
||||||
res.forEach((v) => {
|
res.forEach((v) => {
|
||||||
let tmp = YAML.parse(v)
|
let tmp = YAML.parse(v)
|
||||||
lodash.forEach(tmp, (v, i) => {
|
lodash.forEach(tmp, (v, i) => {
|
||||||
@ -53,17 +53,18 @@ class GsCfg {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
ck,
|
ck,
|
||||||
ckQQ
|
ckQQ
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
async getBingStoken(userId){
|
async getUserStoken(userId){
|
||||||
try {
|
try {
|
||||||
return YAML.parse(
|
let ck=YAML.parse(
|
||||||
fs.readFileSync(`plugins/${plugin}/data/yaml/${userId}.yaml`, 'utf8')
|
fs.readFileSync(`plugins/${plugin}/data/yaml/${userId}.yaml`, 'utf8')
|
||||||
)
|
)
|
||||||
|
return ck||{}
|
||||||
}catch (ex) {
|
}catch (ex) {
|
||||||
return {}
|
return {}
|
||||||
}
|
}
|
||||||
@ -74,11 +75,11 @@ class GsCfg {
|
|||||||
let ckQQ = {}
|
let ckQQ = {}
|
||||||
let dir = `plugins/${plugin}/data/yaml/`
|
let dir = `plugins/${plugin}/data/yaml/`
|
||||||
let files = fs.readdirSync(dir).filter(file => file.endsWith('.yaml'))
|
let files = fs.readdirSync(dir).filter(file => file.endsWith('.yaml'))
|
||||||
|
|
||||||
const readFile = promisify(fs.readFile)
|
const readFile = promisify(fs.readFile)
|
||||||
|
|
||||||
let promises = []
|
let promises = []
|
||||||
|
|
||||||
files.forEach((v) => promises.push(readFile(`${dir}${v}`, 'utf8')))
|
files.forEach((v) => promises.push(readFile(`${dir}${v}`, 'utf8')))
|
||||||
const res = await Promise.all(promises)
|
const res = await Promise.all(promises)
|
||||||
res.forEach((v, index) => {
|
res.forEach((v, index) => {
|
||||||
@ -124,7 +125,7 @@ class GsCfg {
|
|||||||
if (lodash.isEmpty(data)) {
|
if (lodash.isEmpty(data)) {
|
||||||
fs.existsSync(file) && fs.unlinkSync(file)
|
fs.existsSync(file) && fs.unlinkSync(file)
|
||||||
} else {
|
} else {
|
||||||
fs.exists(file, (exists) => {
|
fs.exists(file, (exists) => {
|
||||||
if (!exists) {
|
if (!exists) {
|
||||||
fs.writeFileSync(file, "", 'utf8')
|
fs.writeFileSync(file, "", 'utf8')
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user