From 5394a429df6d435bc8f65d9fc4a80b6dc19ce896 Mon Sep 17 00:00:00 2001 From: yoimiya-kokomi <592981798@qq.com> Date: Thu, 7 Jul 2022 06:12:05 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=88=B3=E4=B8=80=E6=88=B3?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E5=96=B5=E5=96=B5=E7=89=88=E8=A7=92=E8=89=B2?= =?UTF-8?q?=E5=8D=A1=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 22 ++++++------- apps/admin.js | 2 ++ apps/character.js | 2 +- apps/character/avatar-card.js | 2 +- apps/character/avatar-wife.js | 61 +++++++++++++++++++++++------------ index.js | 5 +++ resources/admin/index.html | 7 ++++ 7 files changed, 66 insertions(+), 35 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 097aeb69..fe100615 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,27 +1,25 @@ -# 1.8.4 +# 1.8.5 + +* 支持戳一戳返回喵喵版角色卡片 + * 需要使用喵喵分支Yunzai以支持此能力,如需切换可在Yunzai跟目录输入下方命令后更新重启 + * `git remote set-url origin https://gitee.com/yoimiya-kokomi/Yunzai-Bot` + * 可通过`#喵喵设置` 关闭戳一戳 +* 增加鹿野院平藏的角色图片 + +# 1.8.1~1.8.4 * 新增`#上传深渊数据`命令 * 可上传自己角色的深渊挑战数据及角色列表,不会上传其他信息 * 上传数据用于`#角色持有率 #深渊出场率`等统计,可使统计更加及时准确 * 数据统计及服务来自SG团队胡桃API -* 新增角色 派蒙、瑶瑶、白术、伐难、应达、散兵、女士、萍儿 的角色配置及图片 - -# 1.8.3 - * `#刻晴` 角色卡片功能升级 * `#老婆设置刻晴,心海`不再检查是否具有角色或展示在米游社展柜 * `#刻晴` 角色卡片优先使用面板数据进行展示,无面板数据时使用米游社数据 * 在未能获取到角色数据时也会展示角色卡片 - * 角色卡片后续会进行样式升级,按需展示更多内容 * 支持定义新角色及别名 - * 新增角色 派蒙、瑶瑶、白术、伐难、散兵 的角色配置及图片 + * 新增角色 派蒙、瑶瑶、白术、伐难、应达、散兵、女士、萍儿 的角色配置及图片 * 自定义角色可使用`#派蒙` `#派蒙图片`触发图片查看,`#女儿设置派蒙`进行设置。后续会支持更多场景 * 如需扩展可在喵喵config/character.js中定义 -* `#深渊出场率`增加楼层排序,以防止服务侧数据乱序导致顺序错乱 -* B服面板的天赋与皇冠信息现在可以正确的展示了 - -# 1.8.1~1.8.2 - * `#喵喵帮助`增加对自定义配置文件的支持 * 已有配置文件可更名为help-cfg.js,防止后续更新冲突,后续会支持更多配置项 * 在默认配置中增加部分新帮助命令 diff --git a/apps/admin.js b/apps/admin.js index 5c4f3bb1..c768626a 100644 --- a/apps/admin.js +++ b/apps/admin.js @@ -13,6 +13,7 @@ let cfgMap = { "角色": "char.char", "面板": "char.profile-data", "老婆": "char.wife", + "戳一戳": "char.poke", "小清新": "char.se", "查他人": "char.queryOther", "图鉴": "wiki.wiki", @@ -90,6 +91,7 @@ export async function sysCfg(e, { render }) { chars: getStatus("char.char"), profile: getStatus("char.profile-data"), wife: getStatus("char.wife"), + poke: getStatus("char.poke"), se: getStatus("char.se", false), other: getStatus("char.queryOther"), wiki: getStatus("wiki.wiki"), diff --git a/apps/character.js b/apps/character.js index 188bb53f..3a94c14f 100644 --- a/apps/character.js +++ b/apps/character.js @@ -18,7 +18,7 @@ export { getProfileAll, getProfile, profileHelp }; export { profileArtisList } from "./character/profile-artis.js"; // 老婆 -export { wife, wifeReg } from "./character/avatar-wife.js"; +export { wife, pokeWife, wifeReg } from "./character/avatar-wife.js"; import { Character } from "../components/models.js"; diff --git a/apps/character/avatar-card.js b/apps/character/avatar-card.js index 3f8d3162..c0d392b9 100644 --- a/apps/character/avatar-card.js +++ b/apps/character/avatar-card.js @@ -95,7 +95,7 @@ async function renderCard(e, avatar, render, renderType = "card") { // 如果消息发送成功,就将message_id和图片路径存起来,1小时过期 await redis.set(`miao:original-picture:${msgRes.message_id}`, bg.img, { EX: 3600 }); } - return msgRes; + return true; } return true; } diff --git a/apps/character/avatar-wife.js b/apps/character/avatar-wife.js index aee15643..ea2a837d 100644 --- a/apps/character/avatar-wife.js +++ b/apps/character/avatar-wife.js @@ -37,15 +37,22 @@ export const wifeReg = `^#?\\s*(${relation.join("|")})\\s*(设置|选择|指定| export async function wife(e, { render, User }) { let msg = e.msg || ""; - if (!msg) return false; + if (!msg && !e.isPoke) return false; - if (Cfg.isDisable(e, "char.wife")) { + if (e.isPoke) { + if (Cfg.isDisable(e, "char.poke")) { + return false; + } + } else if (Cfg.isDisable(e, "char.wife")) { return false; } let msgRet = (new RegExp(wifeReg)).exec(msg); - if (!msgRet) return false; - + if (e.isPoke) { + msgRet = []; + } else if (!msgRet) { + return false; + } let target = msgRet[1], action = msgRet[2] || "卡片", actionParam = msgRet[3] || ""; @@ -58,7 +65,7 @@ export async function wife(e, { render, User }) { cfg.key = key; return cfg.keyword.includes(target); }); - if (!targetCfg) return true; + if (!targetCfg && !e.isPoke) return true; let avatarList = [], avatar = {}, wifeList = []; @@ -87,30 +94,38 @@ export async function wife(e, { render, User }) { // 展示老婆卡片 // 如果选择过,则进行展示 - wifeList = await selfUser.getCfg(`wife.${targetCfg.key}`, []); let renderType = action === "卡片" ? "card" : "photo"; - // 存在设置 - if (wifeList && wifeList.length > 0 && isSelf) { - if (wifeList[0] === "随机") { - // 如果选择为全部,则从列表中随机选择一个 - avatarList = await getAvatarList(e, targetCfg.type, MysApi); - let avatar = lodash.sample(avatarList); - return renderAvatar(e, avatar, render, renderType); - } else { - // 如果指定过,则展示指定角色 - return renderAvatar(e, lodash.sample(wifeList), render, renderType); + if (!e.isPoke) { + wifeList = await selfUser.getCfg(`wife.${targetCfg.key}`, []); + // 存在设置 + if (wifeList && wifeList.length > 0 && isSelf && !e.isPoke) { + if (wifeList[0] === "随机") { + // 如果选择为全部,则从列表中随机选择一个 + avatarList = await getAvatarList(e, targetCfg.type, MysApi); + let avatar = lodash.sample(avatarList); + return renderAvatar(e, avatar, render, renderType); + } else { + // 如果指定过,则展示指定角色 + return renderAvatar(e, lodash.sample(wifeList), render, renderType); + } + } + } + // 如果未指定过,则从列表中排序并随机选择前5个 + if (e.isPoke) { + avatarList = await getAvatarList(e, false, MysApi); + if (avatarList && avatarList.length > 0) { + avatar = lodash.sample(avatarList); + return await renderAvatar(e, avatar, render, renderType); } } else { - // 如果未指定过,则从列表中排序并随机选择前5个 avatarList = await getAvatarList(e, targetCfg.type, MysApi); if (avatarList && avatarList.length > 0) { avatar = lodash.sample(avatarList.slice(0, 5)); - return renderAvatar(e, avatar, render, renderType); - } else { - e.reply(`在当前米游社公开展示的角色中未能找到适合展示的角色..`); - return true; + return await renderAvatar(e, avatar, render, renderType); } } + e.reply(`在当前米游社公开展示的角色中未能找到适合展示的角色..`); + return true; break; case "设置": case "选择": @@ -167,4 +182,8 @@ export async function wife(e, { render, User }) { break; } return true; +} + +export async function pokeWife(e, components) { + return await wife(e, components); } \ No newline at end of file diff --git a/index.js b/index.js index c311ffac..8f0a635f 100644 --- a/index.js +++ b/index.js @@ -2,6 +2,7 @@ export { character, getProfile, wife, + pokeWife, enemyLv, profileArtisList, getProfileAll, @@ -63,6 +64,10 @@ let rule = { reg: wifeReg, describe: "【#角色】#老公 #老婆 查询", }, + pokeWife: { + reg: "#poke#", + describe: "【#角色】戳一戳", + }, getOriginalPicture: { reg: "^#?(获取|给我|我要|求|发|发下|发个|发一下)?原图(吧|呗)?$", describe: "【#原图】 回复角色卡片,可获取原图", diff --git a/resources/admin/index.html b/resources/admin/index.html index f5559fbd..e1edf879 100644 --- a/resources/admin/index.html +++ b/resources/admin/index.html @@ -34,6 +34,13 @@ {{@wife}} +