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