mirror of
https://github.com/ctrlcvs/xiaoyao-cvs-plugin.git
synced 2024-12-22 11:00:51 +08:00
更新版本号、具体内容请查看#图鉴版本
This commit is contained in:
parent
e67eda4ee6
commit
79d5bed204
@ -1,3 +1,11 @@
|
||||
# 1.2.0
|
||||
* 咕咕咕
|
||||
* 努力填坑中,速度缓慢咕
|
||||
* 新增指令`#我的stoken|#我的云ck`
|
||||
* 新增操作发送`stoken`可以直接绑定
|
||||
* 具体格式 ****stuid=**********;stoken=**********;ltoken=**********;****
|
||||
* 初步适配锅巴插件
|
||||
* 新增指令`删除stoken|删除云(ck|token)`
|
||||
# 1.1.9
|
||||
* 优化部分代码以及配置
|
||||
* 新增指令`#更新抽卡记录`
|
||||
|
@ -10,7 +10,6 @@ class User {
|
||||
|
||||
// 保存用户配置
|
||||
async setCfg (path, value) {
|
||||
console.log(this.id)
|
||||
let userCfg = await redis.get(`genshin:user-cfg:${this.id}`)
|
||||
userCfg = userCfg ? JSON.parse(userCfg) : {}
|
||||
lodash.set(userCfg, path, value)
|
||||
|
@ -23,8 +23,8 @@ import {
|
||||
currentVersion
|
||||
} from "../components/Changelog.js";
|
||||
import {
|
||||
rule as userRule,
|
||||
userInfo,gclog
|
||||
rule as userRule,delSign,
|
||||
userInfo,gclog,mytoken,bindStoken
|
||||
} from "./user.js"
|
||||
import {
|
||||
rule as signRule,
|
||||
@ -33,11 +33,11 @@ import {
|
||||
cookiesDocHelp,
|
||||
signlist,yunSignlist,yunAllSign,
|
||||
allMysSign,yunSign,sendyunTime,yuntoken,yunHelp,
|
||||
allSign,bbsSeach,delSign
|
||||
allSign,bbsSeach
|
||||
} from "./sign.js"
|
||||
export {
|
||||
updateRes,yunSignlist,delSign,
|
||||
signlist,gclog,
|
||||
signlist,gclog,mytoken,bindStoken,
|
||||
updateMiaoPlugin,userInfo,
|
||||
sign,bbsSeach,
|
||||
versionInfo,yunAllSign,
|
||||
|
13
apps/sign.js
13
apps/sign.js
@ -53,10 +53,6 @@ export const rule = {
|
||||
reg: "^#*云原神签到$",
|
||||
describe: "云原神签到"
|
||||
},
|
||||
// delSign:{
|
||||
// reg: "^#*删除(我的)*(stoken|云原神)$",
|
||||
// describe: "删除云原神、stoken数据"
|
||||
// },
|
||||
yunAllSign: {
|
||||
reg: "^#云原神全部签到$",
|
||||
describe: "云原神全部签到"
|
||||
@ -582,12 +578,3 @@ export async function yunHelp(e){
|
||||
const yunDoc=async function(){
|
||||
return await gsCfg.getfileYaml(`${_path}/plugins/xiaoyao-cvs-plugin/config/`, "config").yunDoc
|
||||
}
|
||||
export async function delSign(e){
|
||||
let msg=e.msg.replace(/#|删除|我的/g,"");
|
||||
let url=msg=="云原神"?`${yunpath}`:`${YamlDataUrl}`;
|
||||
console.log(e.uid)
|
||||
if(await gsCfg.delSytk(url,e.user_id)){
|
||||
e.reply(`删除${msg}数据成功~\n期待您的下次使用`)
|
||||
}
|
||||
return true;
|
||||
}
|
78
apps/user.js
78
apps/user.js
@ -26,9 +26,23 @@ export const rule = {
|
||||
gclog: {
|
||||
reg: "^#*更新抽卡记录$",
|
||||
describe: "更新抽卡记录"
|
||||
}
|
||||
},
|
||||
mytoken: {
|
||||
reg: "^#*我的(stoken|云ck)$",
|
||||
describe: "查询绑定数据"
|
||||
},
|
||||
bindStoken: {
|
||||
reg: "^(.*)stoken=(.*)$",
|
||||
describe: "绑定stoken"
|
||||
},
|
||||
delSign:{
|
||||
reg: "^#*删除(我的)*(stoken|(云原神|云ck))$",
|
||||
describe: "删除云原神、stoken数据"
|
||||
},
|
||||
}
|
||||
const _path = process.cwd();
|
||||
const YamlDataUrl = `${_path}/plugins/xiaoyao-cvs-plugin/data/yaml`;
|
||||
const yunpath=`${_path}/plugins/xiaoyao-cvs-plugin/data/yunToken/`;
|
||||
export async function userInfo(e, {
|
||||
render
|
||||
}) {
|
||||
@ -129,3 +143,65 @@ export async function gclog(e) {
|
||||
});
|
||||
return true;
|
||||
}
|
||||
export async function mytoken(e) {
|
||||
if (!e.isPrivate) {
|
||||
e.reply("请私聊发送")
|
||||
return true;
|
||||
}
|
||||
let user = new User(e);
|
||||
let msg = e.msg.replace(/#|我的/g, "");
|
||||
let ck, sendMsg;
|
||||
if (msg === "stoken") {
|
||||
await user.getCookie(e)
|
||||
ck = await user.getStoken(e.user_id)
|
||||
sendMsg = `stuid=${ck.stuid};stoken=${ck.stoken};ltoken=${ck.ltoken};`;
|
||||
} else {
|
||||
ck = await user.getyunToken(e);
|
||||
sendMsg = `${ck.yuntoken}devId=${ck.devId}`
|
||||
}
|
||||
if (sendMsg.includes("undefined")) {
|
||||
e.reply(`您暂未绑定${msg}`);
|
||||
return true;
|
||||
}
|
||||
e.reply(sendMsg)
|
||||
return true;
|
||||
}
|
||||
export async function bindStoken(e) {
|
||||
let msg = e.msg;
|
||||
let user = new User(e);
|
||||
let miHoYoApi = new MihoYoApi(e);
|
||||
miHoYoApi.cookies = msg;
|
||||
let resObj = await miHoYoApi.getTasksList();
|
||||
if (!resObj?.data) {
|
||||
await e.reply(`登录Stoken失效\n请重新获取~`);
|
||||
return true;
|
||||
}
|
||||
await user.getCookie(e)
|
||||
let sk = await utils.getCookieMap(msg)
|
||||
let data={}
|
||||
data[e.uid]= {
|
||||
uid: e.uid,
|
||||
userId: e.user_id,
|
||||
is_sign: true
|
||||
};
|
||||
for (var item of sk.entries()) {
|
||||
data[e.uid][item[0]] = item[1];
|
||||
}
|
||||
await gsCfg.saveBingStoken(e.user_id, data)
|
||||
msg = 'stoken绑定成功您可通过下列指令进行操作:';
|
||||
msg += '\n【#米币查询】查询米游币余额'
|
||||
msg += '\n【#mys原神签到】获取米游币'
|
||||
msg += '\n【#更新抽卡记录】更新抽卡记录'
|
||||
msg += '\n【#我的stoken】查看绑定信息'
|
||||
msg += '\n【#删除stoken】删除绑定信息'
|
||||
await e.reply(msg);
|
||||
return true;
|
||||
}
|
||||
|
||||
export async function delSign(e){
|
||||
let user = new User(e);
|
||||
e.msg=e.msg.replace(/#|删除|我的/g,"");
|
||||
let url=e.msg=="stoken"?`${YamlDataUrl}`:`${yunpath}`;
|
||||
await user.delSytk(url,e)
|
||||
return true;
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ export function supportGuoba() {
|
||||
],
|
||||
// 获取配置数据方法(用于前端填充显示数据)
|
||||
getConfigData() {
|
||||
return lodash.omit(Cfg.merged(), 'jwt')
|
||||
return Cfg.merged()
|
||||
},
|
||||
// 设置配置的方法(前端点确定后调用的方法)
|
||||
setConfigData(data, {Result}) {
|
||||
|
@ -12,7 +12,7 @@ import {
|
||||
import {
|
||||
isV3
|
||||
} from '../components/Changelog.js';
|
||||
|
||||
import utils from './mys/utils.js';
|
||||
const plugin = "xiaoyao-cvs-plugin"
|
||||
const pathPlugin=`./plugins/${plugin}/data/`
|
||||
/**
|
||||
@ -22,18 +22,6 @@ const pathPlugin=`./plugins/${plugin}/data/`
|
||||
class GsCfg {
|
||||
constructor() {
|
||||
|
||||
}
|
||||
async getyunToken(e) {
|
||||
let file = `${yunpath}/${e.user_id}.yaml`
|
||||
try {
|
||||
let ck = fs.readFileSync(file, 'utf-8')
|
||||
ck = YAML.parse(ck)
|
||||
e.devId = ck.devId;
|
||||
e.yuntoken = ck.yuntoken;
|
||||
return ck
|
||||
} catch (error) {
|
||||
return ""
|
||||
}
|
||||
}
|
||||
/** 通用yaml读取*/
|
||||
getfileYaml(path, name) {
|
||||
@ -122,24 +110,6 @@ class GsCfg {
|
||||
return {}
|
||||
}
|
||||
}
|
||||
getStoken(userId) {
|
||||
let file = `${YamlDataUrl}/${userId}.yaml`
|
||||
try {
|
||||
let ck = fs.readFileSync(file, 'utf-8')
|
||||
ck = YAML.parse(ck)
|
||||
if(ck?.uid){
|
||||
let datalist={};
|
||||
ck.userId=this.e.user_id
|
||||
datalist[ck.uid]=ck;
|
||||
ck=datalist
|
||||
this.saveBingStoken(this.e.user_id,datalist)
|
||||
}
|
||||
return ck[this.e.uid]||{}
|
||||
} catch (error) {
|
||||
return {}
|
||||
}
|
||||
}
|
||||
|
||||
saveBingStoken(userId, data) {
|
||||
let file = `./plugins/${plugin}/data/yaml/${userId}.yaml`
|
||||
if (lodash.isEmpty(data)) {
|
||||
|
@ -55,8 +55,22 @@ export async function replyMake(e,_msg,lenght){
|
||||
}
|
||||
e._reply(await Bot.makeForwardMsg(msgList));
|
||||
}
|
||||
export async function getCookieMap(cookie) {
|
||||
let cookiePattern = /^(\S+)=(\S+)$/;
|
||||
let cookieArray = cookie.replace(/\s*/g, "").split(";");
|
||||
let cookieMap = new Map();
|
||||
for (let item of cookieArray) {
|
||||
let entry = item.split("=");
|
||||
if (!entry[0]) continue;
|
||||
cookieMap.set(entry[0], entry[1]);
|
||||
}
|
||||
return cookieMap;
|
||||
}
|
||||
export default {
|
||||
sleepAsync,
|
||||
randomSleepAsync,replyMake,
|
||||
randomString,relpyPrivate
|
||||
randomSleepAsync,
|
||||
replyMake,
|
||||
randomString,
|
||||
relpyPrivate,
|
||||
getCookieMap
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ const RETRY_OPTIONS = {
|
||||
maxTimeout: 10000
|
||||
};
|
||||
const nameData = ["原神", "崩坏3", "崩坏2", "未定事件簿"];
|
||||
const YamlDataUrl = `${_path}/plugins/xiaoyao-cvs-plugin/data/yaml`;
|
||||
/** 配置文件 */
|
||||
export default class user {
|
||||
constructor(e) {
|
||||
@ -74,17 +75,7 @@ export default class user {
|
||||
}
|
||||
return sumData;
|
||||
}
|
||||
getCookieMap(cookie) {
|
||||
let cookiePattern = /^(\S+)=(\S+)$/;
|
||||
let cookieArray = cookie.replace(/\s*/g, "").split(";");
|
||||
let cookieMap = new Map();
|
||||
for (let item of cookieArray) {
|
||||
let entry = item.split("=");
|
||||
if (!entry[0]) continue;
|
||||
cookieMap.set(entry[0], entry[1]);
|
||||
}
|
||||
return cookieMap;
|
||||
}
|
||||
|
||||
getyunToken(e) {
|
||||
let file = `${this.yunPath}${e.user_id}.yaml`
|
||||
try {
|
||||
@ -109,7 +100,7 @@ export default class user {
|
||||
e.reply("请先#绑定cookie\n发送【体力帮助】查看配置教程")
|
||||
return false;
|
||||
}
|
||||
let stokens = miHoYoApi.getStoken(e.user_id)
|
||||
let stokens = this.getStoken(e.user_id)
|
||||
if (!stokens) {
|
||||
return true;
|
||||
}
|
||||
@ -154,4 +145,48 @@ export default class user {
|
||||
skuid
|
||||
}
|
||||
}
|
||||
getStoken(userId) {
|
||||
let file = `${YamlDataUrl}/${userId}.yaml`
|
||||
try {
|
||||
let ck = fs.readFileSync(file, 'utf-8')
|
||||
ck = YAML.parse(ck)
|
||||
if (ck?.uid) {
|
||||
let datalist = {};
|
||||
ck.userId = this.e.user_id
|
||||
datalist[ck.uid] = ck;
|
||||
ck = datalist
|
||||
gsCfg.saveBingStoken(this.e.user_id, datalist)
|
||||
}
|
||||
return ck[this.e.uid] || {}
|
||||
} catch (error) {
|
||||
return {}
|
||||
}
|
||||
}
|
||||
async delSytk(path,e){
|
||||
await this.getCookie(e);
|
||||
let file = `${path}/${e.user_id}.yaml`
|
||||
fs.exists(file, (exists) => {
|
||||
if (!exists) {
|
||||
return true;
|
||||
}
|
||||
let ck = fs.readFileSync(file, 'utf-8')
|
||||
ck = YAML.parse(ck)
|
||||
if(ck?.yuntoken){
|
||||
fs.unlinkSync(file);
|
||||
}else if(ck){
|
||||
if(!ck[e.uid]) {
|
||||
return true;
|
||||
}
|
||||
delete ck[e.uid];
|
||||
if(Object.keys(ck)==0){
|
||||
fs.unlinkSync(file);
|
||||
}else{
|
||||
ck = YAML.stringify(ck)
|
||||
fs.writeFileSync(file, ck, 'utf8')
|
||||
}
|
||||
}
|
||||
e.reply(`已删除${e.msg}`)
|
||||
return true;
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user