diff --git a/apps/admin.js b/apps/admin.js index 70bb0cba..651bc9f5 100644 --- a/apps/admin.js +++ b/apps/admin.js @@ -20,10 +20,12 @@ let cfgMap = { let sysCfgReg = `^#喵喵设置\s*(${lodash.keys(cfgMap).join("|")})?\s*(.*)$`; export const rule = { updateRes: { + hashMark: true, reg: "^#喵喵更新图像$", describe: "【#管理】更新素材", }, sysCfg: { + hashMark: true, reg: sysCfgReg, describe: "【#管理】系统设置" } @@ -105,39 +107,37 @@ export async function updateRes(e) { if (!await checkAuth(e)) { return true; } - let command = ""; if (fs.existsSync(`${resPath}/miao-res-plus/`)) { - command = `git -C ${resPath}/miao-res-plus pull`; + e.reply("开始尝试更新,请耐心等待~"); + command = `git -C ${resPath}/miao-res-plus pull`; exec(command, function (error, stdout, stderr) { console.log(stdout); if (/Already up to date/.test(stdout)) { - e.reply("素材已经是最新了~"); + e.reply("目前所有图片都已经是最新了~"); return true; } let numRet = /(\d*) files changed,/.exec(stdout); if (numRet && numRet[1]) { - e.reply(`更新成功,更新${numRet[1]}个素材~`); + e.reply(`报告主人,更新成功,此次更新了${numRet[1]}个图片~`); return true; } if (error) { e.reply("更新失败!\nError code: " + error.code + "\n" + error.stack + "\n 请稍后重试。"); } else { - e.reply("角色图像加量包更新成功~"); + e.reply("图片加量包更新成功~"); } }); } else { command = `git clone https://gitee.com/yoimiya-kokomi/miao-res-plus.git ${resPath}/miao-res-plus/`; + e.reply("开始尝试安装图片加量包,可能会需要一段时间,请耐心等待~"); exec(command, function (error, stdout, stderr) { if (error) { - e.reply("角色图像加量包安装失败!\nError code: " + error.code + "\n" + error.stack + "\n 请稍后重试。"); + e.reply("角色图片加量包安装失败!\nError code: " + error.code + "\n" + error.stack + "\n 请稍后重试。"); } else { - e.reply("角色图像加量包安装成功!您后续也可以通过 #喵喵更新图像 命令来更新图像"); + e.reply("角色图片加量包安装成功!您后续也可以通过 #喵喵更新图像 命令来更新图像"); } }); } - return true; - - } \ No newline at end of file diff --git a/apps/help.js b/apps/help.js new file mode 100644 index 00000000..c35244f9 --- /dev/null +++ b/apps/help.js @@ -0,0 +1,39 @@ +import { Character } from "../components/models.js"; +import { Cfg } from "../components/index.js"; +import { segment } from "oicq"; +import lodash from "lodash"; + +const _path = process.cwd(); +const helpFilePath = `${_path}/plugins/miao-plugin/resources/help/help-list.js`; + +export async function help(e, { render }) { + let bg = Character.getRandomImg('party'); + let helpFile = {}; + + helpFile = await import(`file://${helpFilePath}?version=${new Date().getTime()}`); + + const { helpCfg } = helpFile; + + lodash.forEach(helpCfg, (group) => { + lodash.forEach(group.list, (help) => { + let icon = help.icon * 1; + if (!icon) { + help.css = `display:none`; + } else { + let x = (icon - 1) % 10, y = (icon - x - 1) / 10; + help.css = `background-position:-${x * 50}px -${y * 50}px`; + } + + }) + }); + + let base64 = await render("help", "index", { + helpCfg, + bg, + cfgScale: Cfg.scale(1) + }, "png"); + if (base64) { + e.reply(segment.image(`base64://${base64}`)); + } + return true; +} \ No newline at end of file diff --git a/components/models/Character.js b/components/models/Character.js index 2d980bb5..5baa2134 100644 --- a/components/models/Character.js +++ b/components/models/Character.js @@ -10,6 +10,7 @@ let characterMap = {}; const _path = process.cwd(); let genshin = await import(`file://${_path}/config/genshin/roleId.js`); +const metaPath = `${_path}/plugins/miao-plugin/resources/meta/character/` class Character extends Base { constructor(name, id) { @@ -129,4 +130,16 @@ Character.getAbbr = function () { return genshin.abbr; } +Character.getRandomImg = function (type) { + let chars = fs.readdirSync(metaPath); + let ret = []; + type = type === "party" ? "party" : "profile"; + lodash.forEach(chars, (char) => { + if (fs.existsSync(`${metaPath}/${char}/${type}.png`)) { + ret.push(`/meta/character/${char}/${type}.png`); + } + }); + return lodash.sample(ret); +} + export default Character; diff --git a/index.js b/index.js index 8fa28bdf..48a2b7d2 100644 --- a/index.js +++ b/index.js @@ -1,16 +1,17 @@ import { character, wife, wifeReg } from "./apps/character.js"; import { consStat, abyssPct } from "./apps/stat.js"; import { wiki } from "./apps/wiki.js"; +import { help } from "./apps/help.js"; import lodash from "lodash"; import { rule as adminRule, updateRes, sysCfg } from "./apps/admin.js"; -export { character, wife, consStat, abyssPct, wiki, updateRes, sysCfg }; +export { character, wife, consStat, abyssPct, wiki, updateRes, sysCfg, help }; let rule = { character: { - reg: "^#(.*)?$", + reg: "^#(喵喵)?(.*)?$", describe: "【#刻晴】角色详情", }, wife: { @@ -18,13 +19,16 @@ let rule = { describe: "【#老婆,#老公,#女儿】角色详情", }, consStat: { - reg: "^#角色(持有|持有率|命座|命之座|.命)(分布|统计)?$", + reg: "^#(喵喵)?角色(持有|持有率|命座|命之座|.命)(分布|统计)?$", }, abyssPct: { - reg: "^#深渊(第?.{1,2}层)?(角色)?出场(率|统计)*$", + reg: "^#(喵喵)?深渊(第?.{1,2}层)?(角色)?出场(率|统计)*$", }, wiki: { - reg: "^#.*(天赋|技能|命座|命之座|资料|照片|写真|图片|插画)$", + reg: "^#(喵喵)?.*(天赋|技能|命座|命之座|资料|照片|写真|图片|插画)$", + }, + help: { + reg: "#(喵喵)帮助" }, ...adminRule }; diff --git a/resources/help/bg.jpg b/resources/help/bg.jpg new file mode 100644 index 00000000..6726b9ac Binary files /dev/null and b/resources/help/bg.jpg differ diff --git a/resources/help/header.jpg b/resources/help/header.jpg new file mode 100644 index 00000000..d56f0185 Binary files /dev/null and b/resources/help/header.jpg differ diff --git a/resources/help/header.png b/resources/help/header.png new file mode 100644 index 00000000..a3e89188 Binary files /dev/null and b/resources/help/header.png differ diff --git a/resources/help/help-list.js b/resources/help/help-list.js new file mode 100644 index 00000000..70cd620c --- /dev/null +++ b/resources/help/help-list.js @@ -0,0 +1,117 @@ +export const helpCfg = [{ + group: "游戏信息查询", + list: [{ + icon: 1, + title: "#角色 #角色卡片 #探索", + desc: "你的原神角色数据" + }, { + icon: 64, + title: "#深渊 #深渊12层", + desc: "深渊数据,打完请2小时后查询", + }, { + icon: 61, + title: "#五星 #武器 #今日素材", + desc: "你的原神角色详情数据" + }, { + icon: 62, + title: "#五星列表 #练度统计", + desc: "角色列表数据", + }, { + icon: 58, + title: "#刻晴 #刻晴卡片 #戳一戳", + desc: "你的原神角色详情数据" + }, { + icon: 59, + title: "#老婆 #老公", + desc: "查看老婆、老公" + }] +}, { + group: "个人信息查询及签到", + desc: "需要绑定cookie", + list: [{ + icon: 15, + title: "#体力 #体力帮助", + desc: "查询体力,绑定Cookie帮助" + }, { + icon: 86, + title: "#签到", + desc: "米游社原神签到" + }, { + icon: 5, + title: "#原石 #原石统计", + desc: "札记数据,需要绑定Cookie" + }, { + icon: 10, + title: "#uid #绑定uid+[你的uid]", + desc: "查看绑定的uid 绑定uid" + }, { + icon: 22, + title: "#我的ck #删除ck", + desc: "查看绑定的cookie 删除cookie" + }] +}, { + group: "喵喵扩展 Miao-Plugin", + list: [{ + icon: 60, + title: "#老婆 #老婆设置心海,雷神", + desc: "设置老婆,查看老婆信息卡片" + }, { + icon: 88, + title: "#老婆照片 #甘雨照片", + desc: "查看指定角色的图片" + }, { + icon: 53, + title: "#夜兰天赋 #胡桃命座", + desc: "查看角色的天赋与命座资料" + }, { + icon: 56, + title: "#角色持有率 #深渊出场率", + desc: "查看角色的持有率及深渊出场率信息" + }, { + icon: 32, + title: "#喵喵设置", + desc: "管理员可用:配置喵喵功能" + }, { + icon: 35, + title: "#喵喵更新素材", + desc: "管理员可用:更新增量图像素材包" + }] +}, { + group: "其他查询指令", + list: [{ + icon: 6, + title: "#抽卡记录 #记录帮助", + desc: "统计游戏抽卡数据" + }, { + icon: 21, + title: "#角色统计 #武器统计", + desc: "按卡池统计抽卡数据" + }, { + icon: 8, + title: "十连 十连2 定轨", + desc: "真实模拟抽卡" + }, { + icon: 60, + title: "#心海图鉴 #护摩", + desc: "角色武器图鉴" + }, { + icon: 38, + title: "#圣遗物评分 #刻晴攻略", + desc: "可莉特调评分 西风驿站攻略" + }, { + icon: 74, + title: "添加哈哈 删除哈哈", + desc: "添加表情,回复哈哈触发" + }, { + icon: 79, + title: "#帮助 #版本", + desc: "其他命令" + }] +}, { + group: "管理命令", + list: [{ + icon: 85, + title: "#用户统计", + desc: "查看用户CK-UID列表" + }] +}]; \ No newline at end of file diff --git a/resources/help/icon.png b/resources/help/icon.png index e85e539e..fb15d688 100644 Binary files a/resources/help/icon.png and b/resources/help/icon.png differ diff --git a/resources/help/index.css b/resources/help/index.css new file mode 100644 index 00000000..e31f89da --- /dev/null +++ b/resources/help/index.css @@ -0,0 +1,109 @@ +body { + transform: scale(1); + width: 600px; + background: url("bg.jpg"); +} + +.container { + background: url(header.png) top left no-repeat; + background-size: 100% auto; + width: 600px; +} + +.label { + font-family: Number, "微软雅黑", sans-serif; +} + +.head-box { + margin: 0 0 60px 0; +} + +.cont-box { + border-radius: 15px; + margin-top: 20px; + margin-bottom: 20px; + padding: 5px 15px; + overflow: hidden; + box-shadow: 0 5px 10px 0 rgb(0 0 0 / 15%); + position: relative; + background: rgba(43, 52, 61, 0.8); + +} + +.help-group { + color: #ceb78b; + font-size: 18px; + font-weight: bold; + padding: 5px 0; +} + +.help-table { + text-align: center; + border-collapse: collapse; + margin: 5px -10px -10px -15px; + border-radius: 0 0 10px 10px; + display: table; + overflow: hidden; + width: calc(100% + 30px); + color: #fff; +} + +.help-table .tr { + display: table-row; +} + +.help-table .td, +.help-table .th { + font-size: 14px; + display: table-cell; + box-shadow: 0 0 1px 0 #888 inset; + padding: 9px 0 9px 50px; + line-height: 24px; + position: relative; + width: 50%; + text-align: left; +} + +.help-table .tr:nth-child(odd) { + background: rgba(34, 41, 51, .6) +} + +.help-table .tr:nth-child(even) { + background: rgba(34, 41, 51, .3) +} + +.help-table .tr:last-child .td { + padding-bottom: 12px; +} + +.help-table .th { + background: rgba(34, 41, 51, .5) +} + +.help-icon { + width: 40px; + height: 40px; + display: block; + position: absolute; + background: url("icon.png") 0 0 no-repeat; + background-size: 500px 500px; + border-radius: 5px; + left: 5px; + top: 8px; + transform: scale(0.85); +} + +.help-title { + display: block; + color: #d3bc8e; + font-size: 15px; + line-height: 22px; +} + +.help-desc { + display: block; + font-size: 12px; + line-height: 16px; + color: #eee; +} + diff --git a/resources/help/index.html b/resources/help/index.html new file mode 100644 index 00000000..98107646 --- /dev/null +++ b/resources/help/index.html @@ -0,0 +1,41 @@ + + +
+ + + + + + +