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:
leiyilu 2022-06-28 23:21:06 +08:00
parent 6cd22055a3
commit cfb7ccced0
30 changed files with 536 additions and 31 deletions

View File

@ -1,3 +1,10 @@
# 1.0.5
* 新增了一个体力模板
* 设置功能新增模板切换`图鉴设置模板(0-2)`
* 新版清新的模板背景路径**/plugins/xiaoyao-cvs-plugin/resources/dailyNote/icon/bg/**
* 模板背景可以自定义具体看内容
*/
# 1.0.4
* 新增了`版本号`
* 新增`图鉴目录`可以输入图鉴目录查看图鉴大概操作

View File

@ -8,9 +8,11 @@ import format from "date-format";
import puppeteer from "puppeteer";
import common from "../../../lib/common.js";
import lodash from "lodash";
import Data from "../components/Data.js"
import {
Cfg
} from "../components/index.js";
import moment from 'moment';
// import MysApi from "../components/MysApi.js"
import {
@ -19,6 +21,10 @@ import {
} from "../../../lib/app/mysApi.js";
const _path = process.cwd();
let role_user = Data.readJSON(`${_path}/plugins/xiaoyao-cvs-plugin/resources/dailyNote/json/`, "dispatch_time");
let path_url = ["dailyNote", "xiaoyao_Note"];
let path_img = ["background_image", "/icon/bg"];
//#体力
export async function Note(e, {
@ -87,7 +93,6 @@ export async function Note(e, {
}
let data = res.data;
//推送任务
if (e.isTask && data.current_resin < e.sendResin) {
return;
@ -99,23 +104,43 @@ export async function Note(e, {
let nowDay = format("dd", new Date());
let resinMaxTime;
let resinMaxTime_mb2;
let resinMaxTime_mb2Day;
if (data.resin_recovery_time > 0) {
resinMaxTime = new Date().getTime() + data.resin_recovery_time * 1000;
let maxDate = new Date(resinMaxTime);
resinMaxTime = format("hh:mm", maxDate);
let Time_day = await dateTime_(maxDate)
resinMaxTime_mb2 = Time_day + moment(maxDate).format("hh:mm");
// console.log(format("dd", maxDate))
if (format("dd", maxDate) != nowDay) {
resinMaxTime_mb2Day = `明天`;
resinMaxTime = `明天 ${resinMaxTime}`;
} else {
resinMaxTime_mb2Day = `今天`;
resinMaxTime = ` ${resinMaxTime}`;
}
}
// console.log(data.expeditions)
for (let val of data.expeditions) {
// console.log(val.remained_time)
if (val.remained_time > 0) {
// console.log(val.remained_time)
val.dq_time = val.remained_time;
val.remained_time = new Date().getTime() + val.remained_time * 1000;
// console.log(val.remained_time)
var urls_avatar_side = val.avatar_side_icon.split("_");
let id = YunzaiApps.mysInfo.roleIdToName(urls_avatar_side[urls_avatar_side.length - 1].replace(
/(.png|.jpg)/g, ""));
let name = YunzaiApps.mysInfo.roleIdToName(id, true);
var time_cha = 20;
if (role_user["12"].includes(name)) {
time_cha = 12;
}
val.percentage = ((val.dq_time / 60 / 60 * 1 / time_cha) * 100 / 10).toFixed(0) * 10;
let remainedDate = new Date(val.remained_time);
val.remained_time = format("hh:mm", remainedDate);
let Time_day = await dateTime_(remainedDate)
val.remained_mb2 = Time_day + moment(remainedDate).format("hh:mm" );
if (format("dd", remainedDate) != nowDay) {
val.remained_time = `明天 ${val.remained_time}`;
} else {
@ -139,18 +164,27 @@ export async function Note(e, {
}
}
let coinTime_mb2 = "";
let coinTime_mb2Day = "";
let coinTime = "";
var chnNumChar = ["零", "一", "后", "三", "四", "五", "六", "七", "八", "九"];
if (data.home_coin_recovery_time > 0) {
let coinDate = new Date(new Date().getTime() + data.home_coin_recovery_time * 1000);
let coinDay = Math.floor(data.home_coin_recovery_time / 3600 / 24);
let coinHour = Math.floor((data.home_coin_recovery_time / 3600) % 24);
let coinMin = Math.floor((data.home_coin_recovery_time / 60) % 60);
if (coinDay > 0) {
coinTime = `${coinDay}${coinHour}小时${coinMin}分钟`;
coinTime_mb2Day = chnNumChar[coinDay * 1] + "天";
let Time_day = await dateTime_(coinDate)
coinTime_mb2 = Time_day + moment(coinDate).format("hh:mm");
} else {
let coinDate = new Date(new Date().getTime() + data.home_coin_recovery_time * 1000);
coinTime_mb2 = moment(coinDate).format("hh:mm");
if (format("dd", coinDate) != nowDay) {
coinTime_mb2Day = "明天";
coinTime = `明天 ${format("hh:mm", coinDate)}`;
} else {
coinTime_mb2Day = "今天";
coinTime = format("hh:mm", coinDate);
}
}
@ -159,12 +193,11 @@ export async function Note(e, {
let day = format("MM-dd hh:mm", new Date());
let week = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];
day += " " + week[new Date().getDay()];
let day_mb2 = format("yyyy年MM月dd日 hh:mm", new Date()) + " " + week[new Date().getDay()];
//参量质变仪
if (data?.transformer?.obtained) {
data.transformer.reached = data.transformer.recovery_time.reached;
let recovery_time = "";
if (data.transformer.recovery_time.Day > 0) {
recovery_time += `${data.transformer.recovery_time.Day}`;
}
@ -176,19 +209,28 @@ export async function Note(e, {
}
data.transformer.recovery_time = recovery_time;
}
var image = fs.readdirSync(`./plugins/xiaoyao-cvs-plugin/resources/dailyNote/background_image`);
let mb=Cfg.get("mb.len", 0)-1;
if(mb<0){
mb=lodash.random(0,path_url.length-1);
}
var image = fs.readdirSync(`./plugins/xiaoyao-cvs-plugin/resources/dailyNote/${path_img[mb]}`);
var list_img = [];
for (let val of image) {
list_img.push(val)
}
var imgs = list_img.length == 1 ? list_img[0] : list_img[lodash.random(0, list_img.length - 1)];
return await Common.render("dailyNote/dailyNote", {
return await Common.render(`dailyNote/${path_url[mb]}`, {
save_id: uid,
uid: uid,
coinTime_mb2Day,
coinTime_mb2,
resinMaxTime_mb2Day,
resinMaxTime,
resinMaxTime_mb2,
remained_time,
coinTime,
imgs,
day_mb2,
day,
...data,
}, {
@ -199,6 +241,10 @@ export async function Note(e, {
return true;
}
async function dateTime_(time) {
return format("hh", time) < 6 ? "凌晨" : format("hh", time) < 12 ? "上午" : format("hh",
time) < 16 ? "下午" : "傍晚";
}
async function getDailyNote(uid, cookie) {
let {
@ -221,3 +267,52 @@ export async function saveJson() {
let path = "data/NoteCookie/NoteCookie.json";
fs.writeFileSync(path, JSON.stringify(NoteCookie, "", "\t"));
}
//体力定时推送
export async function DailyNoteTask() {
//体力大于多少时推送
let sendResin = 120;
//推送cd12小时一次
let sendCD = 12 * 3600;
//获取需要推送的用户
for (let [user_id, cookie] of Object.entries(NoteCookie)) {
user_id = cookie.qq || user_id;
//没有开启推送
if (!cookie.isPush) {
continue;
}
//今天已经提醒
let sendkey = `genshin:dailyNote:send:${user_id}`;
let send = await redis.get(sendkey);
if (send) {
continue;
}
let e = {
sendResin,
user_id,
isTask: true
};
e.reply = (msg) => {
common.relpyPrivate(user_id, msg);
};
//判断今天是否推送
if (cookie.maxTime && cookie.maxTime > 0 && new Date().getTime() > cookie.maxTime - (160 - sendResin) * 8 *
60 * 1000) {
//Bot.logger.mark(`体力推送:${user_id}`);
redis.set(sendkey, "1", {
EX: sendCD
});
await Note(e, {
render
});
}
}
}

View File

@ -23,6 +23,7 @@ let cfgMap = {
"体力": "sys.Note",
"帮助": "sys.help",
"匹配": "sys.Atlas",
"模板": "mb.len",
};
let sysCfgReg = `^#图鉴设置\s*(${lodash.keys(cfgMap).join("|")})?\s*(.*)$`;
export const rule = {
@ -61,8 +62,8 @@ export async function sysCfg(e, {
if (!regRet) {
return true;
}
console.log(regRet)
if (regRet[1]) {
// 设置模式
let val = regRet[2] || "";
@ -70,11 +71,12 @@ export async function sysCfg(e, {
if (cfgKey === "sys.scale") {
val = Math.min(200, Math.max(50, val * 1 || 100));
}else if(cfgKey === "mb.len"){
val= Math.min(2,Math.max(val,0));
} else {
val = !/关闭/.test(val);
}
if (cfgKey) {
console.log(val)
Cfg.set(cfgKey, val);
}
}
@ -84,8 +86,9 @@ export async function sysCfg(e, {
help: getStatus("sys.help", false),
Note: getStatus("sys.Note"),
Atlas: getStatus("sys.Atlas"),
len:Cfg.get("mb.len", 0),
imgPlus: fs.existsSync(plusPath),
bg:await rodom(), //获取底图
bg: await rodom(), //获取底图
}
console.log(cfg)
//渲染图像
@ -98,7 +101,7 @@ export async function sysCfg(e, {
});
}
const rodom=async function(){
const rodom = async function() {
var image = fs.readdirSync(`./plugins/xiaoyao-cvs-plugin/resources/admin/imgs/bg`);
var list_img = [];
for (let val of image) {
@ -135,6 +138,7 @@ export async function updateRes(e) {
let isForce = e.msg.includes("强制");
if (isForce) {
command = "git checkout . && git pull";
// command="git fetch --all && git reset --hard origin/master && git pull "
e.reply("正在执行强制更新操作,请稍等");
} else {
e.reply("正在执行更新操作,请稍等");
@ -195,7 +199,7 @@ export async function updateMiaoPlugin(e) {
cwd: `${_path}/plugins/xiaoyao-cvs-plugin/`
}, function(error, stdout, stderr) {
//console.log(stdout);
if (/Already up[ -]to[ -]date/.test(stdout)) {
if (/Already up[ -]to[ -]date/.test(stdout)) {
e.reply("目前已经是最新版图鉴插件了~");
return true;
}
@ -211,22 +215,23 @@ export async function updateMiaoPlugin(e) {
}), {
EX: 30
});
timer = setTimeout(function () {
let command = `npm run start`;
if (process.argv[1].includes("pm2")) {
command = `npm run restart`;
}
exec(command, function (error, stdout, stderr) {
if (error) {
e.reply("自动重启失败,请手动重启以应用新版图鉴插件。\nError code: " + error.code + "\n" + error.stack + "\n");
Bot.logger.error('重启失败\n${error.stack}');
return true;
} else if (stdout) {
Bot.logger.mark("重启成功运行已转为后台查看日志请用命令npm run log");
Bot.logger.mark("停止后台运行命令npm stop");
process.exit();
}
})
timer = setTimeout(function() {
let command = `npm run start`;
if (process.argv[1].includes("pm2")) {
command = `npm run restart`;
}
exec(command, function(error, stdout, stderr) {
if (error) {
e.reply("自动重启失败,请手动重启以应用新版图鉴插件。\nError code: " + error.code + "\n" +
error.stack + "\n");
Bot.logger.error('重启失败\n${error.stack}');
return true;
} else if (stdout) {
Bot.logger.mark("重启成功运行已转为后台查看日志请用命令npm run log");
Bot.logger.mark("停止后台运行命令npm stop");
process.exit();
}
})
}, 1000);
});

View File

@ -26,7 +26,7 @@ export async function AtlasAlias(e) {
// if (await foodInfo(e)) return true;
// if (await RelicsInfo(e)) return true;
// if (await monsterInfo(e)) return true;
var name = e.msg.replace(/#||信息|图鉴|命座|天赋|突破|圣遗物|食物|食材|特殊|材|料|特色|料理|理/g, "");
var name = e.msg.replace(/#||信息|图鉴|圣遗物|食物|食材|特殊|特色|料理/g, "");
return send_Msg(e, "all", name);
}

View File

@ -100,6 +100,14 @@
</div>
<div class="cfg-desc">开启后将使用图鉴版体力作为Yunzai的默认体力</div>
</li>
<li class="cfg-li">
<div class="cfg-line">
设置体力模板类型
<span class="cfg-hint">#图鉴设置模板 + (0-2)</span>
<div class="cfg-status">{{@len}}</div>
</div>
<div class="cfg-desc">需开启图鉴版体力作为Yunzai的默认体力,当前模板支持0(随机)以及1-2</div>
</li>
<!-- <li class="cfg-li">
<div class="cfg-line">
更新版本

Binary file not shown.

After

Width:  |  Height:  |  Size: 628 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 590 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 348 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.4 KiB

View File

@ -0,0 +1,3 @@
{
"12": ["班尼特", "刻晴", "重云", "九条裟罗", "菲谢尔"]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@ -0,0 +1,255 @@
@font-face {
font-family: HYWenHei;
src: url(../font/HYWenHei.ttf);
}
@font-face {
font-family: MiSans-Regular;
src: url(../font/MiSans-Regular.ttf);
}
@font-face {
font-family: MiSans-Medium;
src: url(../font/MiSans-Medium.ttf);
}
@font-face {
font-family: HYWenHei-HEW;
src: url(../font/HYWenHei-HEW.ttf);
}
#container {
min-height: 627px;
height: auto;
width: 1137px;
background-color: rgba(0, 0, 0, 0.5);
}
.left_model {
width: calc(50% - 136px);
padding: 75px 0;
padding-left: 136px;
display: inline-block;
float: left;
}
.left_model img {
width: 40px;
height: 40px;
vertical-align: middle;
}
.div {
display: inline-block;
vertical-align: middle;
}
.left_model .div:nth-child(2) {
margin-left: 22px;
width: 190px;
}
.title {
font-size: 24px;
font-family: "MiSans-Regular";
color: #444444;
display: block;
text-align: left;
src: url("{{_res_path}}font/MiSans-Regular.ttf");
}
.bottom {
text-align: left;
color: #a9834f;
font-family: "MiSans-Regular";
}
.time {
border-radius: 15px;
background-color: #a9834f;
color: #fff;
text-align: center;
padding: 4px 10px;
margin: 0 6px;
font-family: "HYWenHei";
}
.kb {
height: 10px;
}
.list {
margin-bottom: 42px;
}
.list:last-child {
margin-bottom: 0;
}
.sumCount {
font-size: 30px;
font-family: "HYWenHei";
text-align: center;
color: #a9843f;
/* float: right; */
width: 170px;
/* margin-top: 10px; */
background-image: url(./icon/矩形.png);
}
.right_model {
display: inline-block;
width: calc(50% - 135px);
padding: 80px 58px 45px;
float: left;
}
.uId {
text-align: center;
background-image: url(./icon/圆角矩形.png);
text-align: center;
width: 364px;
height: 50px;
line-height: 50px;
color: #a9843f;
font-size: 24px;
font-family: 'HYWenHei';
}
.head_image {
margin-top: 45px;
}
.icon {
vertical-align: middle;
display: inline-block;
position: absolute;
margin-left: -5px;
top: -20px;
left: -5px;
}
.icon img {
width: 78px;
height: 78px;
}
.text {
vertical-align: middle;
display: inline-block;
width: calc(80px);
font-size: 16px;
text-align: center;
color: #a9843f;
position: absolute;
font-family: "MiSans-Medium";
top: 20%;
margin-left: 25px;
}
.li {
width: 44%;
display: inline-block;
position: relative;
margin-bottom: 42px;
}
.circleProgress_wrapper {
width: 64px;
height: 64px;
/* margin: 50px auto; */
position: relative;
display: inline-block;
/* border:1px solid #ddd; */
}
.wrapper {
width: 32px;
height: 64px;
position: absolute;
top: 0;
overflow: hidden;
}
.right {
right: 0;
/* border: solid 1px black; */
}
.left {
left: 0;
/* border: solid 1px red; */
}
.circleProgress {
width: 58px;
height: 58px;
border: 3px solid rgb(172, 172, 172);
position: absolute;
top: 0;
border-radius: 50%;
transform: rotate(-135deg);
}
.rightcircle {
border-top: 3px solid rgb(218, 252, 24);
border-right: 3px solid rgb(218, 252, 24);
right: 0;
animation: circleProgressLoad_right;
}
.leftcircle {
border-bottom: 3px solid rgb(218, 252, 24);
border-left: 3px solid rgb(218, 252, 24);
left: 0;
animation: circleProgressLoad_right 0.1ms linear 0ms normal forwards;
}
@keyframes circleProgressLoad_right {
0% {
-webkit-transform: rotate(-135deg);
}
50%,
100% {
-webkit-transform: rotate(45deg);
}
}
@keyframes circleProgressLoad_left {
0%,
50% {
-webkit-transform: rotate(-135deg);
}
100% {
-webkit-transform: rotate(45deg);
}
}
.bottom_time {
display: flex;
font-size: 20px;
color: #d9766c;
font-family: "HYWenHei";
text-align: center;
width: 200px;
}
.bottom_image {
width: 212px;
height: 163px;
display: inline-block;
}
.bottom_image img {
width: 100%;
height: 100%;
}
.jdt {
display: inline-flex;
}

View File

@ -0,0 +1,132 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<link rel="shortcut icon" href="#" />
<link rel="stylesheet" type="text/css" href="{{_res_path}}dailyNote/xiaoyao_Note.css?v=1.0" />
<style>
</style>
</head>
<body>
<div class="container" id="container" style=" background-image: url({{_res_path}}/dailyNote/icon/bg/bg.png);">
<div class="left_model">
<div class="list">
<div class="div">
<img src="{{_res_path}}/dailyNote/icon/树脂.png" alt="">
</div>
<div class="div">
<span class="title">原脆树脂</span>
<div class="kb"></div>
<span class="bottom">{{resinMaxTime_mb2Day}}<span class="time">{{resinMaxTime_mb2}}</span>恢复</span>
</div>
<div class="div sumCount">
{{current_resin}}/{{max_resin}}
</div>
</div>
<div class="list">
<div class="div">
<img src="{{_res_path}}/dailyNote/icon/洞天宝钱.png" alt="">
</div>
<div class="div">
<span class="title">洞庭宝钱</span>
<div class="kb"></div>
<span class="bottom">{{coinTime_mb2Day}}<span class="time">{{coinTime_mb2}}</span>恢复</span>
</div>
<div class="div sumCount">
<!-- /{{max_home_coin}} -->
<span class="{{if current_home_coin/max_home_coin > 0.9}}red{{/if}}">{{current_home_coin}}</span>
</div>
</div>
<div class="list">
<div class="div">
<img src="{{_res_path}}/dailyNote/icon/每日.png" alt="">
</div>
<div class="div">
<span class="title">每日委托</span>
<div class="kb"></div>
<span class="bottom">今日委托奖励{{if is_extra_task_reward_received==1}}已{{else}}未{{/if}}领取</span>
</div>
<div class="div sumCount">
{{finished_task_num}}/{{total_task_num}}
</div>
</div>
<div class="list">
<div class="div">
<img src="{{_res_path}}/dailyNote/icon/周本.png" alt="">
</div>
<div class="div">
<span class="title">值得铭记的强敌</span>
<div class="kb"></div>
<span class="bottom">本周剩余消耗减半次数</span>
</div>
<div class="div sumCount">
{{3-remain_resin_discount_num}}/{{resin_discount_num_limit}}
</div>
</div>
<div class="list">
<div class="div">
<img src="{{_res_path}}/dailyNote/icon/质变仪.png" alt="">
</div>
<div class="div">
<span class="title">参量质变仪</span>
<div class="kb"></div>
<span class="bottom">
{{if transformer.obtained }}
{{if transformer.reached}}已准备完成
{{else}}预计<span class="time">{{transformer.recovery_time}}</span>后可使用{{/if}}
{{else}}尚未获得{{/if}}
<!-- {{coinTime_mb2Day}}<span class="time">{{coinTime_mb2}}</span>恢复 -->
</span>
</div>
<div class="div sumCount">
<span
class="{{if transformer.obtained && transformer.reached }}red{{/if}}">{{if transformer.obtained }}{{if transformer.reached}}可使用
{{else}}冷却中{{/if}}
{{else}}尚未获得{{/if}}</span>
</div>
</div>
</div>
<div class="right_model">
<div class="uId">
UID:120065390
</div>
<div class="head_image">
{{each expeditions list}}
<div class="li">
<!-- <div class="circleProgress_wrapper">
<div class="wrapper right">
<div class="circleProgress rightcircle"></div>
</div>
<div class="wrapper left">
<div class="circleProgress leftcircle"></div>
</div>
</div> -->
<div class="jdt">
<img src="{{_res_path}}/dailyNote/speed/{{list.percentage}}.png"/>
</div>
<div class="icon">
<img src="{{list.avatar_side_icon}}" alt="">
</div>
<div class="text" style="top:{{list.remained_time==0?'30%':'20%'}}">
<span>{{if list.remained_time==0}}已完成
{{else}}{{list.remained_mb2}}完成{{/if}}</span>
</div>
</div>
{{/each}}
</div>
<div class="bottom_list">
<div class="bottom_time">
{{day_mb2}}
</div>
<!-- <div class="bottom_image">
<img src="{{_res_path}}/dailyNote/icon/图片.png" alt="">
</div> -->
</div>
</div>
</div>
</body>
</html>