mirror of
https://github.com/ctrlcvs/xiaoyao-cvs-plugin.git
synced 2025-03-10 19:55:23 +08:00
修复报错
This commit is contained in:
parent
176db5015c
commit
02b6f3943d
205
apps/Note.js
205
apps/Note.js
@ -18,10 +18,7 @@ import utils from "../model/mys/utils.js";
|
|||||||
import note from '../model/note.js'
|
import note from '../model/note.js'
|
||||||
import User from "../model/user.js";
|
import User from "../model/user.js";
|
||||||
const _path = process.cwd();
|
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"];
|
|
||||||
let tempDataUrl = `${_path}/plugins/xiaoyao-cvs-plugin/data/NoteTemp`
|
let tempDataUrl = `${_path}/plugins/xiaoyao-cvs-plugin/data/NoteTemp`
|
||||||
let tempData = {};
|
let tempData = {};
|
||||||
init()
|
init()
|
||||||
@ -37,6 +34,7 @@ export async function Note(e, {
|
|||||||
if (!Cfg.get("sys.Note") && !poke) {
|
if (!Cfg.get("sys.Note") && !poke) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
let notes = new note(e);
|
||||||
let cookie, uid, res;
|
let cookie, uid, res;
|
||||||
if (isV3) {
|
if (isV3) {
|
||||||
let MysInfo = await import(`file://${_path}/plugins/genshin/model/mys/mysInfo.js`);
|
let MysInfo = await import(`file://${_path}/plugins/genshin/model/mys/mysInfo.js`);
|
||||||
@ -83,218 +81,25 @@ export async function Note(e, {
|
|||||||
e.reply(`体力查询错误:${res.message}`);
|
e.reply(`体力查询错误:${res.message}`);
|
||||||
Bot.logger.mark(`体力查询错误:${JSON.stringify(res)}`);
|
Bot.logger.mark(`体力查询错误:${JSON.stringify(res)}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//redis保存uid
|
//redis保存uid
|
||||||
redis.set(`genshin:uid:${e.user_id}`, uid, {
|
redis.set(`genshin:uid:${e.user_id}`, uid, {
|
||||||
EX: 2592000
|
EX: 2592000
|
||||||
});
|
});
|
||||||
|
|
||||||
//更新
|
//更新
|
||||||
if (NoteCookie[e.user_id]) {
|
if (NoteCookie[e.user_id]) {
|
||||||
NoteCookie[e.user_id].maxTime = new Date().getTime() + res.data.resin_recovery_time * 1000;
|
NoteCookie[e.user_id].maxTime = new Date().getTime() + res.data.resin_recovery_time * 1000;
|
||||||
saveJson();
|
saveJson();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let data = res.data;
|
await notes.getNote(cookie,uid,res,{render})
|
||||||
//推送任务
|
|
||||||
if (e.isTask && data.current_resin < e.sendResin) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (e.isTask) {
|
|
||||||
Bot.logger.mark(`体力推送:${e.user_id}`);
|
|
||||||
}
|
|
||||||
let nowDay = moment(new Date()).format("DD");
|
|
||||||
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 = moment(maxDate).format("HH:mm");
|
|
||||||
let Time_day = await dateTime_(maxDate)
|
|
||||||
resinMaxTime_mb2 = Time_day + moment(maxDate).format("hh:mm");
|
|
||||||
if (moment(maxDate).format("DD") != nowDay) {
|
|
||||||
resinMaxTime_mb2Day = `明天`;
|
|
||||||
resinMaxTime = `明天 ${resinMaxTime}`;
|
|
||||||
} else {
|
|
||||||
resinMaxTime_mb2Day = `今天`;
|
|
||||||
resinMaxTime = ` ${resinMaxTime}`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (let val of data.expeditions) {
|
|
||||||
if (val.remained_time <= 0) {
|
|
||||||
val.percentage = 0;
|
|
||||||
}
|
|
||||||
if (val.remained_time > 0) {
|
|
||||||
val.dq_time = val.remained_time;
|
|
||||||
val.remained_time = new Date().getTime() + val.remained_time * 1000;
|
|
||||||
var urls_avatar_side = val.avatar_side_icon.split("_");
|
|
||||||
let Botcfg;
|
|
||||||
if (isV3) {
|
|
||||||
Botcfg = (await import(`file://${_path}/plugins/genshin/model/gsCfg.js`)).default;
|
|
||||||
} else {
|
|
||||||
Botcfg = YunzaiApps.mysInfo
|
|
||||||
}
|
|
||||||
let id = Botcfg.roleIdToName(urls_avatar_side[urls_avatar_side.length - 1].replace(
|
|
||||||
/(.png|.jpg)/g, ""));
|
|
||||||
let name = Botcfg.roleIdToName(id, true);
|
|
||||||
var time_cha = 20;
|
|
||||||
if (role_user["12"].includes(name)) {
|
|
||||||
time_cha = 15;
|
|
||||||
}
|
|
||||||
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 = moment(remainedDate).format("HH:mm");
|
|
||||||
let Time_day = await dateTime_(remainedDate)
|
|
||||||
if (moment(remainedDate).format("DD") != nowDay) {
|
|
||||||
val.remained_mb2 = "明天" + Time_day + moment(remainedDate).format("hh:mm");
|
|
||||||
val.remained_time = `明天 ${val.remained_time}`;
|
|
||||||
} else {
|
|
||||||
val.remained_mb2 = "今天" + Time_day + moment(remainedDate).format("hh:mm");
|
|
||||||
val.remained_time = ` ${val.remained_time}`;
|
|
||||||
}
|
|
||||||
val.mb2_icon = val.avatar_side_icon
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let remained_time = "";
|
|
||||||
if (data.expeditions && data.expeditions.length >= 1) {
|
|
||||||
remained_time = lodash.map(data.expeditions, "remained_time");
|
|
||||||
remained_time = lodash.min(remained_time);
|
|
||||||
if (remained_time > 0) {
|
|
||||||
remained_time = new Date().getTime() + remained_time * 1000;
|
|
||||||
let remainedDate = new Date(remained_time);
|
|
||||||
remained_time = moment(remainedDate).format("hh:mm");
|
|
||||||
if (moment(remainedDate).format("DD") != nowDay) {
|
|
||||||
remained_time = `明天 ${remained_time}`;
|
|
||||||
} else {
|
|
||||||
remained_time = ` ${remained_time}`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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}分钟`;
|
|
||||||
let dayTime = (24 - moment(new Date()).format('HH') + moment(coinDate).diff(new Date(), 'hours')) / 24
|
|
||||||
coinTime_mb2Day = chnNumChar[dayTime.toFixed(0)] + "天";
|
|
||||||
let Time_day = await dateTime_(coinDate)
|
|
||||||
coinTime_mb2 = Time_day + moment(coinDate).format("hh:mm");
|
|
||||||
} else {
|
|
||||||
coinTime_mb2 = moment(coinDate).format("hh:mm");
|
|
||||||
if (moment(coinDate).format("DD") != nowDay) {
|
|
||||||
coinTime_mb2Day = "明天";
|
|
||||||
coinTime = `明天 ${ moment(coinDate).format("hh:mm")}`;
|
|
||||||
} else {
|
|
||||||
coinTime_mb2Day = "今天";
|
|
||||||
coinTime = moment(coinDate).format("hh:mm", coinDate);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let day = moment(new Date()).format("MM-DD HH:mm");
|
|
||||||
let week = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];
|
|
||||||
day += " " + week[new Date().getDay()];
|
|
||||||
let day_mb2 = moment(new Date()).format("yyyy年MM月DD日 HH:mm") + " " + 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}天`;
|
|
||||||
}
|
|
||||||
if (data.transformer.recovery_time.Hour > 0) {
|
|
||||||
recovery_time += `${data.transformer.recovery_time.Hour}小时`;
|
|
||||||
}
|
|
||||||
if (data.transformer.recovery_time.Minute > 0) {
|
|
||||||
recovery_time += `${data.transformer.recovery_time.Minute}分钟`;
|
|
||||||
}
|
|
||||||
data.transformer.recovery_time = recovery_time;
|
|
||||||
}
|
|
||||||
let mb = Cfg.get("mb.len", 0) - 1;
|
|
||||||
if (mb < 0) {
|
|
||||||
mb = lodash.random(0, path_url.length - 1);
|
|
||||||
}
|
|
||||||
let urlType = note_file("xiaoyao");
|
|
||||||
let objFile = Object.keys(urlType)
|
|
||||||
if (objFile.length > 0) {
|
|
||||||
objFile = objFile[lodash.random(0, objFile.length - 1)]
|
|
||||||
}
|
|
||||||
let img_path = `./plugins/xiaoyao-cvs-plugin/resources/dailyNote/${path_img[mb]}`;
|
|
||||||
if (tempData[e.user_id] && tempData[e.user_id].type > -1&&tempData[e.user_id]?.temp?.length!==0) {
|
|
||||||
// mb = tempData[e.user_id].type;
|
|
||||||
if (typeof tempData[e.user_id]["temp"] === "string") {
|
|
||||||
objFile = tempData[e.user_id]["temp"]
|
|
||||||
} else {
|
|
||||||
objFile = tempData[e.user_id].temp[lodash.random(0, tempData[e.user_id].temp.length - 1)];
|
|
||||||
}
|
|
||||||
if (objFile.includes(".")) { //对于模板类型处理
|
|
||||||
mb = 0;
|
|
||||||
} else {
|
|
||||||
mb = 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (mb == 1) {
|
|
||||||
for (var i = 0; i < 5 - data.expeditions.length; i++) {
|
|
||||||
data.expeditions.push({
|
|
||||||
remained_time: 0,
|
|
||||||
remained_mb2: 0,
|
|
||||||
percentage: 0,
|
|
||||||
mb2_icon: ""
|
|
||||||
})
|
|
||||||
}
|
|
||||||
img_path = `${urlType[objFile]}${path_img[mb]}`;
|
|
||||||
}
|
|
||||||
var image = fs.readdirSync(img_path);
|
|
||||||
// console.log(fs.readdirSync(`./plugins/xiaoyao-cvs-plugin/resources/dailyNote/BJT-Templet/Template2`))
|
|
||||||
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)];
|
|
||||||
if (mb == 0 && objFile.includes(".")) {
|
|
||||||
imgs = objFile
|
|
||||||
}
|
|
||||||
return await Common.render(`dailyNote/${path_url[mb]}`, {
|
|
||||||
save_id: uid,
|
|
||||||
uid: uid,
|
|
||||||
coinTime_mb2Day,
|
|
||||||
coinTime_mb2,
|
|
||||||
urlType: encodeURIComponent(img_path.replace(
|
|
||||||
/(\.\/plugins\/xiaoyao-cvs-plugin\/resources\/|\/icon\/bg)/g, '')).replace(/%2F/g, "/"),
|
|
||||||
resinMaxTime_mb2Day,
|
|
||||||
resinMaxTime,
|
|
||||||
resinMaxTime_mb2,
|
|
||||||
remained_time,
|
|
||||||
coinTime,
|
|
||||||
imgs: encodeURIComponent(imgs),
|
|
||||||
day_mb2,
|
|
||||||
day,
|
|
||||||
...data,
|
|
||||||
}, {
|
|
||||||
e,
|
|
||||||
render,
|
|
||||||
scale: 1.2
|
|
||||||
})
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function dateTime_(time) {
|
|
||||||
return moment(time).format("HH") < 6 ? "凌晨" : moment(time).format("HH") < 12 ? "上午" : moment(time).format(
|
|
||||||
"HH") < 17.5 ? "下午" : moment(time).format("HH") < 19.5 ? "傍晚" : moment(time).format("HH") < 22 ? "晚上" :
|
|
||||||
"深夜";
|
|
||||||
}
|
|
||||||
async function getDailyNote(uid, cookie) {
|
async function getDailyNote(uid, cookie) {
|
||||||
let mysApi = (await import(`file://${_path}/lib/app/mysApi.js`))
|
let mysApi = (await import(`file://${_path}/lib/app/mysApi.js`))
|
||||||
let {
|
let {
|
||||||
|
@ -87,6 +87,7 @@ const send_Msg = function(e, type, name) {
|
|||||||
if (type == "all") {
|
if (type == "all") {
|
||||||
for (let [index, val] of list.entries()) {
|
for (let [index, val] of list.entries()) {
|
||||||
name = e.msg.replace(new RegExp(reglist[index], "g"), "");
|
name = e.msg.replace(new RegExp(reglist[index], "g"), "");
|
||||||
|
if(val.includes('juese_tujian')) continue;
|
||||||
let new_name = info_img(e, gsCfg.getfileYaml(`${_path}/plugins/xiaoyao-cvs-plugin/resources/Atlas_alias/`,
|
let new_name = info_img(e, gsCfg.getfileYaml(`${_path}/plugins/xiaoyao-cvs-plugin/resources/Atlas_alias/`,
|
||||||
val), name)
|
val), name)
|
||||||
if (new_name) {
|
if (new_name) {
|
||||||
|
242
model/note.js
242
model/note.js
@ -6,9 +6,15 @@ import {
|
|||||||
Data
|
Data
|
||||||
} from "../components/index.js";
|
} from "../components/index.js";
|
||||||
import moment from 'moment'
|
import moment from 'moment'
|
||||||
|
import Common from "../components/Common.js";
|
||||||
import gsCfg from './gsCfg.js'
|
import gsCfg from './gsCfg.js'
|
||||||
|
import {
|
||||||
|
isV3
|
||||||
|
} from '../components/Changelog.js'
|
||||||
const plugin = 'xiaoyao-cvs-plugin'
|
const plugin = 'xiaoyao-cvs-plugin'
|
||||||
|
const _path = process.cwd();
|
||||||
|
let path_url = ["dailyNote", "xiaoyao_Note"];
|
||||||
|
let path_img = ["background_image", "/icon/bg"];
|
||||||
/** 配置文件 */
|
/** 配置文件 */
|
||||||
export default class note {
|
export default class note {
|
||||||
constructor(e) {
|
constructor(e) {
|
||||||
@ -16,7 +22,9 @@ export default class note {
|
|||||||
this.e = e
|
this.e = e
|
||||||
}
|
}
|
||||||
this.Cfg = `./plugins/${plugin}/config/`
|
this.Cfg = `./plugins/${plugin}/config/`
|
||||||
|
this.role_user = Data.readJSON(`${_path}/plugins/xiaoyao-cvs-plugin/resources/dailyNote/json/`, "dispatch_time");
|
||||||
gsCfg.cpCfg("config", "note")
|
gsCfg.cpCfg("config", "note")
|
||||||
|
this.tempData = Data.readJSON(`./plugins/xiaoyao-cvs-plugin/data/NoteTemp`, "tempData")
|
||||||
this.noteCfg = gsCfg.getfileYaml(this.Cfg, "note") || {}
|
this.noteCfg = gsCfg.getfileYaml(this.Cfg, "note") || {}
|
||||||
this.cfg = gsCfg.getfileYaml(`./plugins/xiaoyao-cvs-plugin/config/`, "config");
|
this.cfg = gsCfg.getfileYaml(`./plugins/xiaoyao-cvs-plugin/config/`, "config");
|
||||||
}
|
}
|
||||||
@ -93,4 +101,236 @@ export default class note {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getNote(cookie, uid, res,{render}){
|
||||||
|
if (!res || res.retcode !== 0) return true
|
||||||
|
|
||||||
|
let data = res.data;
|
||||||
|
//推送任务
|
||||||
|
if (this.e.isTask && data.current_resin < this.e.sendResin) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (this.e.isTask) {
|
||||||
|
Bot.logger.mark(`体力推送:${this.e.user_id}`);
|
||||||
|
}
|
||||||
|
let nowDay = moment(new Date()).format("DD");
|
||||||
|
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 = moment(maxDate).format("HH:mm");
|
||||||
|
let Time_day = await this.dateTime_(maxDate)
|
||||||
|
resinMaxTime_mb2 = Time_day + moment(maxDate).format("hh:mm");
|
||||||
|
if (moment(maxDate).format("DD") != nowDay) {
|
||||||
|
resinMaxTime_mb2Day = `明天`;
|
||||||
|
resinMaxTime = `明天 ${resinMaxTime}`;
|
||||||
|
} else {
|
||||||
|
resinMaxTime_mb2Day = `今天`;
|
||||||
|
resinMaxTime = ` ${resinMaxTime}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (let val of data.expeditions) {
|
||||||
|
if (val.remained_time <= 0) {
|
||||||
|
val.percentage = 0;
|
||||||
|
}
|
||||||
|
if (val.remained_time > 0) {
|
||||||
|
val.dq_time = val.remained_time;
|
||||||
|
val.remained_time = new Date().getTime() + val.remained_time * 1000;
|
||||||
|
var urls_avatar_side = val.avatar_side_icon.split("_");
|
||||||
|
let Botcfg;
|
||||||
|
if (isV3) {
|
||||||
|
Botcfg = (await import(`file://${_path}/plugins/genshin/model/gsCfg.js`)).default;
|
||||||
|
} else {
|
||||||
|
Botcfg = YunzaiApps.mysInfo
|
||||||
|
}
|
||||||
|
let id = Botcfg.roleIdToName(urls_avatar_side[urls_avatar_side.length - 1].replace(
|
||||||
|
/(.png|.jpg)/g, ""));
|
||||||
|
let name = Botcfg.roleIdToName(id, true);
|
||||||
|
var time_cha = 20;
|
||||||
|
if (this.role_user["12"].includes(name)) {
|
||||||
|
time_cha = 15;
|
||||||
|
}
|
||||||
|
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 = moment(remainedDate).format("HH:mm");
|
||||||
|
let Time_day = await this.dateTime_(remainedDate)
|
||||||
|
if (moment(remainedDate).format("DD") != nowDay) {
|
||||||
|
val.remained_mb2 = "明天" + Time_day + moment(remainedDate).format("hh:mm");
|
||||||
|
val.remained_time = `明天 ${val.remained_time}`;
|
||||||
|
} else {
|
||||||
|
val.remained_mb2 = "今天" + Time_day + moment(remainedDate).format("hh:mm");
|
||||||
|
val.remained_time = ` ${val.remained_time}`;
|
||||||
|
}
|
||||||
|
val.mb2_icon = val.avatar_side_icon
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let remained_time = "";
|
||||||
|
if (data.expeditions && data.expeditions.length >= 1) {
|
||||||
|
remained_time = lodash.map(data.expeditions, "remained_time");
|
||||||
|
remained_time = lodash.min(remained_time);
|
||||||
|
if (remained_time > 0) {
|
||||||
|
remained_time = new Date().getTime() + remained_time * 1000;
|
||||||
|
let remainedDate = new Date(remained_time);
|
||||||
|
remained_time = moment(remainedDate).format("hh:mm");
|
||||||
|
if (moment(remainedDate).format("DD") != nowDay) {
|
||||||
|
remained_time = `明天 ${remained_time}`;
|
||||||
|
} else {
|
||||||
|
remained_time = ` ${remained_time}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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}分钟`;
|
||||||
|
let dayTime = (24 - moment(new Date()).format('HH') + moment(coinDate).diff(new Date(), 'hours')) / 24
|
||||||
|
coinTime_mb2Day = chnNumChar[dayTime.toFixed(0)] + "天";
|
||||||
|
let Time_day = await this.dateTime_(coinDate)
|
||||||
|
coinTime_mb2 = Time_day + moment(coinDate).format("hh:mm");
|
||||||
|
} else {
|
||||||
|
coinTime_mb2 = moment(coinDate).format("hh:mm");
|
||||||
|
if (moment(coinDate).format("DD") != nowDay) {
|
||||||
|
coinTime_mb2Day = "明天";
|
||||||
|
coinTime = `明天 ${ moment(coinDate).format("hh:mm")}`;
|
||||||
|
} else {
|
||||||
|
coinTime_mb2Day = "今天";
|
||||||
|
coinTime = moment(coinDate).format("hh:mm", coinDate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let day = moment(new Date()).format("MM-DD HH:mm");
|
||||||
|
let week = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];
|
||||||
|
day += " " + week[new Date().getDay()];
|
||||||
|
let day_mb2 = moment(new Date()).format("yyyy年MM月DD日 HH:mm") + " " + 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}天`;
|
||||||
|
}
|
||||||
|
if (data.transformer.recovery_time.Hour > 0) {
|
||||||
|
recovery_time += `${data.transformer.recovery_time.Hour}小时`;
|
||||||
|
}
|
||||||
|
if (data.transformer.recovery_time.Minute > 0) {
|
||||||
|
recovery_time += `${data.transformer.recovery_time.Minute}分钟`;
|
||||||
|
}
|
||||||
|
data.transformer.recovery_time = recovery_time;
|
||||||
|
}
|
||||||
|
let mb = Cfg.get("mb.len", 0) - 1;
|
||||||
|
if (mb < 0) {
|
||||||
|
mb = lodash.random(0, path_url.length - 1);
|
||||||
|
}
|
||||||
|
let urlType = this.note_file("xiaoyao");
|
||||||
|
let objFile = Object.keys(urlType)
|
||||||
|
if (objFile.length > 0) {
|
||||||
|
objFile = objFile[lodash.random(0, objFile.length - 1)]
|
||||||
|
}
|
||||||
|
let img_path = `./plugins/xiaoyao-cvs-plugin/resources/dailyNote/${path_img[mb]}`;
|
||||||
|
if (this.tempData[this.e.user_id] && this.tempData[this.e.user_id].type > -1&&this.tempData[this.e.user_id]?.temp?.length!==0) {
|
||||||
|
// mb = tempData[e.user_id].type;
|
||||||
|
if (typeof this.tempData[this.e.user_id]["temp"] === "string") {
|
||||||
|
objFile = this.tempData[this.e.user_id]["temp"]
|
||||||
|
} else {
|
||||||
|
objFile = this.tempData[this.e.user_id].temp[lodash.random(0, this.tempData[this.e.user_id].temp.length - 1)];
|
||||||
|
}
|
||||||
|
if (objFile.includes(".")) { //对于模板类型处理
|
||||||
|
mb = 0;
|
||||||
|
} else {
|
||||||
|
mb = 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (mb == 1) {
|
||||||
|
for (var i = 0; i < 5 - data.expeditions.length; i++) {
|
||||||
|
data.expeditions.push({
|
||||||
|
remained_time: 0,
|
||||||
|
remained_mb2: 0,
|
||||||
|
percentage: 0,
|
||||||
|
mb2_icon: ""
|
||||||
|
})
|
||||||
|
}
|
||||||
|
img_path = `${urlType[objFile]}${path_img[mb]}`;
|
||||||
|
}
|
||||||
|
var image = fs.readdirSync(img_path);
|
||||||
|
// console.log(fs.readdirSync(`./plugins/xiaoyao-cvs-plugin/resources/dailyNote/BJT-Templet/Template2`))
|
||||||
|
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)];
|
||||||
|
if (mb == 0 && objFile.includes(".")) {
|
||||||
|
imgs = objFile
|
||||||
|
}
|
||||||
|
return await Common.render(`dailyNote/${path_url[mb]}`, {
|
||||||
|
save_id: uid,
|
||||||
|
uid: uid,
|
||||||
|
coinTime_mb2Day,
|
||||||
|
coinTime_mb2,
|
||||||
|
urlType: encodeURIComponent(img_path.replace(
|
||||||
|
/(\.\/plugins\/xiaoyao-cvs-plugin\/resources\/|\/icon\/bg)/g, '')).replace(/%2F/g, "/"),
|
||||||
|
resinMaxTime_mb2Day,
|
||||||
|
resinMaxTime,
|
||||||
|
resinMaxTime_mb2,
|
||||||
|
remained_time,
|
||||||
|
coinTime,
|
||||||
|
imgs: encodeURIComponent(imgs),
|
||||||
|
day_mb2,
|
||||||
|
day,
|
||||||
|
...data,
|
||||||
|
}, {
|
||||||
|
e:this.e,
|
||||||
|
render,
|
||||||
|
scale: 1.2
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
async dateTime_(time) {
|
||||||
|
return moment(time).format("HH") < 6 ? "凌晨" : moment(time).format("HH") < 12 ? "上午" : moment(time).format(
|
||||||
|
"HH") < 17.5 ? "下午" : moment(time).format("HH") < 19.5 ? "傍晚" : moment(time).format("HH") < 22 ? "晚上" :
|
||||||
|
"深夜";
|
||||||
|
}
|
||||||
|
|
||||||
|
note_file(xiaoyao) {
|
||||||
|
let url1 = `./plugins/xiaoyao-cvs-plugin/resources/dailyNote/Template/`
|
||||||
|
let url2 = `./plugins/xiaoyao-cvs-plugin/resources/BJT-Templet/` //冤种情况。。
|
||||||
|
let url3 = `./plugins/xiaoyao-cvs-plugin/resources/dailyNote/background_image/`
|
||||||
|
var urlFile = fs.readdirSync(url1);
|
||||||
|
var urlType = {};
|
||||||
|
for (let val of urlFile) {
|
||||||
|
if (val.includes(".")) continue;
|
||||||
|
urlType[val] = url1 + val
|
||||||
|
}
|
||||||
|
if (fs.existsSync(url2)) {
|
||||||
|
var bJTurlFile = fs.readdirSync(url2);
|
||||||
|
for (let val of bJTurlFile) {
|
||||||
|
if (!val.includes("Template")) continue;
|
||||||
|
let file = fs.readdirSync(`${url2}${val}`);
|
||||||
|
for (let va of file) {
|
||||||
|
if (va.includes(".")) continue;
|
||||||
|
urlType[va] = url2 + val + "/" + va
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!xiaoyao) {
|
||||||
|
var urlFileOne = fs.readdirSync(url3);
|
||||||
|
for (let val of urlFileOne) {
|
||||||
|
if (!val.includes(".")) continue;
|
||||||
|
urlType[val] = url3 + val
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return urlType;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user