mirror of
https://github.com/ctrlcvs/xiaoyao-cvs-plugin.git
synced 2024-12-23 03:20:52 +08:00
新增体力推送方法以及体力模板设置随机
This commit is contained in:
parent
11f198f708
commit
d4e1258e8f
@ -1,7 +1,11 @@
|
||||
#1.0.7
|
||||
*新增`体力推送方法`
|
||||
*可通过修改init.js方法调用实现新版体力推送
|
||||
*具体将**YunzaiApps.dailyNote.DailyNoteTask()**方法改为**YunzaiApps["plugin_xiaoyao-cvs-plugin"].DailyNoteTask()**
|
||||
*新增`#体力模板2`指定模板
|
||||
*可通过`#体力模板列表`获取你当前已有的模板
|
||||
*通过`#体力模板设置(模板)`来指定你需要的模板
|
||||
*可以通过`#体力模板设置随机`来恢复之前的状态
|
||||
*修复时间区间问题
|
||||
|
||||
# 1.0.6
|
||||
|
35
apps/Note.js
35
apps/Note.js
@ -8,6 +8,7 @@ import format from "date-format";
|
||||
import puppeteer from "puppeteer";
|
||||
import common from "../../../lib/common.js";
|
||||
import lodash from "lodash";
|
||||
import { getPluginRender } from "../../../lib/render.js"
|
||||
import {
|
||||
Cfg,
|
||||
Data
|
||||
@ -25,12 +26,13 @@ let role_user = Data.readJSON(`${_path}/plugins/xiaoyao-cvs-plugin/resources/dai
|
||||
|
||||
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 = {};
|
||||
init()
|
||||
|
||||
function init() {
|
||||
Data.createDir("",tempDataUrl ,false);
|
||||
tempData=Data.readJSON(tempDataUrl,"tempData")
|
||||
Data.createDir("", tempDataUrl, false);
|
||||
tempData = Data.readJSON(tempDataUrl, "tempData")
|
||||
// console.log(tempData)
|
||||
}
|
||||
//#体力
|
||||
@ -233,9 +235,9 @@ export async function Note(e, {
|
||||
urlType = urlType[lodash.random(0, urlType.length - 1)]
|
||||
}
|
||||
let img_path = `./plugins/xiaoyao-cvs-plugin/resources/dailyNote/${path_img[mb]}`;
|
||||
if(tempData[e.user_id]){
|
||||
mb=tempData[e.user_id].type;
|
||||
urlType=tempData[e.user_id].temp;
|
||||
if (tempData[e.user_id] && tempData[e.user_id].type > 0) {
|
||||
mb = tempData[e.user_id].type;
|
||||
urlType = tempData[e.user_id].temp;
|
||||
}
|
||||
if (mb == 1) {
|
||||
for (var i = 0; i < 5 - data.expeditions.length; i++) {
|
||||
@ -308,10 +310,9 @@ export async function saveJson() {
|
||||
//体力定时推送
|
||||
export async function DailyNoteTask() {
|
||||
//体力大于多少时推送
|
||||
let sendResin = 120;
|
||||
let sendResin = 10;
|
||||
//推送cd,12小时一次
|
||||
let sendCD = 12 * 3600;
|
||||
|
||||
//获取需要推送的用户
|
||||
for (let [user_id, cookie] of Object.entries(NoteCookie)) {
|
||||
user_id = cookie.qq || user_id;
|
||||
@ -339,13 +340,11 @@ export async function DailyNoteTask() {
|
||||
//判断今天是否推送
|
||||
if (cookie.maxTime && cookie.maxTime > 0 && new Date().getTime() > cookie.maxTime - (160 - sendResin) * 8 *
|
||||
60 * 1000) {
|
||||
//Bot.logger.mark(`体力推送:${user_id}`);
|
||||
Bot.logger.mark(`体力推送:${user_id}`);
|
||||
redis.set(sendkey, "1", {
|
||||
EX: sendCD
|
||||
});
|
||||
await Note(e, {
|
||||
render
|
||||
});
|
||||
await Note(e, getPluginRender("xiaoyao-cvs-plugin"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -353,18 +352,24 @@ export async function DailyNoteTask() {
|
||||
|
||||
export async function Note_appoint(e) {
|
||||
let msg = e.msg.replace(/#|井|体力|模板|设置/g, "");
|
||||
let All = ["默认", "随机", "0"];
|
||||
let urlType = note_file();
|
||||
let type = 0;
|
||||
if (msg.includes("列表")) {
|
||||
e.reply(`当前支持选择的模板有:\n${urlType.join("\n")}`);
|
||||
return true;
|
||||
}
|
||||
if (!urlType.includes(msg)) {
|
||||
if (!urlType.includes(msg) && !All.includes(msg)) {
|
||||
e.reply("没有找到你想要的模板昵!可输入 【#体力模板列表】 查询当前支持的模板哦~~")
|
||||
return true;
|
||||
} else if (All.includes(msg)) {
|
||||
type = -1;
|
||||
} else type = 1;
|
||||
tempData[e.user_id]={temp: msg,type: type,}
|
||||
fs.writeFileSync(tempDataUrl+"/tempData.json",JSON.stringify(tempData));
|
||||
tempData[e.user_id] = {
|
||||
temp: msg,
|
||||
type: type,
|
||||
}
|
||||
fs.writeFileSync(tempDataUrl + "/tempData.json", JSON.stringify(tempData));
|
||||
init()
|
||||
e.reply("诶~这是你选的模板吗,模板设置成功了快用指令来试试吧~!")
|
||||
return true;
|
||||
|
4
index.js
4
index.js
@ -9,7 +9,7 @@ import {
|
||||
|
||||
import common from "../../lib/common.js";
|
||||
import {
|
||||
Note,
|
||||
Note,DailyNoteTask,
|
||||
Note_appoint
|
||||
} from "./apps/Note.js"
|
||||
import {
|
||||
@ -27,7 +27,7 @@ export {
|
||||
versionInfo,
|
||||
Note_appoint,
|
||||
sysCfg,
|
||||
help,
|
||||
help,DailyNoteTask,
|
||||
AtlasAlias,
|
||||
Note
|
||||
};
|
||||
|
@ -196,7 +196,7 @@
|
||||
"四星圣遗物图鉴|四星遗物图鉴": ["#勇士之心图鉴", "#教官图鉴", "#流放者图鉴", "#祭冰之人图鉴", "#祭雷之人图鉴", "#祭火之人图鉴", "#祭水之人图鉴", "#战狂图鉴", "#武人图鉴",
|
||||
"#学士图鉴", "#赌徒图鉴", "#奇迹图鉴", "#行者之心图鉴", "#守护之心图鉴", "#幸运儿图鉴", "#冒险家图鉴", "#游医图鉴"
|
||||
],
|
||||
"食物图鉴|料理图鉴": ["#回复类食物图鉴", "#复活类食物图鉴", "#体力类食物图鉴", "#攻击类食物图鉴", "#防御类食物图鉴", "#暴击类食物图鉴", "#生命上限食物图鉴", "#治疗加成类食物图鉴",
|
||||
"食物图鉴|料理图鉴|食谱图鉴": ["#回复类食物图鉴", "#复活类食物图鉴", "#体力类食物图鉴", "#攻击类食物图鉴", "#防御类食物图鉴", "#暴击类食物图鉴", "#生命上限食物图鉴", "#治疗加成类食物图鉴",
|
||||
"#应急食品图鉴"
|
||||
],
|
||||
"回复类食物图鉴|回复类料理图鉴": ["#树莓水馒头图鉴", "#荞麦面图鉴", "#鸟蛋寿司图鉴", "#日落鲷鱼烧图鉴", "#蒲烧鳗肉图鉴", "#活力喵饭图鉴", "#干烧香鱼图鉴", "#金枪鱼寿司图鉴",
|
||||
|
Loading…
Reference in New Issue
Block a user