From 54011f93102b5214f92f1094510435b4b2774b3e Mon Sep 17 00:00:00 2001 From: yoimiya-kokomi <592981798@qq.com> Date: Sun, 18 Sep 2022 05:24:04 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8B=86=E5=88=86character=E8=A7=92=E8=89=B2?= =?UTF-8?q?=E5=8D=A1=E7=89=87=E5=8F=8Aprofile=E8=A7=92=E8=89=B2=E9=9D=A2?= =?UTF-8?q?=E6=9D=BF=20=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 14 ++++- apps/character.js | 127 +++------------------------------------ apps/index.js | 8 ++- apps/poke.js | 2 +- apps/profile.js | 147 ++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 171 insertions(+), 127 deletions(-) create mode 100644 apps/profile.js diff --git a/CHANGELOG.md b/CHANGELOG.md index e8a86d09..cf660fba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,15 @@ -# 2.0 Alpha.1 +# 2.0 Alpha.2 -* 内部版本,底层架构升级 -* 稳定前不会增加新功能,暂不建议更新 +* `#深渊配队`、`#戳一戳` 适配V3 +* 优化V3下获取Uid及CK的逻辑,防止一些情况下触发报错 + +# Alpha 2.0.0 + +* 底层架构升级,以V3为主要版本,V2做兼容处理 +* 内部测试版本,可能存在稳定性问题,喵喵升级不会升级此版本 +* Alpha版本预计持续一周左右,完成后正式升级 **2.0.0** +* 若需协助测试可手工切换**miao-plugin**至**2.0.0 Branch** +* 注意:`若不熟悉Git不建议进行操作防止出现异常情况,建议等待正式版 >_<` # 1.10.1~1.10.6 diff --git a/apps/character.js b/apps/character.js index 324655b8..3d8a1a46 100644 --- a/apps/character.js +++ b/apps/character.js @@ -1,30 +1,22 @@ import { Common, Cfg, App } from '../components/index.js' import { Character } from '../models/index.js' import { renderAvatar } from './character/avatar-card.js' -import { getTargetUid, getProfile, profileHelp, inputProfile } from './character/profile-common.js' -import { profileArtis, profileArtisList } from './character/profile-artis.js' -import { renderProfile } from './character/profile-detail.js' // 角色图像上传 import { uploadCharacterImg } from './character/character-img-upload.js' -// 面板练度统计 -import { profileStat } from './character/profile-stat.js' - -// 面板角色列表 -import { profileList } from './character/profile-list.js' - // 老婆 -import { wife, pokeWife, wifeReg } from './character/avatar-wife.js' +import { wife, wifeReg } from './character/avatar-wife.js' -import { enemyLv, getOriginalPicture } from './character/utils.js' +import { getOriginalPicture } from './character/utils.js' let app = App.init({ id: 'character', name: '角色查询' }) + app.reg('character', character, { - rule: /^(#(.*)|#*(更新|录入)?(.*)(详细|详情|面板|面版|伤害[1-7]?)(更新)?)$/, - name: '角色查询' + rule: /^#.+$/, + name: '角色卡片' }) app.reg('upload-img', uploadCharacterImg, { @@ -32,27 +24,6 @@ app.reg('upload-img', uploadCharacterImg, { name: '上传角色写真' }) -app.reg('artis-list', profileArtisList, { - rule: /^#圣遗物列表\s*(\d{9})?$/, - name: '面板圣遗物列表' -}) - -app.reg('profile-list', profileList, { - rule: /^#(面板角色|角色面板|面板)(列表)?\s*(\d{9})?$/, - name: '面板角色列表', - desc: '查看当前已获取面板数据的角色列表' -}) - -app.reg('profile-stat', profileStat, { - rule: /^#面板练度统计$/, - name: '面板练度统计$' -}) - -app.reg('profile-help', profileHelp, { - rule: /^#角色面板帮助$/, - name: '角色面板帮助' -}) - app.reg('wife', wife, { rule: wifeReg, describe: '#老公 #老婆 查询' @@ -63,16 +34,6 @@ app.reg('original-pic', getOriginalPicture, { describe: '【#原图】 回复角色卡片,可获取原图' }) -app.reg('enemy-lv', enemyLv, { - rule: /^#(敌人|怪物)等级\s*\d{1,3}\s*$/, - describe: '【#角色】 设置伤害计算中目标敌人的等级' -}) - -app.reg('profile-refresh', getProfile, { - rule: /^#(全部面板更新|更新全部面板|获取游戏角色详情|更新面板|面板更新)\s*(\d{9})?$/, - describe: '【#角色】 获取游戏橱窗详情数据' -}) - export default app // 查看当前角色 @@ -82,95 +43,21 @@ export async function character (e) { return } - let mode = 'card' let uidRet = /[0-9]{9}/.exec(msg) if (uidRet) { e.uid = uidRet[0] msg = msg.replace(uidRet[0], '') } let name = msg.replace(/#|老婆|老公/g, '').trim() - msg = msg.replace('面版', '面板') - let dmgRet = /伤害(\d?)$/.exec(name) - let dmgIdx = 0 - if (/(详情|详细|面板|面版)\s*$/.test(msg) && !/更新|录入|输入/.test(msg)) { - mode = 'profile' - name = name.replace(/(详情|详细|面板)/, '').trim() - } else if (dmgRet) { - mode = 'dmg' - name = name.replace(/伤害[0-5]?/, '').trim() - if (dmgRet[1]) { - dmgIdx = dmgRet[1] * 1 - } - } else if (/(详情|详细|面板)更新$/.test(msg) || (/更新/.test(msg) && /(详情|详细|面板)$/.test(msg))) { - mode = 'refresh' - name = name.replace(/详情|详细|面板|更新/g, '').trim() - } else if (/(录入|输入)/.test(msg) && /(详情|详细|面板)/.test(msg)) { - mode = 'input' - let nameRet = /(?:录入|输入)(.+)(?:面板|详细|详情|数据)+/.exec(name) - if (nameRet) { - name = nameRet[1] - e.inputData = msg.replace(nameRet[0], '') - } - name = name.replace(/录入|输入|详情|详细|面板|数据|[0-9]|\.|\+/g, '').trim() - } else if (/圣遗物/.test(msg)) { - mode = 'artis' - name = name.replace('圣遗物', '').trim() - } - if (mode === 'card' && Common.isDisable(e, 'char.char')) { + if (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.trim()) if (!char) { return false } - - if (mode === 'card') { - return renderAvatar(e, char.name) - } - - let uid = await getTargetUid(e) - if (!uid) { - return true - } - e.uid = uid - e.avatar = char.id - - if (char.isCustom) { - e.reply('自定义角色暂不支持此功能') - return true - } - - if (mode === 'profile' || mode === 'dmg') { - return renderProfile(e, char, mode, { dmgIdx }) - } else if (mode === 'input') { - await inputProfile(e, mode) - return true - } else if (mode === 'refresh') { - await getProfile(e) - return true - } else if (mode === 'artis') { - return profileArtis(e) - } - return true + return renderAvatar(e, char.name) } diff --git a/apps/index.js b/apps/index.js index 787bbe11..66914454 100644 --- a/apps/index.js +++ b/apps/index.js @@ -1,9 +1,10 @@ -import help from './help.js' import character from './character.js' -import admin from './admin.js' +import profile from './profile.js' import stat from './stat.js' import wiki from './wiki.js' import poke from './poke.js' +import help from './help.js' +import admin from './admin.js' export const characterApp = character.v2App() export const adminApp = admin.v2App() @@ -11,8 +12,9 @@ export const helpApp = help.v2App() export const statApp = stat.v2App() export const wikiApp = wiki.v2App() export const pokeApp = poke.v2App() +export const profileApp = profile.v2App() -let apps = { character, admin, help, stat, wiki, poke } +let apps = { character, admin, help, stat, wiki, poke, profile } let rule = {} // v2 let rules = {} // v3 for (let key in apps) { diff --git a/apps/poke.js b/apps/poke.js index ec03535c..051364f7 100644 --- a/apps/poke.js +++ b/apps/poke.js @@ -3,7 +3,7 @@ import { pokeWife } from './character/avatar-wife.js' let app = App.init({ id: 'poke', - name: '角色查询', + name: '戳一戳', event: 'poke' }) diff --git a/apps/profile.js b/apps/profile.js new file mode 100644 index 00000000..38d255ba --- /dev/null +++ b/apps/profile.js @@ -0,0 +1,147 @@ +import { Common, Cfg, App } from '../components/index.js' +import { Character } from '../models/index.js' +import { getTargetUid, getProfile, profileHelp, inputProfile } from './character/profile-common.js' +import { profileArtis, profileArtisList } from './character/profile-artis.js' +import { renderProfile } from './character/profile-detail.js' + +// 面板练度统计 +import { profileStat } from './character/profile-stat.js' + +// 面板角色列表 +import { profileList } from './character/profile-list.js' + +import { enemyLv } from './character/utils.js' + +let app = App.init({ + id: 'profile', + name: '角色面板' +}) +app.reg('profile-detail', profileDetail, { + rule: /^#*(更新|录入)?(.+)(详细|详情|面板|面版|圣遗物|伤害[1-7]?)(更新)?$/, + name: '角色面板' +}) + +app.reg('artis-list', profileArtisList, { + rule: /^#圣遗物列表\s*(\d{9})?$/, + name: '面板圣遗物列表' +}) + +app.reg('profile-list', profileList, { + rule: /^#(面板角色|角色面板|面板)(列表)?\s*(\d{9})?$/, + name: '面板角色列表', + desc: '查看当前已获取面板数据的角色列表' +}) + +app.reg('profile-stat', profileStat, { + rule: /^#面板练度统计$/, + name: '面板练度统计$' +}) + +app.reg('profile-help', profileHelp, { + rule: /^#角色面板帮助$/, + name: '角色面板帮助' +}) + +app.reg('enemy-lv', enemyLv, { + rule: /^#(敌人|怪物)等级\s*\d{1,3}\s*$/, + describe: '【#角色】 设置伤害计算中目标敌人的等级' +}) + +app.reg('profile-refresh', getProfile, { + rule: /^#(全部面板更新|更新全部面板|获取游戏角色详情|更新面板|面板更新)\s*(\d{9})?$/, + describe: '【#角色】 获取游戏橱窗详情数据' +}) + +export default app + +// 查看当前角色 +export async function profileDetail (e) { + let msg = e.original_msg || e.msg + if (!msg) { + return + } + + let mode = 'profile' + let uidRet = /[0-9]{9}/.exec(msg) + if (uidRet) { + e.uid = uidRet[0] + msg = msg.replace(uidRet[0], '') + } + let name = msg.replace(/#|老婆|老公/g, '').trim() + msg = msg.replace('面版', '面板') + let dmgRet = /伤害(\d?)$/.exec(name) + let dmgIdx = 0 + if (/(详情|详细|面板|面版)\s*$/.test(msg) && !/更新|录入|输入/.test(msg)) { + mode = 'profile' + name = name.replace(/(详情|详细|面板)/, '').trim() + } else if (dmgRet) { + mode = 'dmg' + name = name.replace(/伤害[0-5]?/, '').trim() + if (dmgRet[1]) { + dmgIdx = dmgRet[1] * 1 + } + } else if (/(详情|详细|面板)更新$/.test(msg) || (/更新/.test(msg) && /(详情|详细|面板)$/.test(msg))) { + mode = 'refresh' + name = name.replace(/详情|详细|面板|更新/g, '').trim() + } else if (/(录入|输入)/.test(msg) && /(详情|详细|面板)/.test(msg)) { + mode = 'input' + let nameRet = /(?:录入|输入)(.+)(?:面板|详细|详情|数据)+/.exec(name) + if (nameRet) { + name = nameRet[1] + e.inputData = msg.replace(nameRet[0], '') + } + name = name.replace(/录入|输入|详情|详细|面板|数据|[0-9]|\.|\+/g, '').trim() + } else if (/圣遗物/.test(msg)) { + mode = 'artis' + name = name.replace('圣遗物', '').trim() + } + + if (!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.trim()) + + if (!char) { + return false + } + + let uid = await getTargetUid(e) + if (!uid) { + return true + } + e.uid = uid + e.avatar = char.id + + if (char.isCustom) { + e.reply('自定义角色暂不支持此功能') + return true + } + + if (mode === 'profile' || mode === 'dmg') { + return renderProfile(e, char, mode, { dmgIdx }) + } else if (mode === 'input') { + await inputProfile(e, mode) + return true + } else if (mode === 'refresh') { + await getProfile(e) + return true + } else if (mode === 'artis') { + return profileArtis(e) + } + return true +}