2
0
mirror of https://github.com/ctrlcvs/xiaoyao-cvs-plugin.git synced 2024-12-23 03:20:52 +08:00

修正部分已知bug

This commit is contained in:
Ctrlcvs 2022-08-02 20:20:34 +08:00 committed by leiyilu
parent c123959529
commit afe314b32e
6 changed files with 46 additions and 35 deletions

View File

@ -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 1. 配合云崽使用, https://gitee.com/Le-niao/Yunzai-Bot
2. V3版本安装报错的话请用指令引入包 2. V3版本安装报错的话请用指令引入包
``` ```
pnpm i superagent pnpm add superagent -w
``` ```
``` ```
pnpm i promise-retry pnpm add promise-retry -w
``` ```
3. V2版本安装报错指令引入包 3. V2版本安装报错指令引入包
``` ```

View File

@ -16,9 +16,14 @@ export class atlas extends plugin {
}] }]
}) })
} }
accept () {
this.e.original_msg = this.e.original_msg || this.e.msg
}
async dispatch (e) { async dispatch (e) {
let msg = e.raw_message let msg = e.original_msg || ''
if (!msg) {
return false
}
e.checkAuth = async function (cfg) { e.checkAuth = async function (cfg) {
return await checkAuth(e, cfg) return await checkAuth(e, cfg)
} }

View File

@ -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 utils from '../model/mys/utils.js';
import promiseRetry from 'promise-retry'; import promiseRetry from 'promise-retry';
import { import {
@ -22,9 +22,9 @@ export const rule = {
reg: "^#*(崩坏3|崩坏2|未定事件簿)签到$", reg: "^#*(崩坏3|崩坏2|未定事件簿)签到$",
describe: "米社规则签到" describe: "米社规则签到"
}, },
signlist:{ signlist: {
reg: "^#(米游币|米社)全部签到$", reg: "^#(米游币|米社)全部签到$",
describe: "米游币全部签到" describe: "米游币全部签到"
}, },
// allMysSign: { // allMysSign: {
// reg: "^#米游币全部签到$", // reg: "^#米游币全部签到$",
@ -51,7 +51,8 @@ const RETRY_OPTIONS = {
export async function sign(e) { export async function sign(e) {
let { let {
skuid,cookie skuid,
cookie
} = await getCookie(e); } = await getCookie(e);
if (!cookie) { if (!cookie) {
e.reply("请先绑定cookie~\n发送【cookie帮助】获取教程") e.reply("请先绑定cookie~\n发送【cookie帮助】获取教程")
@ -98,7 +99,7 @@ export async function mysSign(e) {
let iscount = ""; let iscount = "";
let miHoYoApi = new MihoYoApi(e); let miHoYoApi = new MihoYoApi(e);
if (Object.keys((await miHoYoApi.getStoken(e.user_id))).length == 0) { 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; return true;
} }
@ -292,7 +293,6 @@ export async function allMysSign() {
if (!isPushSign) { if (!isPushSign) {
return; return;
} }
if (msg.includes("签到成功") && (cookie.isSignPush === true || cookie.isSignPush === undefined)) { if (msg.includes("签到成功") && (cookie.isSignPush === true || cookie.isSignPush === undefined)) {
// msg = msg.replace("签到成功", "自动签到成功"); // msg = msg.replace("签到成功", "自动签到成功");
utils.relpyPrivate(user_id, msg + "\n自动签到成功"); utils.relpyPrivate(user_id, msg + "\n自动签到成功");
@ -327,7 +327,7 @@ export async function allSign() {
qq, qq,
isTask: true isTask: true
}; };
e.msg="全部" e.msg = "全部"
e.reply = (msg) => { e.reply = (msg) => {
if (!msg.includes("OK")) { if (!msg.includes("OK")) {
return; return;
@ -351,23 +351,31 @@ const checkAuth = async function(e) {
(*/ω*)` (*/ω*)`
}); });
} }
let isbool=false; let isbool = false;
export async function signlist(e){ let ismysbool = false;
export async function signlist(e) {
if (!await checkAuth(e)) { if (!await checkAuth(e)) {
return true; return true;
} }
if(isbool){ if (isbool) {
e.reply(`签到中请勿重复执行`) e.reply(`米社签到中请勿重复执行`)
return true; return true;
} }
isbool=true; if (ismysbool) {
let msg=e.msg.replace(/#|全部签到/g,"") e.reply(`米游币签到中请勿重复执行`)
return true;
}
let msg = e.msg.replace(/#|全部签到/g, "")
e.reply(`开始执行${msg}签到中,请勿重复执行`); e.reply(`开始执行${msg}签到中,请勿重复执行`);
if(msg=="米游币"){ if (msg == "米游币") {
ismysbool=true;
await allMysSign() await allMysSign()
}else{ } else {
isbool = true;
await allSign() await allSign()
} }
e.reply(`${msg}签到任务已完成`); e.reply(`${msg}签到任务已完成`);
isbool=false; ismysbool=false;
isbool = false;
return true;
} }

View File

@ -55,13 +55,13 @@ export async function roleInfo(e) {
} }
const send_Msg = function(e, type, name) { 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") { if (type == "all") {
for (let val of list) { 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/`, let new_name = info_img(e, Data.readJSON(`${_path}/plugins/xiaoyao-cvs-plugin/resources/Atlas_alias/`,
val), name) val), name)
if (new_name) { if (new_name) {

View File

@ -13,9 +13,8 @@ if (isV3) {
index = await Data.importModule('/plugins/xiaoyao-cvs-plugin/adapter', 'index.js') index = await Data.importModule('/plugins/xiaoyao-cvs-plugin/adapter', 'index.js')
} }
export const atlas = index.atlas || {} export const atlas = index.atlas || {}
Bot.logger.info(`--------------------------`) Bot.logger.info(`---------^_^---------`)
Bot.logger.info(`图鉴插件${currentVersion}初始化~`) Bot.logger.info(`图鉴插件${currentVersion}初始化~`)
Bot.logger.info(`--------------------------`)
setTimeout(async function() { setTimeout(async function() {
let msgStr = await redis.get('xiaoyao:restart-msg') let msgStr = await redis.get('xiaoyao:restart-msg')

View File

@ -84,7 +84,6 @@ export default class MihoYoApi {
this.e = e this.e = e
this.cookie = e.cookie this.cookie = e.cookie
this.userId = String(e.user_id) this.userId = String(e.user_id)
this.msgName = e.msg.replace(/#|签到|井|米游社|mys|社区/g, "")
// //初始化配置文件 // //初始化配置文件
let data = this.getStoken(this.e.user_id); let data = this.getStoken(this.e.user_id);
if (data) { if (data) {
@ -111,7 +110,7 @@ export default class MihoYoApi {
} }
if (!objData.nickname) { if (!objData.nickname) {
return { return {
message: `未绑定${this.msgName}信息` message: `未绑定${name}信息`
} }
} }
// 获取签到信息和奖励信息 、、后续重新梳理补充 // 获取签到信息和奖励信息 、、后续重新梳理补充
@ -127,7 +126,7 @@ export default class MihoYoApi {
// 签到操作 // 签到操作
return await this.postSign(kkbody, objData.game_uid, objData.region) return await this.postSign(kkbody, objData.game_uid, objData.region)
} catch (error) { } catch (error) {
logger.mark(`error.message`, error.message) Bot.logger.mark(`error.message`, error.message)
} }
} }
async forumSign(forumId) { async forumSign(forumId) {
@ -168,7 +167,7 @@ export default class MihoYoApi {
} }
} }
} else { } else {
logger.mark(`ForumSign: error`); Bot.logger.mark(`ForumSign: error`);
} }
} }
} }