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