2022-06-23 22:30:41 +08:00
|
|
|
|
import {
|
|
|
|
|
segment
|
|
|
|
|
} from "oicq";
|
|
|
|
|
import fetch from "node-fetch";
|
|
|
|
|
import Common from "../components/Common.js";
|
|
|
|
|
import fs from "fs";
|
2022-08-03 21:25:29 +08:00
|
|
|
|
import {
|
|
|
|
|
isV3
|
|
|
|
|
} from '../components/Changelog.js'
|
2022-06-23 22:30:41 +08:00
|
|
|
|
import lodash from "lodash";
|
2022-07-24 11:46:05 +08:00
|
|
|
|
import gsCfg from '../model/gsCfg.js'
|
2022-06-23 23:06:30 +08:00
|
|
|
|
import {
|
2022-07-04 23:32:26 +08:00
|
|
|
|
Cfg,
|
|
|
|
|
Data
|
2022-06-23 23:06:30 +08:00
|
|
|
|
} from "../components/index.js";
|
2022-06-28 23:21:06 +08:00
|
|
|
|
import moment from 'moment';
|
2022-09-09 10:03:17 +08:00
|
|
|
|
import utils from "../model/mys/utils.js";
|
2022-06-23 22:30:41 +08:00
|
|
|
|
const _path = process.cwd();
|
2022-06-28 23:21:06 +08:00
|
|
|
|
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"];
|
2022-07-05 23:12:47 +08:00
|
|
|
|
let tempDataUrl = `${_path}/plugins/xiaoyao-cvs-plugin/data/NoteTemp`
|
2022-07-04 23:32:26 +08:00
|
|
|
|
let tempData = {};
|
|
|
|
|
init()
|
2022-08-03 21:25:29 +08:00
|
|
|
|
|
2022-07-04 23:32:26 +08:00
|
|
|
|
function init() {
|
2022-07-05 23:12:47 +08:00
|
|
|
|
Data.createDir("", tempDataUrl, false);
|
|
|
|
|
tempData = Data.readJSON(tempDataUrl, "tempData")
|
2022-07-04 23:32:26 +08:00
|
|
|
|
}
|
2022-06-23 22:30:41 +08:00
|
|
|
|
//#体力
|
|
|
|
|
export async function Note(e, {
|
|
|
|
|
render
|
2022-08-03 21:25:29 +08:00
|
|
|
|
}, poke) {
|
|
|
|
|
if (!Cfg.get("sys.Note") && !poke) {
|
2022-06-23 23:06:30 +08:00
|
|
|
|
return false;
|
|
|
|
|
}
|
2022-08-03 21:25:29 +08:00
|
|
|
|
let cookie, uid, res;
|
|
|
|
|
if (isV3) {
|
2022-10-12 16:51:51 +08:00
|
|
|
|
let MysInfo = await import(`file://${_path}/plugins/genshin/model/mys/mysInfo.js`);
|
2022-08-07 00:20:05 +08:00
|
|
|
|
res = await MysInfo.default.get(e, 'dailyNote')
|
2022-07-24 12:12:39 +08:00
|
|
|
|
if (!res || res.retcode !== 0) return true
|
2022-08-03 21:25:29 +08:00
|
|
|
|
uid = e.uid;
|
|
|
|
|
} else {
|
2022-07-24 11:46:05 +08:00
|
|
|
|
if (NoteCookie[e.user_id]) {
|
|
|
|
|
cookie = NoteCookie[e.user_id].cookie;
|
|
|
|
|
uid = NoteCookie[e.user_id].uid;
|
|
|
|
|
} else if (BotConfig.dailyNote && BotConfig.dailyNote[e.user_id]) {
|
|
|
|
|
cookie = BotConfig.dailyNote[e.user_id].cookie;
|
|
|
|
|
uid = BotConfig.dailyNote[e.user_id].uid;
|
2022-06-23 22:30:41 +08:00
|
|
|
|
} else {
|
2022-07-24 11:46:05 +08:00
|
|
|
|
e.reply(`尚未配置,无法查询体力\n配置教程:${BotConfig.cookieDoc}`);
|
|
|
|
|
return true;
|
2022-06-23 22:30:41 +08:00
|
|
|
|
}
|
2022-07-24 11:46:05 +08:00
|
|
|
|
const response = await getDailyNote(uid, cookie);
|
|
|
|
|
if (!response.ok) {
|
|
|
|
|
e.reply("米游社接口错误");
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
res = await response.json();
|
|
|
|
|
if (res.retcode == 10102) {
|
|
|
|
|
if (!e.openDailyNote) {
|
|
|
|
|
e.openDailyNote = true;
|
|
|
|
|
await openDailyNote(cookie); //自动开启
|
|
|
|
|
dailyNote(e);
|
|
|
|
|
} else {
|
|
|
|
|
e.reply("请先开启实时便笺数据展示");
|
2022-06-23 22:30:41 +08:00
|
|
|
|
}
|
2022-07-24 11:46:05 +08:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
if (res.retcode != 0) {
|
|
|
|
|
if (res.message == "Please login") {
|
|
|
|
|
Bot.logger.mark(`体力cookie已失效`);
|
|
|
|
|
e.reply(`体力cookie已失效,请重新配置\n注意:退出米游社登录cookie将会失效!`);
|
|
|
|
|
if (NoteCookie[e.user_id]) {
|
|
|
|
|
// await MysUser.delNote(NoteCookie[e.user_id]);
|
|
|
|
|
delete NoteCookie[e.user_id];
|
|
|
|
|
saveJson();
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
e.reply(`体力查询错误:${res.message}`);
|
|
|
|
|
Bot.logger.mark(`体力查询错误:${JSON.stringify(res)}`);
|
|
|
|
|
}
|
2022-08-03 21:25:29 +08:00
|
|
|
|
|
2022-07-24 11:46:05 +08:00
|
|
|
|
return true;
|
|
|
|
|
}
|
2022-08-03 21:25:29 +08:00
|
|
|
|
|
2022-07-24 11:46:05 +08:00
|
|
|
|
//redis保存uid
|
|
|
|
|
redis.set(`genshin:uid:${e.user_id}`, uid, {
|
|
|
|
|
EX: 2592000
|
|
|
|
|
});
|
2022-08-03 21:25:29 +08:00
|
|
|
|
|
2022-07-24 11:46:05 +08:00
|
|
|
|
//更新
|
|
|
|
|
if (NoteCookie[e.user_id]) {
|
|
|
|
|
NoteCookie[e.user_id].maxTime = new Date().getTime() + res.data.resin_recovery_time * 1000;
|
|
|
|
|
saveJson();
|
2022-06-23 22:30:41 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
let data = res.data;
|
|
|
|
|
//推送任务
|
|
|
|
|
if (e.isTask && data.current_resin < e.sendResin) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (e.isTask) {
|
|
|
|
|
Bot.logger.mark(`体力推送:${e.user_id}`);
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-25 19:19:39 +08:00
|
|
|
|
let nowDay = moment(new Date()).format("DD");
|
2022-06-23 22:30:41 +08:00
|
|
|
|
let resinMaxTime;
|
2022-06-28 23:21:06 +08:00
|
|
|
|
let resinMaxTime_mb2;
|
|
|
|
|
let resinMaxTime_mb2Day;
|
2022-06-23 22:30:41 +08:00
|
|
|
|
if (data.resin_recovery_time > 0) {
|
|
|
|
|
resinMaxTime = new Date().getTime() + data.resin_recovery_time * 1000;
|
|
|
|
|
let maxDate = new Date(resinMaxTime);
|
2022-08-03 21:25:29 +08:00
|
|
|
|
resinMaxTime = moment(maxDate).format("HH:mm");
|
2022-06-28 23:21:06 +08:00
|
|
|
|
let Time_day = await dateTime_(maxDate)
|
|
|
|
|
resinMaxTime_mb2 = Time_day + moment(maxDate).format("hh:mm");
|
2022-07-25 19:19:39 +08:00
|
|
|
|
if (moment(maxDate).format("DD") != nowDay) {
|
2022-06-28 23:21:06 +08:00
|
|
|
|
resinMaxTime_mb2Day = `明天`;
|
2022-06-23 22:30:41 +08:00
|
|
|
|
resinMaxTime = `明天 ${resinMaxTime}`;
|
|
|
|
|
} else {
|
2022-06-28 23:21:06 +08:00
|
|
|
|
resinMaxTime_mb2Day = `今天`;
|
2022-06-23 22:30:41 +08:00
|
|
|
|
resinMaxTime = ` ${resinMaxTime}`;
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-06-24 22:01:48 +08:00
|
|
|
|
for (let val of data.expeditions) {
|
2022-06-29 06:51:06 +08:00
|
|
|
|
if (val.remained_time <= 0) {
|
2022-06-30 10:06:51 +08:00
|
|
|
|
val.percentage = 0;
|
2022-06-28 23:53:58 +08:00
|
|
|
|
}
|
2022-06-25 10:02:49 +08:00
|
|
|
|
if (val.remained_time > 0) {
|
2022-06-28 23:21:06 +08:00
|
|
|
|
val.dq_time = val.remained_time;
|
2022-06-25 10:02:49 +08:00
|
|
|
|
val.remained_time = new Date().getTime() + val.remained_time * 1000;
|
2022-06-28 23:21:06 +08:00
|
|
|
|
var urls_avatar_side = val.avatar_side_icon.split("_");
|
2022-08-13 23:42:34 +08:00
|
|
|
|
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(
|
2022-06-28 23:21:06 +08:00
|
|
|
|
/(.png|.jpg)/g, ""));
|
2022-08-13 23:42:34 +08:00
|
|
|
|
let name = Botcfg.roleIdToName(id, true);
|
2022-06-28 23:21:06 +08:00
|
|
|
|
var time_cha = 20;
|
|
|
|
|
if (role_user["12"].includes(name)) {
|
2022-06-29 06:51:06 +08:00
|
|
|
|
time_cha = 15;
|
2022-06-28 23:21:06 +08:00
|
|
|
|
}
|
|
|
|
|
val.percentage = ((val.dq_time / 60 / 60 * 1 / time_cha) * 100 / 10).toFixed(0) * 10;
|
2022-06-25 10:02:49 +08:00
|
|
|
|
let remainedDate = new Date(val.remained_time);
|
2022-07-28 20:44:26 +08:00
|
|
|
|
val.remained_time = moment(remainedDate).format("HH:mm");
|
2022-06-28 23:21:06 +08:00
|
|
|
|
let Time_day = await dateTime_(remainedDate)
|
2022-07-25 19:19:39 +08:00
|
|
|
|
if (moment(remainedDate).format("DD") != nowDay) {
|
2022-06-29 06:51:06 +08:00
|
|
|
|
val.remained_mb2 = "明天" + Time_day + moment(remainedDate).format("hh:mm");
|
2022-06-25 10:02:49 +08:00
|
|
|
|
val.remained_time = `明天 ${val.remained_time}`;
|
|
|
|
|
} else {
|
2022-06-29 06:51:06 +08:00
|
|
|
|
val.remained_mb2 = "今天" + Time_day + moment(remainedDate).format("hh:mm");
|
2022-06-25 10:02:49 +08:00
|
|
|
|
val.remained_time = ` ${val.remained_time}`;
|
|
|
|
|
}
|
2022-07-03 12:45:09 +08:00
|
|
|
|
val.mb2_icon = val.avatar_side_icon
|
2022-06-24 22:01:48 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2022-07-03 12:45:09 +08:00
|
|
|
|
|
|
|
|
|
|
2022-06-23 22:30:41 +08:00
|
|
|
|
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);
|
2022-07-25 19:19:39 +08:00
|
|
|
|
remained_time = moment(remainedDate).format("hh:mm");
|
|
|
|
|
if (moment(remainedDate).format("DD") != nowDay) {
|
2022-06-23 22:30:41 +08:00
|
|
|
|
remained_time = `明天 ${remained_time}`;
|
|
|
|
|
} else {
|
|
|
|
|
remained_time = ` ${remained_time}`;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-28 23:21:06 +08:00
|
|
|
|
let coinTime_mb2 = "";
|
|
|
|
|
let coinTime_mb2Day = "";
|
2022-06-23 22:30:41 +08:00
|
|
|
|
let coinTime = "";
|
2022-06-29 22:11:12 +08:00
|
|
|
|
var chnNumChar = ["零", "明", "后", "三", "四", "五", "六", "七", "八", "九"];
|
2022-06-23 22:30:41 +08:00
|
|
|
|
if (data.home_coin_recovery_time > 0) {
|
2022-06-28 23:21:06 +08:00
|
|
|
|
let coinDate = new Date(new Date().getTime() + data.home_coin_recovery_time * 1000);
|
2022-06-23 22:30:41 +08:00
|
|
|
|
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}分钟`;
|
2022-06-28 23:21:06 +08:00
|
|
|
|
coinTime_mb2Day = chnNumChar[coinDay * 1] + "天";
|
|
|
|
|
let Time_day = await dateTime_(coinDate)
|
|
|
|
|
coinTime_mb2 = Time_day + moment(coinDate).format("hh:mm");
|
2022-06-23 22:30:41 +08:00
|
|
|
|
} else {
|
2022-06-28 23:21:06 +08:00
|
|
|
|
coinTime_mb2 = moment(coinDate).format("hh:mm");
|
2022-08-03 21:25:29 +08:00
|
|
|
|
if (moment(coinDate).format("DD") != nowDay) {
|
2022-06-28 23:21:06 +08:00
|
|
|
|
coinTime_mb2Day = "明天";
|
2022-07-25 19:19:39 +08:00
|
|
|
|
coinTime = `明天 ${ moment(coinDate).format("hh:mm")}`;
|
2022-06-23 22:30:41 +08:00
|
|
|
|
} else {
|
2022-06-28 23:21:06 +08:00
|
|
|
|
coinTime_mb2Day = "今天";
|
2022-07-25 19:19:39 +08:00
|
|
|
|
coinTime = moment(coinDate).format("hh:mm", coinDate);
|
2022-06-23 22:30:41 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-03 21:25:29 +08:00
|
|
|
|
let day = moment(new Date()).format("MM-DD HH:mm");
|
2022-06-23 22:30:41 +08:00
|
|
|
|
let week = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];
|
|
|
|
|
day += " " + week[new Date().getDay()];
|
2022-08-03 21:25:29 +08:00
|
|
|
|
let day_mb2 = moment(new Date()).format("yyyy年MM月DD日 HH:mm") + " " + week[new Date().getDay()];
|
2022-06-23 22:30:41 +08:00
|
|
|
|
//参量质变仪
|
|
|
|
|
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;
|
|
|
|
|
}
|
2022-06-29 06:51:06 +08:00
|
|
|
|
let mb = Cfg.get("mb.len", 0) - 1;
|
|
|
|
|
if (mb < 0) {
|
|
|
|
|
mb = lodash.random(0, path_url.length - 1);
|
2022-06-28 23:21:06 +08:00
|
|
|
|
}
|
2022-07-05 23:12:47 +08:00
|
|
|
|
|
2022-08-03 22:56:01 +08:00
|
|
|
|
let urlType = note_file("xiaoyao");
|
2022-07-03 12:45:09 +08:00
|
|
|
|
if (urlType.length > 0) {
|
|
|
|
|
urlType = urlType[lodash.random(0, urlType.length - 1)]
|
|
|
|
|
}
|
2022-07-04 23:32:26 +08:00
|
|
|
|
let img_path = `./plugins/xiaoyao-cvs-plugin/resources/dailyNote/${path_img[mb]}`;
|
2022-08-03 21:25:29 +08:00
|
|
|
|
if (tempData[e.user_id] && tempData[e.user_id].type > -1) {
|
2022-07-05 23:12:47 +08:00
|
|
|
|
mb = tempData[e.user_id].type;
|
|
|
|
|
urlType = tempData[e.user_id].temp;
|
2022-07-04 23:32:26 +08:00
|
|
|
|
}
|
2022-07-03 16:00:37 +08:00
|
|
|
|
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: ""
|
|
|
|
|
})
|
|
|
|
|
}
|
2022-07-04 23:32:26 +08:00
|
|
|
|
img_path = `./plugins/xiaoyao-cvs-plugin/resources/dailyNote/Template/${urlType}${path_img[mb]}`;
|
2022-07-03 16:00:37 +08:00
|
|
|
|
}
|
|
|
|
|
var image = fs.readdirSync(img_path);
|
2022-06-24 22:01:48 +08:00
|
|
|
|
var list_img = [];
|
2022-06-23 22:30:41 +08:00
|
|
|
|
for (let val of image) {
|
|
|
|
|
list_img.push(val)
|
|
|
|
|
}
|
2022-06-25 10:02:49 +08:00
|
|
|
|
var imgs = list_img.length == 1 ? list_img[0] : list_img[lodash.random(0, list_img.length - 1)];
|
2022-08-03 21:25:29 +08:00
|
|
|
|
if (mb == 0 && urlType.includes(".")) {
|
|
|
|
|
imgs = urlType
|
|
|
|
|
}
|
2022-06-28 23:21:06 +08:00
|
|
|
|
return await Common.render(`dailyNote/${path_url[mb]}`, {
|
2022-06-23 22:30:41 +08:00
|
|
|
|
save_id: uid,
|
|
|
|
|
uid: uid,
|
2022-06-28 23:21:06 +08:00
|
|
|
|
coinTime_mb2Day,
|
|
|
|
|
coinTime_mb2,
|
2022-10-12 16:51:51 +08:00
|
|
|
|
urlType: encodeURIComponent(urlType),
|
2022-06-28 23:21:06 +08:00
|
|
|
|
resinMaxTime_mb2Day,
|
2022-06-23 22:30:41 +08:00
|
|
|
|
resinMaxTime,
|
2022-06-28 23:21:06 +08:00
|
|
|
|
resinMaxTime_mb2,
|
2022-06-23 22:30:41 +08:00
|
|
|
|
remained_time,
|
|
|
|
|
coinTime,
|
2022-10-12 16:51:51 +08:00
|
|
|
|
imgs: encodeURIComponent(imgs),
|
2022-06-28 23:21:06 +08:00
|
|
|
|
day_mb2,
|
2022-06-23 22:30:41 +08:00
|
|
|
|
day,
|
|
|
|
|
...data,
|
|
|
|
|
}, {
|
|
|
|
|
e,
|
|
|
|
|
render,
|
|
|
|
|
scale: 1.2
|
|
|
|
|
})
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-28 23:21:06 +08:00
|
|
|
|
async function dateTime_(time) {
|
2022-08-03 21:25:29 +08:00
|
|
|
|
return moment(time).format("HH") < 6 ? "凌晨" : moment(time).format("HH") < 12 ? "上午" : moment(time).format(
|
2022-10-12 16:51:51 +08:00
|
|
|
|
"HH") < 17.5 ? "下午" : moment(time).format("HH") < 19.5 ? "傍晚" : moment(time).format("HH") < 22 ? "晚上" :
|
2022-08-03 21:25:29 +08:00
|
|
|
|
"深夜";
|
2022-06-28 23:21:06 +08:00
|
|
|
|
}
|
2022-06-23 22:30:41 +08:00
|
|
|
|
async function getDailyNote(uid, cookie) {
|
2022-10-12 21:16:44 +08:00
|
|
|
|
let mysApi = (await import(`file://${_path}/lib/app/mysApi.js`))
|
2022-06-23 22:30:41 +08:00
|
|
|
|
let {
|
|
|
|
|
url,
|
|
|
|
|
headers,
|
|
|
|
|
query,
|
|
|
|
|
body
|
2022-07-24 11:46:05 +08:00
|
|
|
|
} = mysApi.getUrl("dailyNote", uid);
|
2022-06-23 22:30:41 +08:00
|
|
|
|
headers.Cookie = cookie;
|
|
|
|
|
const response = await fetch(url, {
|
2022-10-12 21:16:44 +08:00
|
|
|
|
method: "get", headers
|
2022-06-23 22:30:41 +08:00
|
|
|
|
});
|
|
|
|
|
return response;
|
|
|
|
|
}
|
|
|
|
|
export async function saveJson() {
|
|
|
|
|
let path = "data/NoteCookie/NoteCookie.json";
|
|
|
|
|
fs.writeFileSync(path, JSON.stringify(NoteCookie, "", "\t"));
|
|
|
|
|
}
|
2022-06-28 23:21:06 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//体力定时推送
|
|
|
|
|
export async function DailyNoteTask() {
|
|
|
|
|
//体力大于多少时推送
|
2022-07-15 23:34:47 +08:00
|
|
|
|
let sendResin = 120;
|
2022-06-28 23:21:06 +08:00
|
|
|
|
//推送cd,12小时一次
|
|
|
|
|
let sendCD = 12 * 3600;
|
2022-10-12 16:51:51 +08:00
|
|
|
|
if (isV3) {
|
2022-08-04 23:13:05 +08:00
|
|
|
|
return true;
|
|
|
|
|
}
|
2022-06-28 23:21:06 +08:00
|
|
|
|
//获取需要推送的用户
|
|
|
|
|
for (let [user_id, cookie] of Object.entries(NoteCookie)) {
|
|
|
|
|
user_id = cookie.qq || user_id;
|
|
|
|
|
//没有开启推送
|
|
|
|
|
if (!cookie.isPush) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2022-08-03 21:25:29 +08:00
|
|
|
|
|
2022-06-28 23:21:06 +08:00
|
|
|
|
//今天已经提醒
|
|
|
|
|
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) => {
|
2022-08-03 21:25:29 +08:00
|
|
|
|
Bot.pickUser(user_id * 1).sendMsg(msg).catch((err) => {
|
2022-08-04 23:13:05 +08:00
|
|
|
|
Bot.logger.mark(err)
|
2022-07-24 11:46:05 +08:00
|
|
|
|
})
|
|
|
|
|
// common.relpyPrivate(user_id, msg);
|
2022-06-28 23:21:06 +08:00
|
|
|
|
};
|
|
|
|
|
//判断今天是否推送
|
|
|
|
|
if (cookie.maxTime && cookie.maxTime > 0 && new Date().getTime() > cookie.maxTime - (160 - sendResin) * 8 *
|
|
|
|
|
60 * 1000) {
|
2022-07-05 23:12:47 +08:00
|
|
|
|
Bot.logger.mark(`体力推送:${user_id}`);
|
2022-06-28 23:21:06 +08:00
|
|
|
|
redis.set(sendkey, "1", {
|
|
|
|
|
EX: sendCD
|
|
|
|
|
});
|
2022-10-12 16:51:51 +08:00
|
|
|
|
if (isV3) {
|
|
|
|
|
let {
|
|
|
|
|
getRender
|
|
|
|
|
} = await import(`file://${_path}/plugins/xiaoyao-cvs-plugin/render.js`);
|
|
|
|
|
await Note(e, {
|
|
|
|
|
render: await getRender()
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
let {
|
|
|
|
|
getPluginRender
|
|
|
|
|
} = await import(`file://${_path}/lib/render.js`);
|
|
|
|
|
await Note(e, {
|
|
|
|
|
render: await getPluginRender()
|
|
|
|
|
});
|
2022-09-13 23:06:47 +08:00
|
|
|
|
}
|
2022-10-12 16:51:51 +08:00
|
|
|
|
|
2022-06-28 23:21:06 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-07-04 23:32:26 +08:00
|
|
|
|
|
2022-10-12 16:51:51 +08:00
|
|
|
|
export async function pokeNote(e, {
|
|
|
|
|
render
|
|
|
|
|
}) {
|
2022-07-07 10:52:17 +08:00
|
|
|
|
if (!Cfg.get("note.poke")) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2022-10-12 16:51:51 +08:00
|
|
|
|
return await Note(e, {
|
|
|
|
|
render
|
|
|
|
|
}, "poke");
|
2022-07-06 14:14:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-07-04 23:32:26 +08:00
|
|
|
|
|
|
|
|
|
export async function Note_appoint(e) {
|
2022-08-03 21:25:29 +08:00
|
|
|
|
let mbPath = `${_path}/plugins/xiaoyao-cvs-plugin/resources/dailyNote/`;
|
2022-07-04 23:32:26 +08:00
|
|
|
|
let msg = e.msg.replace(/#|井|体力|模板|设置/g, "");
|
2022-08-03 21:25:29 +08:00
|
|
|
|
|
2022-07-05 23:12:47 +08:00
|
|
|
|
let All = ["默认", "随机", "0"];
|
2022-07-04 23:32:26 +08:00
|
|
|
|
let urlType = note_file();
|
2022-08-03 21:25:29 +08:00
|
|
|
|
if (!isNaN(msg) && msg != 0) {
|
|
|
|
|
if (msg > urlType.length) {
|
|
|
|
|
e.reply(`没有${msg}的索引序号哦~`)
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
msg = urlType[msg - 1];
|
|
|
|
|
}
|
2022-07-04 23:32:26 +08:00
|
|
|
|
let type = 0;
|
|
|
|
|
if (msg.includes("列表")) {
|
2022-10-12 16:51:51 +08:00
|
|
|
|
let xlmsg = msg.replace("列表", "") * 1 || 1
|
|
|
|
|
let sumCount = (urlType.length / 80 + 0.49).toFixed(0);
|
|
|
|
|
xlmsg = sumCount - xlmsg > -1 ? xlmsg : sumCount == 0 ? 1 : sumCount;
|
|
|
|
|
let xxmsg = (xlmsg - 1) <= 0 ? 0 : 80 * (xlmsg - 1)
|
|
|
|
|
let count = 0;
|
|
|
|
|
let msgData = [`模板列表共,第${xlmsg}页,共${urlType.length}张,\n您可通过【#体力模板设置1】来绑定你需要的体力模板~\n请选择序号~~\n当前支持选择的模板有:`];
|
2022-08-03 21:25:29 +08:00
|
|
|
|
for (let [index, item] of urlType.entries()) {
|
|
|
|
|
let msg_pass = [];
|
|
|
|
|
let imgurl;
|
2022-09-09 10:03:17 +08:00
|
|
|
|
if (item.includes(".")) {
|
|
|
|
|
imgurl = await segment.image(`file:///${mbPath}background_image/${item}`);
|
|
|
|
|
item = item.split(".")[0];
|
|
|
|
|
} else {
|
|
|
|
|
imgurl = await segment.image(
|
|
|
|
|
`file:///${mbPath}Template/${item}/icon/bg/${fs.readdirSync(`${mbPath}/Template/${item}/icon/bg/`)[0]}`
|
|
|
|
|
)
|
2022-08-03 15:15:30 +08:00
|
|
|
|
}
|
2022-10-12 16:51:51 +08:00
|
|
|
|
item = index + 1 + "." + item
|
2022-08-04 23:13:05 +08:00
|
|
|
|
count++;
|
2022-10-12 16:51:51 +08:00
|
|
|
|
if (msgData.length == 81) {
|
2022-08-04 00:15:34 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
2022-10-12 16:51:51 +08:00
|
|
|
|
if (index < xxmsg) {
|
2022-08-04 00:15:34 +08:00
|
|
|
|
continue;
|
|
|
|
|
}
|
2022-08-03 21:25:29 +08:00
|
|
|
|
msg_pass.push(item)
|
|
|
|
|
if (imgurl) {
|
|
|
|
|
msg_pass.push(imgurl)
|
2022-08-03 15:15:30 +08:00
|
|
|
|
}
|
2022-09-09 10:03:17 +08:00
|
|
|
|
msgData.push(msg_pass)
|
2022-08-03 15:15:30 +08:00
|
|
|
|
}
|
2022-10-12 16:51:51 +08:00
|
|
|
|
let endMsg = "";
|
|
|
|
|
if (count < urlType.length) {
|
|
|
|
|
endMsg = `更多内容请翻页查看\n如:#体力模板列表2`
|
|
|
|
|
} else {
|
|
|
|
|
endMsg = `已经到底了~~`
|
2022-08-04 00:15:34 +08:00
|
|
|
|
}
|
2022-09-09 10:03:17 +08:00
|
|
|
|
msgData.push(endMsg)
|
|
|
|
|
await utils.replyMake(e, msgData, 0)
|
2022-07-04 23:32:26 +08:00
|
|
|
|
return true;
|
|
|
|
|
}
|
2022-10-12 16:51:51 +08:00
|
|
|
|
if (urlType.includes(msg + ".png")) {
|
|
|
|
|
msg = msg + ".png";
|
2022-08-03 21:25:29 +08:00
|
|
|
|
}
|
2022-07-05 23:12:47 +08:00
|
|
|
|
if (!urlType.includes(msg) && !All.includes(msg)) {
|
2022-07-04 23:32:26 +08:00
|
|
|
|
e.reply("没有找到你想要的模板昵!可输入 【#体力模板列表】 查询当前支持的模板哦~~")
|
|
|
|
|
return true;
|
2022-07-05 23:12:47 +08:00
|
|
|
|
} else if (All.includes(msg)) {
|
|
|
|
|
type = -1;
|
2022-08-03 21:25:29 +08:00
|
|
|
|
} else {
|
|
|
|
|
type = 1
|
|
|
|
|
if (msg.includes(".")) {
|
|
|
|
|
type = 0
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-07-05 23:12:47 +08:00
|
|
|
|
tempData[e.user_id] = {
|
|
|
|
|
temp: msg,
|
|
|
|
|
type: type,
|
|
|
|
|
}
|
|
|
|
|
fs.writeFileSync(tempDataUrl + "/tempData.json", JSON.stringify(tempData));
|
2022-07-04 23:32:26 +08:00
|
|
|
|
init()
|
|
|
|
|
e.reply("诶~这是你选的模板吗,模板设置成功了快用指令来试试吧~!")
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-03 22:56:01 +08:00
|
|
|
|
const note_file = function(xiaoyao) {
|
2022-07-04 23:32:26 +08:00
|
|
|
|
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)
|
|
|
|
|
}
|
2022-10-12 16:51:51 +08:00
|
|
|
|
if (!xiaoyao) {
|
2022-08-03 22:56:01 +08:00
|
|
|
|
var urlFileOne = fs.readdirSync(`./plugins/xiaoyao-cvs-plugin/resources/dailyNote/background_image/`);
|
|
|
|
|
for (let val of urlFileOne) {
|
|
|
|
|
if (!val.includes(".")) continue;
|
|
|
|
|
urlType.push(val)
|
2022-09-09 10:03:17 +08:00
|
|
|
|
|
2022-08-03 22:56:01 +08:00
|
|
|
|
}
|
2022-08-03 21:25:29 +08:00
|
|
|
|
}
|
2022-07-04 23:32:26 +08:00
|
|
|
|
return urlType;
|
|
|
|
|
}
|