From 57489b68c0122447a6b619a4ac903fa1fe2f8bc6 Mon Sep 17 00:00:00 2001 From: Ctrlcvs <1509167646@qq.com> Date: Tue, 6 Sep 2022 23:09:04 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=8C=87=E4=BB=A4#=E5=88=B7?= =?UTF-8?q?=E6=96=B0ck?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 5 ++-- apps/index.js | 4 +-- apps/user.js | 39 ++++++++++++++++++++++++++ model/mys/mihoyo-api.js | 7 ++++- model/mys/utils.js | 2 +- resources/Atlas_alias/wuqi_tujian.json | 7 +++-- resources/admin/index.css | 1 - resources/admin/index.less | 1 - 8 files changed, 56 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e6028d2..2a04dd9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # 1.2.0 -* 咕咕咕 -* 努力填坑中,速度缓慢咕 +* 新增指令 `#刷新ck` + * 需要绑定`stoken` + * 用于刷新登录失效的ck * 新增指令`#我的stoken|#我的云ck` * 新增操作发送`stoken`可以直接绑定 * 具体格式 ****stuid=**********;stoken=**********;ltoken=**********;**** diff --git a/apps/index.js b/apps/index.js index 6cc0b6b..38a5425 100644 --- a/apps/index.js +++ b/apps/index.js @@ -23,7 +23,7 @@ import { currentVersion } from "../components/Changelog.js"; import { - rule as userRule,delSign, + rule as userRule,delSign,updCookie, userInfo,gclog,mytoken,bindStoken } from "./user.js" import { @@ -45,7 +45,7 @@ export { pokeNote,yunSign,sendyunTime,yuntoken, cookiesDocHelp,yunHelp, sysCfg, - help, + help,updCookie, DailyNoteTask, allMysSign, allSign, diff --git a/apps/user.js b/apps/user.js index b1c5ce9..7b548a5 100644 --- a/apps/user.js +++ b/apps/user.js @@ -39,6 +39,10 @@ export const rule = { reg: "^#*删除(我的)*(stoken|(云原神|云ck))$", describe: "删除云原神、stoken数据" }, + updCookie:{ + reg:"^#*(刷新|更新)(ck|cookie)$", + describe:"刷新cookie" + } } const _path = process.cwd(); const YamlDataUrl = `${_path}/plugins/xiaoyao-cvs-plugin/data/yaml`; @@ -209,3 +213,38 @@ export async function delSign(e){ await user.delSytk(url,e) return true; } +export async function updCookie(e){ + let user = new User(e); + await user.getCookie(e) + let miHoYoApi = new MihoYoApi(e); + if (!e.cookies || e.cookies.includes("undefined")) { + e.reply("请先绑定stoken") + return true; + } + let resObj=await miHoYoApi.updCookie(); + if(!resObj?.data){ + e.reply(`请求异常:${resObj.message}`) + return false; + } + let sendMsg = []; + e._reply = e.reply; + e.reply = (msg) => { + sendMsg.push(msg) + } + let sk = await utils.getCookieMap(e.cookie) + let ck=resObj["data"]["cookie_token"]; + e.msg=`ltoken=${sk.get("ltoken")};ltuid=${sk.get("ltuid")};cookie_token=${ck}; account_id=${sk.get("ltuid")};` + if (isV3) { + let userck = (await import(`file:///${_path}/plugins/genshin/model/user.js`)).default + e.ck=e.msg; + await (new userck(e)).bing() + } else { + let { + bingCookie + } = (await import(`file:///${_path}/lib/app/dailyNote.js`)) + e.isPrivate = true; + await bingCookie(e) + } + await utils.replyMake(e, sendMsg, 0) + return true; +} \ No newline at end of file diff --git a/model/mys/mihoyo-api.js b/model/mys/mihoyo-api.js index 6b9ddfd..bdb4b17 100644 --- a/model/mys/mihoyo-api.js +++ b/model/mys/mihoyo-api.js @@ -270,7 +270,12 @@ export default class MihoYoApi { resObj.log_msg = log_msg return resObj } - + async updCookie(){ + let url = `https://api-takumi.mihoyo.com/auth/api/getCookieAccountInfoBySToken`; + let res = await superagent.get(url).set(this._getHeader()).timeout(10000); + let resObj = JSON.parse(res.text); + return resObj; + } async stoken(cookie, e) { this.e = e; let datalist = this.getStoken(e.user_id) || {} diff --git a/model/mys/utils.js b/model/mys/utils.js index cf9d09d..9d67d66 100644 --- a/model/mys/utils.js +++ b/model/mys/utils.js @@ -64,7 +64,7 @@ export async function getCookieMap(cookie) { if (!entry[0]) continue; cookieMap.set(entry[0], entry[1]); } - return cookieMap; + return cookieMap||{}; } export default { sleepAsync, diff --git a/resources/Atlas_alias/wuqi_tujian.json b/resources/Atlas_alias/wuqi_tujian.json index 69f99a4..6206484 100644 --- a/resources/Atlas_alias/wuqi_tujian.json +++ b/resources/Atlas_alias/wuqi_tujian.json @@ -13,7 +13,9 @@ "冬极白星": ["冬极","冬季","公子","达达利亚","鸭鸭","达达鸭"], "波乱月白经津": ["波乱", "月白", "波乱月白", "经津", "波波津","凌人","神里凌人","神理凌人","啵啵剑"], "若水": ["麒麟弓", "Aqua", "aqua","夜兰","叶兰","夜阑","夜天后"], - "猎人之径":["驴耳","提纳里"], + "流浪的晚星":["流浪的晚星"], + "圣显之钥":["圣显之钥","妮露"], + "赤沙之杖":["赤沙之杖","赛诺"], "磐岩结绿": ["绿箭", "绿剑"], "和璞鸢": ["鸟枪", "绿枪","魈","绿叉","护法夜叉"], @@ -132,5 +134,6 @@ "渔获": ["鱼叉","渔叉","鱼获"], "笼钓瓶一心":["妖刀", "红刀", "笼钓瓶", "一心传名刀","万叶外观"], - "竭泽":["竭泽","咸鱼弓","鱼弓","渔弓"] + "竭泽":["竭泽","咸鱼弓","鱼弓","渔弓"], + "风信之锋":["风信之锋"] } \ No newline at end of file diff --git a/resources/admin/index.css b/resources/admin/index.css index ea49912..3126ead 100644 --- a/resources/admin/index.css +++ b/resources/admin/index.css @@ -63,7 +63,6 @@ body { color: #495366; font-weight: bold; border-radius: 0 16px 16px 0; - font-family: Number, "微软雅黑", sans-serif; } .cfg-status.status-off { color: #a95151; diff --git a/resources/admin/index.less b/resources/admin/index.less index 2df4b93..0d0fe81 100644 --- a/resources/admin/index.less +++ b/resources/admin/index.less @@ -76,7 +76,6 @@ body { color: #495366; font-weight: bold; border-radius: 0 16px 16px 0; - font-family: Number, "微软雅黑", sans-serif; } .cfg-status.status-off {