From 4f294bed1157edbdf017ed9b2fd532b8655d6bda Mon Sep 17 00:00:00 2001 From: Ctrlcvs <1509167646@qq.com> Date: Fri, 29 Jul 2022 22:43:28 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9Ecookies=E5=B8=AE=E5=8A=A9?= =?UTF-8?q?=E6=8C=87=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 10 ++++++++++ apps/index.js | 4 ++-- apps/sign.js | 22 ++++++++++++++++++---- config/config.yaml | 2 ++ model/gsCfg.js | 7 ++++++- 5 files changed, 38 insertions(+), 7 deletions(-) create mode 100644 config/config.yaml diff --git a/CHANGELOG.md b/CHANGELOG.md index b0be465..6cd0e6f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ +# 1.1.3 +* 下列功能需要绑定`cookies`来跑,非信任的bot请勿发送cookies +* 实现米游社多模块签到 +* 实现米游社米游币获取 +* 新增指令`cookies帮助` +* 新增指令`#米游社原神签到` + * 用于获取米游社米游币 +* 新增指令`#崩坏3签到` + * 用于签到不同的社区模块 + * 具体有`原神、崩坏3、崩坏2、未定事件簿、大别野、崩坏星穹铁道、绝区零` # 1.1.2 * 初步实现米游社签到米游币以及社区签到 * 需要引入包文件`cnpm i promise-retry `跟`cnpm i superagent` diff --git a/apps/index.js b/apps/index.js index f5ba14c..7c2e416 100644 --- a/apps/index.js +++ b/apps/index.js @@ -21,13 +21,13 @@ import { } from "../components/Changelog.js"; import { rule as signRule, - sign,mysSign + sign,mysSign,cookiesDocHelp } from "./sign.js" export { updateRes, updateMiaoPlugin,sign, versionInfo, - Note_appoint,pokeNote, + Note_appoint,pokeNote,cookiesDocHelp, sysCfg, help,DailyNoteTask, AtlasAlias, diff --git a/apps/sign.js b/apps/sign.js index 2aad6f6..45ccd07 100644 --- a/apps/sign.js +++ b/apps/sign.js @@ -10,7 +10,8 @@ import MysInfo from '../model/mys/mysInfo.js' import { isV3 } from '../components/Changelog.js'; -import gsCfg from '../model/gsCfg.js' +import gsCfg from '../model/gsCfg.js'; + export const rule = { mysSign: { reg: "^#*(米游社|mys|社区)(原神|崩坏3|崩坏2|未定事件簿|大别野|崩坏星穹铁道|绝区零|全部)签到$", @@ -19,6 +20,10 @@ export const rule = { sign: { reg: "^#*(原神|崩坏3|崩坏2|未定事件簿|大别野|崩坏星穹铁道|绝区零)签到$", describe: "米社规则签到" + }, + cookiesDocHelp: { + reg: "^#*(米游社|cookies|米游币)帮助$", + describe: "cookies获取帮助" } }; @@ -30,6 +35,7 @@ const RETRY_OPTIONS = { minTimeout: 5000, maxTimeout: 10000 }; + export async function sign(e) { let isck=await cookie(e); if (!isck) { @@ -167,8 +173,8 @@ async function cookie(e) { let cookie, uid; let miHoYoApi = new MihoYoApi(e); let skuid; + let cookiesDoc=await getcookiesDoc(); if (isV3) { - // console.log(e) skuid= await gsCfg.getBingCookie(e.user_id); cookie = skuid.ck; uid = skuid.item; @@ -182,12 +188,12 @@ async function cookie(e) { } } if(!cookie){ - e.reply("cookie失效请重新绑定~") + e.reply("cookie失效请重新绑定~【教程】\n"+cookiesDoc) return false; } e.uid = uid; if (!cookie.includes("login_ticket")&&(isV3&&!skuid?.login_ticket)) { - e.reply("米游社登录cookie不完整,请前往米游社通行证处重新获取cookie~\ncookies必须包含login_ticket") + e.reply("米游社登录cookie不完整,请前往米游社通行证处重新获取cookie~\ncookies必须包含login_ticket【教程】 "+cookiesDoc) return false; } let flot = (await miHoYoApi.stoken(cookie, e)); @@ -199,3 +205,11 @@ async function cookie(e) { } return true; } +export async function cookiesDocHelp(e){ + let cookiesDoc=await getcookiesDoc() + e.reply("【cookies帮助】"+cookiesDoc+"\ncookies必须包含login_ticket获取后请私发机器人"); + return true +} +async function getcookiesDoc(){ + return await gsCfg.getfileYaml(`${_path}/plugins/xiaoyao-cvs-plugin/config/`,"config").cookiesDoc +} diff --git a/config/config.yaml b/config/config.yaml new file mode 100644 index 0000000..4f4fe4f --- /dev/null +++ b/config/config.yaml @@ -0,0 +1,2 @@ +# cookies教程 +cookiesDoc: docs.qq.com/doc/DV2tDY2ltSFdtbU9z \ No newline at end of file diff --git a/model/gsCfg.js b/model/gsCfg.js index d94eb8f..5c8a897 100644 --- a/model/gsCfg.js +++ b/model/gsCfg.js @@ -46,7 +46,12 @@ class GsCfg { ...this.getYaml(app, name, 'config') } } - + + getfileYaml(path,name){ + return YAML.parse( + fs.readFileSync(path+name+".yaml", 'utf8') + ) + } /** * 获取配置yaml * @param app 功能