From 750cdddbced17ee8927c4c0d43f358a783332f84 Mon Sep 17 00:00:00 2001
From: yoimiya-kokomi <592981798@qq.com>
Date: Sun, 29 May 2022 05:18:13 +0800
Subject: [PATCH] =?UTF-8?q?*=20=E5=A2=9E=E5=8A=A0`#=E5=96=B5=E5=96=B5?=
=?UTF-8?q?=E9=9D=A2=E6=9D=BF=E8=AE=BE=E7=BD=AE`=E5=91=BD=E4=BB=A4?=
=?UTF-8?q?=EF=BC=8C=E5=8F=AF=E6=9B=B4=E7=B2=BE=E7=BB=86=E7=9A=84=E8=AE=BE?=
=?UTF-8?q?=E7=BD=AE=E6=98=AF=E5=90=A6=E5=85=81=E8=AE=B8=E5=A5=BD=E5=8F=8B?=
=?UTF-8?q?/=E4=B8=B4=E6=97=B6=E5=AF=B9=E8=AF=9D/=E7=BE=A4=E4=BD=BF?=
=?UTF-8?q?=E7=94=A8=E9=9D=A2=E6=9D=BF=E5=8A=9F=E8=83=BD=20*=20`#=E5=96=B5?=
=?UTF-8?q?=E5=96=B5=E6=97=A5=E5=8E=86`=20=E4=BC=98=E5=8C=96=20=20=20=20?=
=?UTF-8?q?=20*=20=E5=AF=B9=E8=A7=92=E8=89=B2=E3=80=81=E6=AD=A6=E5=99=A8UP?=
=?UTF-8?q?=E7=9A=84=E6=97=A5=E5=8E=86=E5=B1=95=E7=A4=BA=E5=81=9A=E5=90=88?=
=?UTF-8?q?=E5=B9=B6=E4=BC=98=E5=8C=96=20=20=20=20=20*=20=E5=A2=9E?=
=?UTF-8?q?=E5=BC=BA=E4=BB=8E=E6=B4=BB=E5=8A=A8=E8=AF=A6=E6=83=85=E8=A7=A3?=
=?UTF-8?q?=E6=9E=90=E6=97=A5=E6=9C=9F=E7=9A=84=E8=83=BD=E5=8A=9B=EF=BC=8C?=
=?UTF-8?q?=E4=BD=BF=E4=B8=80=E4=BA=9B=E6=B4=BB=E5=8A=A8=E6=97=A5=E6=9C=9F?=
=?UTF-8?q?=E6=9B=B4=E5=8A=A0=E5=87=86=E7=A1=AE=20*=20`#=E8=A7=92=E8=89=B2?=
=?UTF-8?q?=E9=9D=A2=E6=9D=BF`=20=E4=BC=A4=E5=AE=B3=E8=AE=A1=E7=AE=97?=
=?UTF-8?q?=E5=A2=9E=E5=8A=A0=20=E7=90=B4=E3=80=81=E8=8E=AB=E5=A8=9C?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
CHANGELOG.md | 8 +++
apps/admin.js | 70 ++++++++++++++++++++-
apps/character.js | 24 +++++++-
components/Calendar.js | 81 +++++++++++++++++++++----
components/Cfg.js | 4 ++
index.js | 5 +-
resources/admin/index.html | 8 ---
resources/admin/profile.css | 0
resources/admin/profile.html | 59 ++++++++++++++++++
resources/admin/profile.less | 0
resources/meta/character/琴/calc.js | 32 ++++++++++
resources/meta/character/莫娜/calc.js | 50 +++++++++++++++
resources/wiki/calendar.css | 16 ++++-
resources/wiki/calendar.html | 4 +-
resources/wiki/calendar.less | 26 +++++++-
15 files changed, 355 insertions(+), 32 deletions(-)
create mode 100644 resources/admin/profile.css
create mode 100644 resources/admin/profile.html
create mode 100644 resources/admin/profile.less
create mode 100644 resources/meta/character/琴/calc.js
create mode 100644 resources/meta/character/莫娜/calc.js
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 83e2e3f4..2935d9fb 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,11 @@
+# 1.6.2
+
+* 增加`#喵喵面板设置`命令,可更精细的设置是否允许好友/临时对话/群使用面板功能
+* `#喵喵日历` 优化
+ * 对角色、武器UP的日历展示做合并优化
+ * 增强从活动详情解析日期的能力,使一些活动日期更加准确
+* `#角色面板` 伤害计算增加 琴、莫娜
+
# 1.6.1
* `#角色面板` 伤害计算增加 皇女、温迪、夜兰
diff --git a/apps/admin.js b/apps/admin.js
index 31b2c9c7..68e43705 100644
--- a/apps/admin.js
+++ b/apps/admin.js
@@ -36,6 +36,11 @@ export const rule = {
hashMark: true,
reg: sysCfgReg,
describe: "【#管理】系统设置"
+ },
+ profileCfg: {
+ hashMark: true,
+ reg: "^#喵喵面板(?:设置)?.*",
+ describe: "【#管理】面板设置"
}
};
@@ -105,7 +110,6 @@ const getStatus = function (rote, def = true) {
} else {
return `
已关闭
`;
}
-
}
export async function updateRes(e) {
@@ -117,7 +121,6 @@ export async function updateRes(e) {
e.reply("开始尝试更新,请耐心等待~");
command = `git pull`;
exec(command, { cwd: `${resPath}/miao-res-plus/` }, function (error, stdout, stderr) {
- //console.log(stdout);
if (/Already up to date/.test(stdout)) {
e.reply("目前所有图片都已经是最新了~");
return true;
@@ -162,7 +165,6 @@ export async function updateMiaoPlugin(e) {
e.reply("正在执行更新操作,请稍等");
}
exec(command, { cwd: `${_path}/plugins/miao-plugin/` }, function (error, stdout, stderr) {
- //console.log(stdout);
if (/Already up to date/.test(stdout)) {
e.reply("目前已经是最新版喵喵了~");
return true;
@@ -193,4 +195,66 @@ export async function updateMiaoPlugin(e) {
});
return true;
+}
+
+export async function profileCfg(e, { render }) {
+ if (!await checkAuth(e)) {
+ return true;
+ }
+
+ let keyMap = {
+ "好友": "friend",
+ "群": "group",
+ "陌生人": "stranger"
+ }
+
+ let regRet = /喵喵面板(?:设置)?\s*(好友|群|群聊|陌生人)?\s*(\d*)\s*(开启|关闭|删除)?\s*$/.exec(e.msg);
+
+ if (!regRet) {
+ return;
+ }
+
+ let [, target, groupId, actionType] = regRet;
+ if (target === "群聊") {
+ target = "群";
+ }
+
+ if (target) {
+ if (groupId && (target === "群" || !target)) {
+ if (actionType === "删除") {
+ Cfg.del(`profile.groups.群${groupId}`);
+ } else {
+ Cfg.set(`profile.groups.群${groupId}.status`, actionType !== "关闭");
+ }
+ } else {
+ Cfg.set(`profile.${keyMap[target]}.status`, actionType !== "关闭");
+ }
+ }
+
+ let cfg = {
+ groups: []
+ }
+
+ lodash.forEach(['friend', 'group', 'stranger'], (key) => {
+ cfg[key] = getStatus(`profile.${key}.status`, true)
+ });
+
+ let groups = Cfg.get('profile.groups', {});
+ lodash.forEach(lodash.keys(groups), (group, idx) => {
+
+ if (lodash.isUndefined(groups[group])) {
+ return;
+ }
+ cfg.groups.push({
+ group,
+ idx: idx + 1,
+ status: getStatus(`profile.groups.${group}.status`, true)
+ })
+ })
+
+ //渲染图像
+ return await Common.render("admin/profile", {
+ ...cfg,
+ }, { e, render, scale: 1.4 });
+
}
\ No newline at end of file
diff --git a/apps/character.js b/apps/character.js
index 80759ba7..46398a87 100644
--- a/apps/character.js
+++ b/apps/character.js
@@ -78,12 +78,30 @@ export async function character(e, { render, User }) {
name = name.replace(/详情|详细|面板|面版|更新/g, "").trim();
}
- if (
- (mode === "card" && Common.isDisable(e, "char.char")) ||
- (mode !== "card" && Common.isDisable(e, "char.profile"))) {
+
+ if (mode === "card" && Common.isDisable(e, "char.char")) {
return;
}
+ if (mode !== "card" && !e.isMaster) {
+ if (Common.isDisable(e, "char.profile")) {
+ // 面板开关关闭
+ return;
+ }
+ if (e.isPrivate) {
+ if ((e.sub_type === "friend" && Cfg.get("profile.friend.status") === false) ||
+ (e.sub_type === "group" && Cfg.get("profile.stranger.status") === false)) {
+ return;
+ }
+ } else if (e.isGroup) {
+ let groupCfg = Cfg.get(`profile.groups.群${e.group_id}.status`);
+ if (groupCfg === false || (groupCfg !== true && Cfg.get(`profile.group.status`) === false)) {
+ return;
+ }
+ }
+ }
+
+
let char = Character.get(name);
if (!char) {
diff --git a/components/Calendar.js b/components/Calendar.js
index 00884e05..3a0d6295 100644
--- a/components/Calendar.js
+++ b/components/Calendar.js
@@ -11,7 +11,7 @@ const ignoreIds = [495,// 有奖问卷调查开启!
762, // 《原神》公平运营声明
]
-const ignoreReg = /(内容专题页|版本更新说明|调研|防沉迷|米游社|专项意见|更新修复与优化|问卷调查)/;
+const ignoreReg = /(内容专题页|版本更新说明|调研|防沉迷|米游社|专项意见|更新修复与优化|问卷调查|版本更新通知|更新时间说明|预下载功能|周边限时返场)/;
const fulltimeReg = /(魔神任务)/;
let Cal = {
@@ -23,7 +23,7 @@ let Cal = {
let timeMap;
let timeMapCache = await redis.get("cache:calendar:detail");
- if (timeMapCache) {
+ if (timeMapCache && false) {
timeMap = JSON.parse(timeMapCache) || {};
} else {
let detailApi = "https://hk4e-api.mihoyo.com/common/hk4e_cn/announcement/api/getAnnContent?game=hk4e&game_biz=hk4e_cn&lang=zh-cn&bundle_id=hk4e_cn&platform=pc®ion=cn_gf01&level=55&uid=100000000";
@@ -31,18 +31,58 @@ let Cal = {
let detailData = await request2.json();
timeMap = {}
if (detailData && detailData.data && detailData.data.list) {
+ let versionTime = {};
lodash.forEach(detailData.data.list, (ds) => {
- let { ann_id, content } = ds;
+ let vRet = /(\d\.\d)版本更新时间/.exec(ds.title)
+ if (vRet && vRet[1]) {
+ let tRet = /([0-9\\/\\: ]){9,}/.exec(ds.content);
+ if (tRet && tRet[0]) {
+ versionTime[vRet[1]] = tRet[0].replace("06:00", "11:00");
+ }
+ }
+ })
+ lodash.forEach(detailData.data.list, (ds) => {
+ let { ann_id, content, title } = ds;
+ if (ignoreReg.test(title)) {
+ return;
+ }
content = content.replace(/(<|<)[\w "%:;=\-\\/\\(\\)\,\\.]+(>|>)/g, "");
+ content = /(?:活动时间|祈愿介绍|任务开放时间|冒险....包)\s*〓([^〓]+)(〓|$)/.exec(content);
+ if (!content || !content[1]) {
+ return;
+ }
+ content = content[1];
+ let annTime = [];
+
+ // 第一种简单格式
let timeRet = /活动时间(?:〓|\s)*([0-9\\/\\: ~]*)/.exec(content);
if (timeRet && timeRet[1]) {
- let times = timeRet[1].split("~");
- if (times.length === 2) {
- timeMap[ann_id] = {
- start: times[0].trim().replace(/\//g,"-"),
- end: times[1].trim().replace(/\//g,"-")
+ annTime = timeRet[1].split("~");
+ } else if (/\d\.\d版本更新后/.test(content)) {
+ let vRet = /(\d\.\d)版本更新后/.exec(content);
+ let vTime = '';
+ if (vRet && vRet[1] && versionTime[vRet[1]]) {
+ vTime = versionTime[vRet[1]];
+ }
+ if (!vTime) {
+ return;
+ }
+ if (/永久开放/.test(content)) {
+ annTime = [vTime, '2099/01/01 00:00:00'];
+ } else {
+ timeRet = /([0-9\\/\\: ]){9,}/.exec(content);
+ if (timeRet && timeRet[0]) {
+ annTime = [vTime, timeRet[0]];
}
}
+
+ }
+
+ if (annTime.length === 2) {
+ timeMap[ann_id] = {
+ start: annTime[0].trim().replace(/\//g, "-"),
+ end: annTime[1].trim().replace(/\//g, "-")
+ }
}
})
}
@@ -167,9 +207,11 @@ let Cal = {
width = eRange / totalRange * 100 - left;
let label = "";
- if (fulltimeReg.test(title)) {
- left = 0;
- width = 100;
+ if (fulltimeReg.test(title) || eDate - sDate > 365 * 24 * 3600 * 1000) {
+ if (sDate < now) {
+ left = 0;
+ width = 100;
+ }
label = "永久有效";
} else if (now > sDate && eDate > now) {
label = eDate.format("MM-DD HH:mm") + " (" + moment.duration(eDate - now).humanize() + "后结束)"
@@ -222,12 +264,27 @@ let Cal = {
}, abyss, { ...dl, now }, true)
});
- list = lodash.sortBy(list, ["sort", 'duration', 'start']);
+ list = lodash.sortBy(list, ["sort", 'start', 'duration']);
+
+ let charCount = 0, charOld = 0;
+ let weaponCount = 0;
+ lodash.forEach(list, (li) => {
+ if (li.type === "character") {
+ charCount++;
+ li.left === 0 && charOld++;
+ li.idx = charCount;
+ }
+ if (li.type === "weapon") {
+ weaponCount++;
+ li.idx = weaponCount;
+ }
+ })
return {
...dl,
list,
abyss,
+ charMode: `char-${charCount}-${charOld}`,
nowTime: now.format("YYYY-MM-DD HH:mm"),
nowDate: now.date(),
}
diff --git a/components/Cfg.js b/components/Cfg.js
index 2561a91f..3add1e5a 100644
--- a/components/Cfg.js
+++ b/components/Cfg.js
@@ -21,6 +21,10 @@ let Cfg = {
lodash.set(cfg, rote, val);
fs.writeFileSync(_cfgPath + "cfg.json", JSON.stringify(cfg, null, "\t"));
},
+ del(rote) {
+ lodash.set(cfg, rote, undefined);
+ fs.writeFileSync(_cfgPath + "cfg.json", JSON.stringify(cfg, null, "\t"));
+ },
scale(pct = 1) {
let scale = Cfg.get("sys.scale", 100);
scale = Math.min(2, Math.max(0.5, scale / 100));
diff --git a/index.js b/index.js
index 3d393f96..95c75d66 100644
--- a/index.js
+++ b/index.js
@@ -13,7 +13,7 @@ import { wiki, calendar } from "./apps/wiki.js";
import { help, versionInfo } from "./apps/help.js";
import lodash from "lodash";
import common from "../../lib/common.js";
-import { rule as adminRule, updateRes, sysCfg, updateMiaoPlugin } from "./apps/admin.js";
+import { rule as adminRule, updateRes, sysCfg, updateMiaoPlugin, profileCfg } from "./apps/admin.js";
import { currentVersion } from "./components/Changelog.js";
export {
@@ -33,7 +33,8 @@ export {
getArtis,
getProfileAll,
profileHelp,
- calendar
+ calendar,
+ profileCfg
};
diff --git a/resources/admin/index.html b/resources/admin/index.html
index 16d1189f..cfde2015 100644
--- a/resources/admin/index.html
+++ b/resources/admin/index.html
@@ -105,14 +105,6 @@
开启后将使用喵喵版帮助作为Yunzai的默认帮助
-
-
diff --git a/resources/admin/profile.css b/resources/admin/profile.css
new file mode 100644
index 00000000..e69de29b
diff --git a/resources/admin/profile.html b/resources/admin/profile.html
new file mode 100644
index 00000000..e965a6dc
--- /dev/null
+++ b/resources/admin/profile.html
@@ -0,0 +1,59 @@
+{{extend defaultLayout}}
+
+{{block 'css'}}
+
+
+
+{{/block}}
+
+{{block 'main'}}
+
+
+
+
#角色面板开放范围
+
+ -
+
+ 好友
+ #喵喵面板设置好友 + 开启/关闭
+ {{@friend}}
+
+
+ -
+
+ 陌生人
+ #喵喵面板设置陌生人 + 开启/关闭
+ {{@stranger}}
+
+
+ -
+
+ 群
+ #喵喵面板设置群 + 开启/关闭
+ {{@group}}
+
+ 若下方无指定群设置,默认使用此设置
+
+
+
+
+
指定群设置
+
#喵喵面板设置群123456 + 开启/关闭/删除。对应群号会优先使用
+
+
+{{/block}}
\ No newline at end of file
diff --git a/resources/admin/profile.less b/resources/admin/profile.less
new file mode 100644
index 00000000..e69de29b
diff --git a/resources/meta/character/琴/calc.js b/resources/meta/character/琴/calc.js
new file mode 100644
index 00000000..e9eefd5e
--- /dev/null
+++ b/resources/meta/character/琴/calc.js
@@ -0,0 +1,32 @@
+export const details = [{
+ title: "风压剑伤害",
+ dmg: ({ talent }, dmg) => dmg(talent.e['技能伤害'], 'e')
+}, {
+ title: "Q爆发伤害",
+ params: { q: true },
+ dmg: ({ talent }, dmg) => dmg(talent.q['爆发伤害'], 'q')
+}, {
+ title: "Q爆发治疗",
+ dmg: ({ talent, calc, attr }, { heal }) =>
+ heal(talent.q['领域发动治疗量2'][0] * calc(attr.atk) / 100 + talent.q['领域发动治疗量2'][1] * 1)
+}, {
+ title: "Q每跳治疗",
+ dmg: ({ talent, calc, attr }, { heal }) =>
+ heal(talent.q['持续治疗2'][0] * calc(attr.atk) / 100 + talent.q['持续治疗2'][1] * 1)
+}];
+
+export const mainAttr = "atk,cpct,cdmg";
+
+export const buffs = [{
+ cons: 1,
+ title: "琴1命:长按1秒后风压剑伤害提升40%",
+ data: {
+ eDmg: 40
+ }
+}, {
+ cons: 4,
+ title: "琴4命:蒲公英之风的领域内敌人风元素抗性降低40%",
+ data: {
+ kx: ({ params }) => params.q ? 40 : 0
+ }
+}];
\ No newline at end of file
diff --git a/resources/meta/character/莫娜/calc.js b/resources/meta/character/莫娜/calc.js
new file mode 100644
index 00000000..f78a3f2a
--- /dev/null
+++ b/resources/meta/character/莫娜/calc.js
@@ -0,0 +1,50 @@
+export const details = [{
+ title: "重击伤害",
+ dmg: ({ talent }, dmg) => dmg(talent.a['重击伤害'], 'a2')
+}, {
+ title: "重击蒸发",
+ dmg: ({ talent }, dmg) => dmg(talent.a['重击伤害'], 'a2', 'zf')
+}, {
+ title: "Q泡影破裂伤害",
+ params: { q: true },
+ dmg: ({ talent }, dmg) => dmg(talent.q['泡影破裂伤害'], 'q')
+}, {
+ title: "Q泡影破裂蒸发",
+ params: { q: true },
+ dmg: ({ talent }, dmg) => dmg(talent.q['泡影破裂伤害'], 'q', 'zf')
+}];
+
+export const mainAttr = "atk,hp,cpct,recharge";
+
+export const buffs = [{
+ title: "莫娜被动:基于元素充能效率获得水元素伤害[dmg]%",
+ data: {
+ dmg: ({ calc, attr }) => calc(attr.recharge) * 0.2
+ }
+}, {
+ title: "莫娜1命:命中星异状态下的敌人水元素相关反应效果提升15%",
+ cons: 1,
+ data: {
+ zf: ({ params }) => params.q ? 15 : 0
+ }
+}, {
+ title: "莫娜4命:攻击处于星异状态下的敌人时暴击率提升15%",
+ cons: 4,
+ data: {
+ cpct: ({ params }) => params.q ? 15 : 0
+ }
+}, {
+ title: "莫娜6命:虚实流动状态后满Buff提升重击180%伤害",
+ cons: 6,
+ data: {
+ a2Dmg: 180
+ }
+}, {
+ title: "元素精通:蒸发融化伤害提高[zf]%",
+ mastery: "zf,rh"
+}, {
+ title: "莫娜天赋:开Q获得[dmg]%伤害加成",
+ data: {
+ dmg: ({ talent }) => talent.q['伤害加成']
+ }
+}];
diff --git a/resources/wiki/calendar.css b/resources/wiki/calendar.css
index 503ffccf..f96689d2 100644
--- a/resources/wiki/calendar.css
+++ b/resources/wiki/calendar.css
@@ -141,7 +141,7 @@ body {
padding-left: 65px;
}
.cal-list .cal-item.type-character .character-img {
- width: 65px;
+ height: 75px;
position: absolute;
bottom: 0;
left: 0;
@@ -193,6 +193,20 @@ body {
left: 10px;
top: 10px;
}
+.cal-list.char-2-1 .type-character.li-idx-2,
+.cal-list.char-3-1 .type-character.li-idx-2 {
+ margin-top: -82px;
+}
+.cal-list.char-3-2 .type-character.li-idx-3 {
+ margin-top: -82px;
+}
+.cal-list.char-4-2 .type-character.li-idx-3,
+.cal-list.char-4-2 .type-character.li-idx-4 {
+ margin-top: -164px;
+}
+.cal-list .type-weapon.li-idx-2 {
+ margin-top: -82px;
+}
.calendar .now-line {
position: absolute;
top: 86px;
diff --git a/resources/wiki/calendar.html b/resources/wiki/calendar.html
index 35f49cd6..2a4a1d6d 100644
--- a/resources/wiki/calendar.html
+++ b/resources/wiki/calendar.html
@@ -35,7 +35,7 @@
-
+
{{each abyss li}}
@@ -48,7 +48,7 @@
{{/each}}
{{each list li}}
-
diff --git a/resources/wiki/calendar.less b/resources/wiki/calendar.less
index 731117b8..bc9e6b57 100644
--- a/resources/wiki/calendar.less
+++ b/resources/wiki/calendar.less
@@ -175,7 +175,7 @@ body {
}
.character-img {
- width: 65px;
+ height: 75px;
position: absolute;
bottom: 0;
left: 0;
@@ -246,6 +246,30 @@ body {
}
}
+
+ &.char-2-1,
+ &.char-3-1 {
+ .type-character.li-idx-2 {
+ margin-top: -82px;
+ }
+ }
+
+ &.char-3-2 {
+ .type-character.li-idx-3 {
+ margin-top: -82px;
+ }
+ }
+
+ &.char-4-2 {
+ .type-character.li-idx-3,
+ .type-character.li-idx-4 {
+ margin-top: -164px;
+ }
+ }
+
+ .type-weapon.li-idx-2 {
+ margin-top: -82px;
+ }
}
.calendar .now-line {