* 增加#喵喵面板设置命令,可更精细的设置是否允许好友/临时对话/群使用面板功能

* `#喵喵日历` 优化
    * 对角色、武器UP的日历展示做合并优化
    * 增强从活动详情解析日期的能力,使一些活动日期更加准确
* `#角色面板` 伤害计算增加 琴、莫娜
This commit is contained in:
yoimiya-kokomi 2022-05-29 05:18:13 +08:00
parent 7094262acf
commit 750cdddbce
15 changed files with 355 additions and 32 deletions

View File

@ -1,3 +1,11 @@
# 1.6.2
* 增加`#喵喵面板设置`命令,可更精细的设置是否允许好友/临时对话/群使用面板功能
* `#喵喵日历` 优化
* 对角色、武器UP的日历展示做合并优化
* 增强从活动详情解析日期的能力,使一些活动日期更加准确
* `#角色面板` 伤害计算增加 琴、莫娜
# 1.6.1 # 1.6.1
* `#角色面板` 伤害计算增加 皇女、温迪、夜兰 * `#角色面板` 伤害计算增加 皇女、温迪、夜兰

View File

@ -36,6 +36,11 @@ export const rule = {
hashMark: true, hashMark: true,
reg: sysCfgReg, reg: sysCfgReg,
describe: "【#管理】系统设置" describe: "【#管理】系统设置"
},
profileCfg: {
hashMark: true,
reg: "^#喵喵面板(?:设置)?.*",
describe: "【#管理】面板设置"
} }
}; };
@ -105,7 +110,6 @@ const getStatus = function (rote, def = true) {
} else { } else {
return `<div class="cfg-status status-off">已关闭</div>`; return `<div class="cfg-status status-off">已关闭</div>`;
} }
} }
export async function updateRes(e) { export async function updateRes(e) {
@ -117,7 +121,6 @@ export async function updateRes(e) {
e.reply("开始尝试更新,请耐心等待~"); e.reply("开始尝试更新,请耐心等待~");
command = `git pull`; command = `git pull`;
exec(command, { cwd: `${resPath}/miao-res-plus/` }, function (error, stdout, stderr) { exec(command, { cwd: `${resPath}/miao-res-plus/` }, function (error, stdout, stderr) {
//console.log(stdout);
if (/Already up to date/.test(stdout)) { if (/Already up to date/.test(stdout)) {
e.reply("目前所有图片都已经是最新了~"); e.reply("目前所有图片都已经是最新了~");
return true; return true;
@ -162,7 +165,6 @@ export async function updateMiaoPlugin(e) {
e.reply("正在执行更新操作,请稍等"); e.reply("正在执行更新操作,请稍等");
} }
exec(command, { cwd: `${_path}/plugins/miao-plugin/` }, function (error, stdout, stderr) { exec(command, { cwd: `${_path}/plugins/miao-plugin/` }, function (error, stdout, stderr) {
//console.log(stdout);
if (/Already up to date/.test(stdout)) { if (/Already up to date/.test(stdout)) {
e.reply("目前已经是最新版喵喵了~"); e.reply("目前已经是最新版喵喵了~");
return true; return true;
@ -193,4 +195,66 @@ export async function updateMiaoPlugin(e) {
}); });
return true; 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 });
} }

View File

@ -78,12 +78,30 @@ export async function character(e, { render, User }) {
name = name.replace(/详情|详细|面板|面版|更新/g, "").trim(); name = name.replace(/详情|详细|面板|面版|更新/g, "").trim();
} }
if (
(mode === "card" && Common.isDisable(e, "char.char")) || if (mode === "card" && Common.isDisable(e, "char.char")) {
(mode !== "card" && Common.isDisable(e, "char.profile"))) {
return; 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); let char = Character.get(name);
if (!char) { if (!char) {

View File

@ -11,7 +11,7 @@ const ignoreIds = [495,// 有奖问卷调查开启!
762, // 《原神》公平运营声明 762, // 《原神》公平运营声明
] ]
const ignoreReg = /(内容专题页|版本更新说明|调研|防沉迷|米游社|专项意见|更新修复与优化|问卷调查)/; const ignoreReg = /(内容专题页|版本更新说明|调研|防沉迷|米游社|专项意见|更新修复与优化|问卷调查|版本更新通知|更新时间说明|预下载功能|周边限时返场)/;
const fulltimeReg = /(魔神任务)/; const fulltimeReg = /(魔神任务)/;
let Cal = { let Cal = {
@ -23,7 +23,7 @@ let Cal = {
let timeMap; let timeMap;
let timeMapCache = await redis.get("cache:calendar:detail"); let timeMapCache = await redis.get("cache:calendar:detail");
if (timeMapCache) { if (timeMapCache && false) {
timeMap = JSON.parse(timeMapCache) || {}; timeMap = JSON.parse(timeMapCache) || {};
} else { } 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&region=cn_gf01&level=55&uid=100000000"; 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&region=cn_gf01&level=55&uid=100000000";
@ -31,18 +31,58 @@ let Cal = {
let detailData = await request2.json(); let detailData = await request2.json();
timeMap = {} timeMap = {}
if (detailData && detailData.data && detailData.data.list) { if (detailData && detailData.data && detailData.data.list) {
let versionTime = {};
lodash.forEach(detailData.data.list, (ds) => { 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(/(<|&lt;)[\w "%:;=\-\\/\\(\\)\,\\.]+(>|&gt;)/g, ""); content = content.replace(/(<|&lt;)[\w "%:;=\-\\/\\(\\)\,\\.]+(>|&gt;)/g, "");
content = /(?:活动时间|祈愿介绍|任务开放时间|冒险....包)\s*〓([^〓]+)(〓|$)/.exec(content);
if (!content || !content[1]) {
return;
}
content = content[1];
let annTime = [];
// 第一种简单格式
let timeRet = /活动时间(?:〓|\s)*([0-9\\/\\: ~]*)/.exec(content); let timeRet = /活动时间(?:〓|\s)*([0-9\\/\\: ~]*)/.exec(content);
if (timeRet && timeRet[1]) { if (timeRet && timeRet[1]) {
let times = timeRet[1].split("~"); annTime = timeRet[1].split("~");
if (times.length === 2) { } else if (/\d\.\d版本更新后/.test(content)) {
timeMap[ann_id] = { let vRet = /(\d\.\d)版本更新后/.exec(content);
start: times[0].trim().replace(/\//g,"-"), let vTime = '';
end: times[1].trim().replace(/\//g,"-") 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; width = eRange / totalRange * 100 - left;
let label = ""; let label = "";
if (fulltimeReg.test(title)) { if (fulltimeReg.test(title) || eDate - sDate > 365 * 24 * 3600 * 1000) {
left = 0; if (sDate < now) {
width = 100; left = 0;
width = 100;
}
label = "永久有效"; label = "永久有效";
} else if (now > sDate && eDate > now) { } else if (now > sDate && eDate > now) {
label = eDate.format("MM-DD HH:mm") + " (" + moment.duration(eDate - now).humanize() + "后结束)" label = eDate.format("MM-DD HH:mm") + " (" + moment.duration(eDate - now).humanize() + "后结束)"
@ -222,12 +264,27 @@ let Cal = {
}, abyss, { ...dl, now }, true) }, 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 { return {
...dl, ...dl,
list, list,
abyss, abyss,
charMode: `char-${charCount}-${charOld}`,
nowTime: now.format("YYYY-MM-DD HH:mm"), nowTime: now.format("YYYY-MM-DD HH:mm"),
nowDate: now.date(), nowDate: now.date(),
} }

View File

@ -21,6 +21,10 @@ let Cfg = {
lodash.set(cfg, rote, val); lodash.set(cfg, rote, val);
fs.writeFileSync(_cfgPath + "cfg.json", JSON.stringify(cfg, null, "\t")); 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) { scale(pct = 1) {
let scale = Cfg.get("sys.scale", 100); let scale = Cfg.get("sys.scale", 100);
scale = Math.min(2, Math.max(0.5, scale / 100)); scale = Math.min(2, Math.max(0.5, scale / 100));

View File

@ -13,7 +13,7 @@ import { wiki, calendar } from "./apps/wiki.js";
import { help, versionInfo } from "./apps/help.js"; import { help, versionInfo } from "./apps/help.js";
import lodash from "lodash"; import lodash from "lodash";
import common from "../../lib/common.js"; 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"; import { currentVersion } from "./components/Changelog.js";
export { export {
@ -33,7 +33,8 @@ export {
getArtis, getArtis,
getProfileAll, getProfileAll,
profileHelp, profileHelp,
calendar calendar,
profileCfg
}; };

View File

@ -105,14 +105,6 @@
</div> </div>
<div class="cfg-desc">开启后将使用喵喵版帮助作为Yunzai的默认帮助</div> <div class="cfg-desc">开启后将使用喵喵版帮助作为Yunzai的默认帮助</div>
</li> </li>
<!-- <li class="cfg-li">
<div class="cfg-line">
更新版本
<div class="cfg-status">#喵喵更新</div>
</div>
<div class="cfg-desc">更新喵喵Plugin可能需要重启Yunzai-Bot</div>
</li>-->
</ul> </ul>
</div> </div>

View File

View File

@ -0,0 +1,59 @@
{{extend defaultLayout}}
{{block 'css'}}
<link rel="stylesheet" type="text/css" href="{{_res_path}}/admin/index.css"/>
<link rel="stylesheet" type="text/css" href="{{_res_path}}/admin/index.css"/>
<link rel="stylesheet" type="text/css" href="{{_res_path}}/admin/profile.css"/>
{{/block}}
{{block 'main'}}
<div class="info_box">
<div class="head-box type{{bgType}}">
<div class="label">#喵喵面板设置</div>
<div class="title">角色面板管理</div>
</div>
</div>
<div class="cfg-box">
<div class="cfg-group">#角色面板开放范围</div>
<ul class="cfg-ul">
<li class="cfg-li">
<div class="cfg-line">
好友
<span class="cfg-hint"> #喵喵面板设置好友 + 开启/关闭</span>
{{@friend}}
</div>
</li>
<li class="cfg-li">
<div class="cfg-line">
陌生人
<span class="cfg-hint"> #喵喵面板设置陌生人 + 开启/关闭</span>
{{@stranger}}
</div>
</li>
<li class="cfg-li">
<div class="cfg-line">
<span class="cfg-hint"> #喵喵面板设置群 + 开启/关闭</span>
{{@group}}
</div>
<div class="cfg-desc">若下方无指定群设置,默认使用此设置</div>
</li>
</ul>
</div>
<div class="cfg-box">
<div class="cfg-group">指定群设置</div>
<div class="cfg-desc">#喵喵面板设置群123456 + 开启/关闭/删除。对应群号会优先使用</div>
<ul class="cfg-ul">
{{each groups group}}
<li class="cfg-li">
<div class="cfg-line">
{{group.group}}
{{@group.status}}
</div>
</li>
{{/each}}
</ul>
</div>
{{/block}}

View File

View File

@ -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
}
}];

View File

@ -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['伤害加成']
}
}];

View File

@ -141,7 +141,7 @@ body {
padding-left: 65px; padding-left: 65px;
} }
.cal-list .cal-item.type-character .character-img { .cal-list .cal-item.type-character .character-img {
width: 65px; height: 75px;
position: absolute; position: absolute;
bottom: 0; bottom: 0;
left: 0; left: 0;
@ -193,6 +193,20 @@ body {
left: 10px; left: 10px;
top: 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 { .calendar .now-line {
position: absolute; position: absolute;
top: 86px; top: 86px;

View File

@ -35,7 +35,7 @@
</tr> </tr>
</table> </table>
</div> </div>
<div class="cal-list"> <div class="cal-list {{charMode}}">
<div class="cal-abyss-cont"> <div class="cal-abyss-cont">
{{each abyss li}} {{each abyss li}}
<div class="cal-item type-abyss" style="{{`left:${li.left}%;width:${li.width}%`}}"> <div class="cal-item type-abyss" style="{{`left:${li.left}%;width:${li.width}%`}}">
@ -48,7 +48,7 @@
{{/each}} {{/each}}
</div> </div>
{{each list li}} {{each list li}}
<div class="cal-item type-{{li.type}} {{li.elem?'elem-'+li.elem:''}} {{li.width<20 ? 'small-mode':''}}" <div class="cal-item type-{{li.type}} {{li.idx? `li-idx-${li.idx}`:``}} {{li.elem?'elem-'+li.elem:''}} {{li.width<20 ? 'small-mode':''}}"
style="{{`margin-left:${li.left}%;width:${li.width}%`}}" style="{{`margin-left:${li.left}%;width:${li.width}%`}}"
data-id="{{li.id}}" data-id="{{li.id}}"
data-type="{{li.type}}"> data-type="{{li.type}}">

View File

@ -175,7 +175,7 @@ body {
} }
.character-img { .character-img {
width: 65px; height: 75px;
position: absolute; position: absolute;
bottom: 0; bottom: 0;
left: 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 { .calendar .now-line {