2
0
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:
ctrlcvs 2022-10-04 21:41:07 +08:00
parent dc2e600ed7
commit 8e502d995e
2 changed files with 52 additions and 31 deletions

View File

@ -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绑定状态的签到信息以及米游币信息数据
* 新增指令`#米币查询` * 新增指令`#米币查询`

View File

@ -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,15 +137,20 @@ export async function gclog(e) {
e.reply = (msg) => { e.reply = (msg) => {
sendMsg.push(msg) sendMsg.push(msg)
} }
if (isV3) { if(isGet){
let gclog = (await import(`file:///${_path}/plugins/genshin/model/gachaLog.js`)).default
await (new gclog(e)).logUrl() sendMsg=[...sendMsg,...[1,`uid:${e.uid}`,e.msg]]
} else { }else {
let { if (isV3) {
bing let gclog = (await import(`file:///${_path}/plugins/genshin/model/gachaLog.js`)).default
} = (await import(`file:///${_path}/lib/app/gachaLog.js`)) await (new gclog(e)).logUrl()
e.isPrivate = true; } else {
await bing(e) let {
bing
} = (await import(`file:///${_path}/lib/app/gachaLog.js`))
e.isPrivate = true;
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
@ -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,22 +250,26 @@ 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 (isV3) { if(isGet){
let userck = (await import(`file:///${_path}/plugins/genshin/model/user.js`)).default sendMsg=[...sendMsg,...[`uid:${stoken[item].uid}`,e.msg]]
e.ck = e.msg; }else {
await (new userck(e)).bing() if (isV3) {
} else { let userck = (await import(`file:///${_path}/plugins/genshin/model/user.js`)).default
let { e.ck = e.msg;
bingCookie await (new userck(e)).bing()
} = (await import(`file:///${_path}/lib/app/dailyNote.js`)) } else {
e.isPrivate = true; let {
await bingCookie(e) bingCookie
} = (await import(`file:///${_path}/lib/app/dailyNote.js`))
e.isPrivate = true;
await bingCookie(e)
}
} }
} }
await utils.replyMake(e, sendMsg, 0) await utils.replyMake(e, sendMsg, 0)