From afe314b32ec9e54935c3d7aaa31b293c18b551c9 Mon Sep 17 00:00:00 2001 From: Ctrlcvs <1509167646@qq.com> Date: Tue, 2 Aug 2022 20:20:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E9=83=A8=E5=88=86=E5=B7=B2?= =?UTF-8?q?=E7=9F=A5bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 ++-- adapter/index.js | 9 ++++++-- apps/sign.js | 48 ++++++++++++++++++++++++----------------- apps/xiaoyao_image.js | 10 ++++----- index.js | 3 +-- model/mys/mihoyo-api.js | 7 +++--- 6 files changed, 46 insertions(+), 35 deletions(-) diff --git a/README.md b/README.md index 0c763aa..b3521ce 100644 --- a/README.md +++ b/README.md @@ -31,11 +31,11 @@ git clone https://github.com/Ctrlcvs/xiaoyao-cvs-plugin.git ./plugins/xiaoyao-cv 1. 配合云崽使用, https://gitee.com/Le-niao/Yunzai-Bot 2. V3版本安装报错的话请用指令引入包 ``` -pnpm i superagent +pnpm add superagent -w ``` ``` -pnpm i promise-retry +pnpm add promise-retry -w ``` 3. V2版本安装报错指令引入包 ``` diff --git a/adapter/index.js b/adapter/index.js index b285980..7cefea3 100644 --- a/adapter/index.js +++ b/adapter/index.js @@ -16,9 +16,14 @@ export class atlas extends plugin { }] }) } - + accept () { + this.e.original_msg = this.e.original_msg || this.e.msg + } async dispatch (e) { - let msg = e.raw_message + let msg = e.original_msg || '' + if (!msg) { + return false + } e.checkAuth = async function (cfg) { return await checkAuth(e, cfg) } diff --git a/apps/sign.js b/apps/sign.js index 0e6df35..1942ee6 100644 --- a/apps/sign.js +++ b/apps/sign.js @@ -1,4 +1,4 @@ -import MihoYoApi from "../model/mys/mihoyo-api.js" +import MihoYoApi from "../model/mys/mihoyo-api.js" import utils from '../model/mys/utils.js'; import promiseRetry from 'promise-retry'; import { @@ -22,9 +22,9 @@ export const rule = { reg: "^#*(崩坏3|崩坏2|未定事件簿)签到$", describe: "米社规则签到" }, - signlist:{ + signlist: { reg: "^#(米游币|米社)全部签到$", - describe: "米游币全部签到" + describe: "米游币全部签到" }, // allMysSign: { // reg: "^#米游币全部签到$", @@ -51,7 +51,8 @@ const RETRY_OPTIONS = { export async function sign(e) { let { - skuid,cookie + skuid, + cookie } = await getCookie(e); if (!cookie) { e.reply("请先绑定cookie~\n发送【cookie帮助】获取教程") @@ -98,7 +99,7 @@ export async function mysSign(e) { let iscount = ""; let miHoYoApi = new MihoYoApi(e); if (Object.keys((await miHoYoApi.getStoken(e.user_id))).length == 0) { - e.reply("未读取到stoken请尝试重新登录获取cookies") + e.reply("未读取到stoken请检查cookies是否包含login_ticket、以及云崽是否为最新版本V3、V2兼容") return true; } @@ -292,7 +293,6 @@ export async function allMysSign() { if (!isPushSign) { return; } - if (msg.includes("签到成功") && (cookie.isSignPush === true || cookie.isSignPush === undefined)) { // msg = msg.replace("签到成功", "自动签到成功"); utils.relpyPrivate(user_id, msg + "\n自动签到成功"); @@ -327,7 +327,7 @@ export async function allSign() { qq, isTask: true }; - e.msg="全部" + e.msg = "全部" e.reply = (msg) => { if (!msg.includes("OK")) { return; @@ -351,23 +351,31 @@ const checkAuth = async function(e) { (*/ω\*)` }); } -let isbool=false; -export async function signlist(e){ +let isbool = false; +let ismysbool = false; +export async function signlist(e) { if (!await checkAuth(e)) { - return true; - } -if(isbool){ - e.reply(`签到中请勿重复执行`) - return true; - } - isbool=true; - let msg=e.msg.replace(/#|全部签到/g,"") + return true; + } + if (isbool) { + e.reply(`米社签到中请勿重复执行`) + return true; + } + if (ismysbool) { + e.reply(`米游币签到中请勿重复执行`) + return true; + } + let msg = e.msg.replace(/#|全部签到/g, "") e.reply(`开始执行${msg}签到中,请勿重复执行`); - if(msg=="米游币"){ + if (msg == "米游币") { + ismysbool=true; await allMysSign() - }else{ + } else { + isbool = true; await allSign() } e.reply(`${msg}签到任务已完成`); - isbool=false; + ismysbool=false; + isbool = false; + return true; } diff --git a/apps/xiaoyao_image.js b/apps/xiaoyao_image.js index 2c13bdc..dc430f1 100644 --- a/apps/xiaoyao_image.js +++ b/apps/xiaoyao_image.js @@ -55,13 +55,13 @@ export async function roleInfo(e) { } const send_Msg = function(e, type, name) { - let path = `${_path}/plugins/xiaoyao-cvs-plugin/resources/xiaoyao-plus/${type}/${name}.png` - if (fs.existsSync(path)) { - e.reply(segment.image(`file:///${path}`)); - return true; - } if (type == "all") { for (let val of list) { + let path = `${_path}/plugins/xiaoyao-cvs-plugin/resources/xiaoyao-plus/${val}/${name}.png` + if (fs.existsSync(path)) { + e.reply(segment.image(`file:///${path}`)); + return true; + } let new_name = info_img(e, Data.readJSON(`${_path}/plugins/xiaoyao-cvs-plugin/resources/Atlas_alias/`, val), name) if (new_name) { diff --git a/index.js b/index.js index 9cf098a..10817f7 100644 --- a/index.js +++ b/index.js @@ -13,9 +13,8 @@ if (isV3) { index = await Data.importModule('/plugins/xiaoyao-cvs-plugin/adapter', 'index.js') } export const atlas = index.atlas || {} -Bot.logger.info(`--------------------------`) +Bot.logger.info(`---------^_^---------`) Bot.logger.info(`图鉴插件${currentVersion}初始化~`) -Bot.logger.info(`--------------------------`) setTimeout(async function() { let msgStr = await redis.get('xiaoyao:restart-msg') diff --git a/model/mys/mihoyo-api.js b/model/mys/mihoyo-api.js index a37a809..a4b39d4 100644 --- a/model/mys/mihoyo-api.js +++ b/model/mys/mihoyo-api.js @@ -84,7 +84,6 @@ export default class MihoYoApi { this.e = e this.cookie = e.cookie this.userId = String(e.user_id) - this.msgName = e.msg.replace(/#|签到|井|米游社|mys|社区/g, "") // //初始化配置文件 let data = this.getStoken(this.e.user_id); if (data) { @@ -111,7 +110,7 @@ export default class MihoYoApi { } if (!objData.nickname) { return { - message: `未绑定${this.msgName}信息` + message: `未绑定${name}信息` } } // 获取签到信息和奖励信息 、、后续重新梳理补充 @@ -127,7 +126,7 @@ export default class MihoYoApi { // 签到操作 return await this.postSign(kkbody, objData.game_uid, objData.region) } catch (error) { - logger.mark(`error.message`, error.message) + Bot.logger.mark(`error.message`, error.message) } } async forumSign(forumId) { @@ -168,7 +167,7 @@ export default class MihoYoApi { } } } else { - logger.mark(`ForumSign: error`); + Bot.logger.mark(`ForumSign: error`); } } }