mirror of
https://github.com/ctrlcvs/xiaoyao-cvs-plugin.git
synced 2024-12-22 19:10:53 +08:00
支持直接获取cookie及抽卡链接
This commit is contained in:
parent
dc2e600ed7
commit
8e502d995e
@ -1,3 +1,7 @@
|
||||
# 1.2.1
|
||||
* 新增指令`获取(抽卡记录|ck)` 导出cookie或者抽卡链接供用户操作到其他bot或app上面
|
||||
* 增加国际服 `stoken` 绑定 (功能目前仅支持V3)
|
||||
* 支持国际服`刷新ck`
|
||||
# 1.2.0
|
||||
* 新增指令 `#刷新ck`
|
||||
* 需要绑定`stoken`
|
||||
@ -8,14 +12,11 @@
|
||||
* 初步适配锅巴插件
|
||||
* 新增指令`删除stoken|删除云(ck|token)`
|
||||
# 1.1.9
|
||||
* 优化部分代码以及配置
|
||||
* 新增指令`#更新抽卡记录`
|
||||
* 必须绑定stoken
|
||||
* 定义限制5分钟可请求一次避免刷屏`默认5分钟具体修改规则请自行修改config配置`
|
||||
* 默认配置文件位于****xiaoyao-cvs-plugin/defSet/config/config.yaml****
|
||||
*后续叠加配置数据会在此文件中增加
|
||||
|
||||
# 1.1.2~1.1.8
|
||||
* 新增指令`#ck查询`
|
||||
* 可查询当前cookie绑定状态的签到信息以及米游币信息数据
|
||||
* 新增指令`#米币查询`
|
||||
|
38
apps/user.js
38
apps/user.js
@ -25,7 +25,7 @@ export const rule = {
|
||||
describe: "用户个人信息查询"
|
||||
},
|
||||
gclog: {
|
||||
reg: "^#*更新抽卡记录$",
|
||||
reg: "^#*(更新|获取|导出)抽卡记录$",
|
||||
describe: "更新抽卡记录"
|
||||
},
|
||||
mytoken: {
|
||||
@ -41,7 +41,7 @@ export const rule = {
|
||||
describe: "删除云原神、stoken数据"
|
||||
},
|
||||
updCookie: {
|
||||
reg: "^#*(刷新|更新)(ck|cookie)$",
|
||||
reg: "^#*(刷新|更新|获取)(ck|cookie)$",
|
||||
describe: "刷新cookie"
|
||||
}
|
||||
}
|
||||
@ -87,16 +87,20 @@ export async function gclog(e) {
|
||||
e.reply(`请求过快,请${time}秒后重试...`);
|
||||
return true;
|
||||
}
|
||||
let isGet= /导出|获取/.test(e.msg)
|
||||
if (!e.isPrivate&&isGet) {
|
||||
e.reply("请私聊发送")
|
||||
return true;
|
||||
}
|
||||
let miHoYoApi = new MihoYoApi(e);
|
||||
if (!e.cookies || e.cookies.includes("undefined")) {
|
||||
e.reply(`请先绑定stoken\n发送【stoken帮助】查看配置教程`)
|
||||
return true;
|
||||
}
|
||||
let kkbody = await miHoYoApi.getbody("原神");
|
||||
// let kkbody = await miHoYoApi.getbody("原神");
|
||||
e.region = getServer(e.uid)
|
||||
// const objData = await miHoYoApi.getUserInfo(kkbody)
|
||||
// let data = objData.data
|
||||
// console.log(data)
|
||||
let authkeyrow = await miHoYoApi.authkey(e);
|
||||
if (!authkeyrow?.data) {
|
||||
e.reply("authkey获取失败:" + authkeyrow.message)
|
||||
@ -133,6 +137,10 @@ export async function gclog(e) {
|
||||
e.reply = (msg) => {
|
||||
sendMsg.push(msg)
|
||||
}
|
||||
if(isGet){
|
||||
|
||||
sendMsg=[...sendMsg,...[1,`uid:${e.uid}`,e.msg]]
|
||||
}else {
|
||||
if (isV3) {
|
||||
let gclog = (await import(`file:///${_path}/plugins/genshin/model/gachaLog.js`)).default
|
||||
await (new gclog(e)).logUrl()
|
||||
@ -143,6 +151,7 @@ export async function gclog(e) {
|
||||
e.isPrivate = true;
|
||||
await bing(e)
|
||||
}
|
||||
}
|
||||
await utils.replyMake(e, sendMsg, 1)
|
||||
let time = (configData.gclogEx || 5) * 60
|
||||
redis.set(`xiaoyao:gclog:${e.user_id}`, Math.floor(Date.now() / 1000) + time, { //数据写入缓存避免重复请求
|
||||
@ -180,11 +189,13 @@ export async function bindStoken(e) {
|
||||
}
|
||||
let msg = e.msg;
|
||||
let user = new User(e);
|
||||
await user.cookie(e)
|
||||
let miHoYoApi = new MihoYoApi(e);
|
||||
e.region = getServer(e.uid)
|
||||
miHoYoApi.cookies = msg;
|
||||
let resObj = await miHoYoApi.getTasksList();
|
||||
let resObj = await miHoYoApi.updCookie();
|
||||
if (!resObj?.data) {
|
||||
await e.reply(`登录Stoken失效\n请发送【stoken帮助】查看配置教程重新配置~`);
|
||||
await e.reply(`绑定Stoken失败,异常:${resObj?.message}\n请发送【stoken帮助】查看配置教程重新配置~`);
|
||||
return true;
|
||||
}
|
||||
await user.getCookie(e)
|
||||
@ -195,7 +206,7 @@ export async function bindStoken(e) {
|
||||
userId: e.user_id,
|
||||
is_sign: true
|
||||
};
|
||||
for (var item of sk.entries()) {
|
||||
for (let item of sk.entries()) {
|
||||
data[e.uid][item[0]] = item[1];
|
||||
}
|
||||
await gsCfg.saveBingStoken(e.user_id, data)
|
||||
@ -223,6 +234,11 @@ export async function updCookie(e) {
|
||||
e.reply("请先绑定stoken\n发送【stoken帮助】查看配置教程")
|
||||
return true;
|
||||
}
|
||||
let isGet= e.msg.includes("获取")
|
||||
if (!e.isPrivate&&isGet) {
|
||||
e.reply("请私聊发送")
|
||||
return true;
|
||||
}
|
||||
let miHoYoApi = new MihoYoApi(e);
|
||||
let sendMsg = [];
|
||||
e._reply = e.reply;
|
||||
@ -234,12 +250,15 @@ export async function updCookie(e) {
|
||||
miHoYoApi.cookies= `stuid=${stoken[item].stuid};stoken=${stoken[item].stoken};ltoken=${stoken[item].ltoken};`;
|
||||
let resObj = await miHoYoApi.updCookie();
|
||||
if (!resObj?.data) {
|
||||
e._reply(`请求异常:${resObj.message}`)
|
||||
return false;
|
||||
e.reply(`uid:${stoken[item].uid},请求异常:${resObj.message}`)
|
||||
continue;
|
||||
}
|
||||
let sk = await utils.getCookieMap(miHoYoApi.cookies)
|
||||
let ck = resObj["data"]["cookie_token"];
|
||||
e.msg = `ltoken=${sk.get("ltoken")};ltuid=${sk.get("stuid")};cookie_token=${ck}; account_id=${sk.get("stuid")};`
|
||||
if(isGet){
|
||||
sendMsg=[...sendMsg,...[`uid:${stoken[item].uid}`,e.msg]]
|
||||
}else {
|
||||
if (isV3) {
|
||||
let userck = (await import(`file:///${_path}/plugins/genshin/model/user.js`)).default
|
||||
e.ck = e.msg;
|
||||
@ -252,6 +271,7 @@ export async function updCookie(e) {
|
||||
await bingCookie(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
await utils.replyMake(e, sendMsg, 0)
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user