mirror of
https://github.com/ctrlcvs/xiaoyao-cvs-plugin.git
synced 2024-12-23 03:20:52 +08:00
1.0.7
This commit is contained in:
parent
83c235d25a
commit
11f198f708
@ -1,3 +1,9 @@
|
|||||||
|
#1.0.7
|
||||||
|
*新增`#体力模板2`指定模板
|
||||||
|
*可通过`#体力模板列表`获取你当前已有的模板
|
||||||
|
*通过`#体力模板设置(模板)`来指定你需要的模板
|
||||||
|
*修复时间区间问题
|
||||||
|
|
||||||
# 1.0.6
|
# 1.0.6
|
||||||
*兼容`体力模板2`可自定义css以及背景icon等
|
*兼容`体力模板2`可自定义css以及背景icon等
|
||||||
* 模板内容需要具体参考**/dailyNote/Template/temp**
|
* 模板内容需要具体参考**/dailyNote/Template/temp**
|
||||||
|
69
apps/Note.js
69
apps/Note.js
@ -8,9 +8,9 @@ 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 Data from "../components/Data.js"
|
|
||||||
import {
|
import {
|
||||||
Cfg
|
Cfg,
|
||||||
|
Data
|
||||||
} from "../components/index.js";
|
} from "../components/index.js";
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
// import MysApi from "../components/MysApi.js"
|
// import MysApi from "../components/MysApi.js"
|
||||||
@ -25,7 +25,14 @@ 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 tempData = {};
|
||||||
|
init()
|
||||||
|
function init() {
|
||||||
|
Data.createDir("",tempDataUrl ,false);
|
||||||
|
tempData=Data.readJSON(tempDataUrl,"tempData")
|
||||||
|
// console.log(tempData)
|
||||||
|
}
|
||||||
//#体力
|
//#体力
|
||||||
export async function Note(e, {
|
export async function Note(e, {
|
||||||
render
|
render
|
||||||
@ -220,17 +227,16 @@ 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 img_path=`./plugins/xiaoyao-cvs-plugin/resources/dailyNote/${path_img[mb]}`;
|
|
||||||
var urlFile = fs.readdirSync(`./plugins/xiaoyao-cvs-plugin/resources/dailyNote/Template/`);
|
let urlType = note_file();
|
||||||
var urlType = [];
|
|
||||||
for (let val of urlFile) {
|
|
||||||
if (val.includes(".")) continue;
|
|
||||||
urlType.push(val)
|
|
||||||
}
|
|
||||||
// console.log(urlType)
|
|
||||||
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]}`;
|
||||||
|
if(tempData[e.user_id]){
|
||||||
|
mb=tempData[e.user_id].type;
|
||||||
|
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++) {
|
||||||
data.expeditions.push({
|
data.expeditions.push({
|
||||||
@ -240,7 +246,7 @@ export async function Note(e, {
|
|||||||
mb2_icon: ""
|
mb2_icon: ""
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
img_path=`./plugins/xiaoyao-cvs-plugin/resources/dailyNote/Template/${urlType}${path_img[mb]}`;
|
img_path = `./plugins/xiaoyao-cvs-plugin/resources/dailyNote/Template/${urlType}${path_img[mb]}`;
|
||||||
}
|
}
|
||||||
var image = fs.readdirSync(img_path);
|
var image = fs.readdirSync(img_path);
|
||||||
var list_img = [];
|
var list_img = [];
|
||||||
@ -273,7 +279,9 @@ export async function Note(e, {
|
|||||||
|
|
||||||
async function dateTime_(time) {
|
async function dateTime_(time) {
|
||||||
return format("hh", time) < 6 ? "凌晨" : format("hh", time) < 12 ? "上午" : format("hh",
|
return format("hh", time) < 6 ? "凌晨" : format("hh", time) < 12 ? "上午" : format("hh",
|
||||||
time) < 16 ? "下午" : "傍晚";
|
time) < 17.5 ? "下午" : format("hh",
|
||||||
|
time) < 19.5 ? "傍晚" : format("hh",
|
||||||
|
time) < 22 ? "晚上" : "深夜";
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getDailyNote(uid, cookie) {
|
async function getDailyNote(uid, cookie) {
|
||||||
@ -283,9 +291,7 @@ async function getDailyNote(uid, cookie) {
|
|||||||
query,
|
query,
|
||||||
body
|
body
|
||||||
} = getUrl("dailyNote", uid);
|
} = getUrl("dailyNote", uid);
|
||||||
|
|
||||||
headers.Cookie = cookie;
|
headers.Cookie = cookie;
|
||||||
|
|
||||||
const response = await fetch(url, {
|
const response = await fetch(url, {
|
||||||
method: "get",
|
method: "get",
|
||||||
headers
|
headers
|
||||||
@ -330,19 +336,46 @@ export async function DailyNoteTask() {
|
|||||||
e.reply = (msg) => {
|
e.reply = (msg) => {
|
||||||
common.relpyPrivate(user_id, msg);
|
common.relpyPrivate(user_id, msg);
|
||||||
};
|
};
|
||||||
|
|
||||||
//判断今天是否推送
|
//判断今天是否推送
|
||||||
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, {
|
||||||
render
|
render
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export async function Note_appoint(e) {
|
||||||
|
let msg = e.msg.replace(/#|井|体力|模板|设置/g, "");
|
||||||
|
let urlType = note_file();
|
||||||
|
let type = 0;
|
||||||
|
if (msg.includes("列表")) {
|
||||||
|
e.reply(`当前支持选择的模板有:\n${urlType.join("\n")}`);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (!urlType.includes(msg)) {
|
||||||
|
e.reply("没有找到你想要的模板昵!可输入 【#体力模板列表】 查询当前支持的模板哦~~")
|
||||||
|
return true;
|
||||||
|
} else type = 1;
|
||||||
|
tempData[e.user_id]={temp: msg,type: type,}
|
||||||
|
fs.writeFileSync(tempDataUrl+"/tempData.json",JSON.stringify(tempData));
|
||||||
|
init()
|
||||||
|
e.reply("诶~这是你选的模板吗,模板设置成功了快用指令来试试吧~!")
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
const note_file = function() {
|
||||||
|
var urlFile = fs.readdirSync(`./plugins/xiaoyao-cvs-plugin/resources/dailyNote/Template/`);
|
||||||
|
var urlType = [];
|
||||||
|
for (let val of urlFile) {
|
||||||
|
if (val.includes(".")) continue;
|
||||||
|
urlType.push(val)
|
||||||
|
}
|
||||||
|
return urlType;
|
||||||
|
}
|
||||||
|
@ -42,11 +42,11 @@ let Data = {
|
|||||||
/*
|
/*
|
||||||
* 写JSON
|
* 写JSON
|
||||||
* */
|
* */
|
||||||
writeJson(path, file, data, space = "\t") {
|
writeJson(root,path, file, data, space = "\t") {
|
||||||
if (!/\.json$/.test(file)) {
|
if (!/\.json$/.test(file)) {
|
||||||
file = file + ".json";
|
file = file + ".json";
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查并创建目录
|
// 检查并创建目录
|
||||||
Data.createDir(path, true);
|
Data.createDir(path, true);
|
||||||
return fs.writeFileSync(`${path}/${file}`, JSON.stringify(data, null, space));
|
return fs.writeFileSync(`${path}/${file}`, JSON.stringify(data, null, space));
|
||||||
|
8
index.js
8
index.js
@ -9,7 +9,8 @@ import {
|
|||||||
|
|
||||||
import common from "../../lib/common.js";
|
import common from "../../lib/common.js";
|
||||||
import {
|
import {
|
||||||
Note
|
Note,
|
||||||
|
Note_appoint
|
||||||
} from "./apps/Note.js"
|
} from "./apps/Note.js"
|
||||||
import {
|
import {
|
||||||
rule as adminRule,
|
rule as adminRule,
|
||||||
@ -24,6 +25,7 @@ export {
|
|||||||
updateRes,
|
updateRes,
|
||||||
updateMiaoPlugin,
|
updateMiaoPlugin,
|
||||||
versionInfo,
|
versionInfo,
|
||||||
|
Note_appoint,
|
||||||
sysCfg,
|
sysCfg,
|
||||||
help,
|
help,
|
||||||
AtlasAlias,
|
AtlasAlias,
|
||||||
@ -47,6 +49,10 @@ let rule = {
|
|||||||
reg: "^#*(体力|树脂|查询体力|便笺|便签)$",
|
reg: "^#*(体力|树脂|查询体力|便笺|便签)$",
|
||||||
describe: "体力",
|
describe: "体力",
|
||||||
},
|
},
|
||||||
|
Note_appoint: {
|
||||||
|
reg: "^#体力模板(设置(.*)|列表)$",
|
||||||
|
describe: "体力模板设置",
|
||||||
|
},
|
||||||
...adminRule
|
...adminRule
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user