2
0
mirror of https://github.com/ctrlcvs/xiaoyao-cvs-plugin.git synced 2025-01-23 06:31:09 +08:00

修正米游币签到逻辑补充米币任务数据

This commit is contained in:
Ctrlcvs 2022-08-11 22:37:56 +08:00 committed by leiyilu
parent 066c2b5314
commit 6fdbe44f0e
4 changed files with 75 additions and 31 deletions

View File

@ -1,5 +1,8 @@
# 1.1.7
* 新增指令`#米币查询`
* 新增`道具图鉴`图鉴数据
* 修正米游币签到逻辑
# 1.1.6 # 1.1.6
* 初步实现云原神签到 以及查询时间
* 通过发送token以及devId给机器人实现绑定 * 通过发送token以及devId给机器人实现绑定
* 格式支持`ai=*;ci=*;oi=*;ct=***********;si=**************;bi=***********;devId=***********` * 格式支持`ai=*;ci=*;oi=*;ct=***********;si=**************;bi=***********;devId=***********`
* 新增指令`#云原神签到`可进行云原神签到 * 新增指令`#云原神签到`可进行云原神签到
@ -49,5 +52,3 @@
* 增加`#**图鉴`用于查看逍遥全图鉴 * 增加`#**图鉴`用于查看逍遥全图鉴
* 增加`#图鉴更新`用于获取图鉴数据 * 增加`#图鉴更新`用于获取图鉴数据
* 增加`#图鉴插件(强制)更新`用于插件包更新 * 增加`#图鉴插件(强制)更新`用于插件包更新
# 1.0.0
* ~~~~~~~~~~~

View File

@ -29,13 +29,13 @@ import {
cookiesDocHelp, cookiesDocHelp,
signlist,yunSignlist,yunAllSign, signlist,yunSignlist,yunAllSign,
allMysSign,yunSign,sendyunTime,yuntoken,yunHelp, allMysSign,yunSign,sendyunTime,yuntoken,yunHelp,
allSign allSign,bbsSeach
} from "./sign.js" } from "./sign.js"
export { export {
updateRes,yunSignlist, updateRes,yunSignlist,
signlist, signlist,
updateMiaoPlugin, updateMiaoPlugin,
sign, sign,bbsSeach,
versionInfo,yunAllSign, versionInfo,yunAllSign,
Note_appoint, Note_appoint,
pokeNote,yunSign,sendyunTime,yuntoken, pokeNote,yunSign,sendyunTime,yuntoken,

View File

@ -11,12 +11,19 @@ import {
} from '../components/Changelog.js'; } from '../components/Changelog.js';
import gsCfg from '../model/gsCfg.js'; import gsCfg from '../model/gsCfg.js';
import fs from "fs"; import fs from "fs";
import {
segment
} from "oicq";
import YAML from 'yaml' import YAML from 'yaml'
export const rule = { export const rule = {
mysSign: { mysSign: {
reg: "^#*(米游社|mys|社区)(原神|崩坏3|崩坏2|未定事件簿|大别野|崩坏星穹铁道|绝区零|全部)签到$", reg: "^#*(米游社|mys|社区)(原神|崩坏3|崩坏2|未定事件簿|大别野|崩坏星穹铁道|绝区零|全部)签到$",
describe: "米游社米游币签到(理论上会签到全部所以区分开了)" describe: "米游社米游币签到(理论上会签到全部所以区分开了)"
}, },
bbsSeach:{
reg: "^#*(米游币|米币)查询$",
describe: "米币查询"
},
sign: { sign: {
reg: "^#*(崩坏3|崩坏2|未定事件簿)签到$", reg: "^#*(崩坏3|崩坏2|未定事件簿)签到$",
describe: "米社规则签到" describe: "米社规则签到"
@ -119,9 +126,14 @@ export async function mysSign(e) {
e.reply("未读取到stoken请检查cookies是否包含login_ticket、以及云崽是否为最新版本V3、V2兼容") e.reply("未读取到stoken请检查cookies是否包含login_ticket、以及云崽是否为最新版本V3、V2兼容")
return true; return true;
} }
START = moment().unix(); START = moment().unix();
let resultMessage = ""; let resultMessage = "";
let resObj=await mysSeach(e)
if(resObj.data.can_get_points===0){
resultMessage+=`今日米游币任务已完成~\n请勿重复操作\n当前米游币总持有数量为:${resObj.data.total_points}`;
await replyMsg(e, resultMessage);
return true
}
// Execute task // Execute task
let msg = e.msg.replace(/#|签到|井|米游社|mys|社区/g, ""); let msg = e.msg.replace(/#|签到|井|米游社|mys|社区/g, "");
let ForumData = await getDataList(msg); let ForumData = await getDataList(msg);
@ -203,11 +215,35 @@ export async function mysSign(e) {
return true return true
} }
export async function bbsSeach(e){
let miHoYoApi = new MihoYoApi(e);
if (Object.keys((await miHoYoApi.getStoken(e.user_id))).length == 0) {
e.reply("未读取到stoken请检查cookies是否包含login_ticket请先绑定stoken再查询~");
await cookiesDocHelp(e);
return true;
}
let resObj=await mysSeach(e)
e.reply(`当前米游币数量为:${resObj.data.total_points},今日剩余可获取:${resObj.data.can_get_points}`);
return true;
}
async function mysSeach(e){
let miHoYoApi = new MihoYoApi(e);
try{
let resObj = await promiseRetry((retry, number) => {
return miHoYoApi.getTasksList().catch((e) => {
return retry(e);
});
}, RETRY_OPTIONS);
return resObj
}catch(e){
}
}
async function replyMsg(e, resultMessage) { async function replyMsg(e, resultMessage) {
const END = moment().unix(); const END = moment().unix();
Bot.logger.info(`运行结束, 用时 ${END - START}`); Bot.logger.info(`运行结束, 用时 ${END - START}`);
resultMessage += `\n用时 ${END - START}`; resultMessage += `\n用时 ${END - START}`;
e.reply(resultMessage); e.reply([segment.at(e.user_id),"\n"+resultMessage]);
} }
async function getDataList(name) { async function getDataList(name) {

View File

@ -133,7 +133,9 @@ export default class MihoYoApi {
// } // }
// } // }
// 签到操作 // 签到操作
return {message} return {
message
}
} catch (error) { } catch (error) {
Bot.logger.mark(`error.message`, error.message) Bot.logger.mark(`error.message`, error.message)
} }
@ -145,7 +147,12 @@ export default class MihoYoApi {
// Bot.logger.mark(`ForumSign: ${res.text}`); // Bot.logger.mark(`ForumSign: ${res.text}`);
return resObj; return resObj;
} }
async getTasksList() {
let res = await superagent.get(`https://bbs-api.mihoyo.com/apihub/sapi/getUserMissionsState`).set(this
._getHeader()).timeout(10000);
let resObj = JSON.parse(res.text);
return resObj
}
// 获取签到状态和奖励信息 // 获取签到状态和奖励信息
async getHonkai3rdSignInfo(game_uid, region, nickname, board) { async getHonkai3rdSignInfo(game_uid, region, nickname, board) {
let res = await superagent.get( let res = await superagent.get(