#角色增加配置开关

This commit is contained in:
Kokomi 2023-02-14 04:43:14 +08:00
parent f4353fc5ca
commit 036d61d698
17 changed files with 139 additions and 131 deletions

View File

@ -1,14 +1,18 @@
# 2.2.3 Dev # 2.3.0 Dev
* 【Dev测试分支暂未正式公开预计2.17左右发布】 * `【Dev测试分支开发中】`
* 如需体验可切换至miao-plugin仓库dev分支
* dev功能可能不稳定建议具备一定排错能力的勇士体验
* 2.3.0正式版预计2.19日发布,当然也有可能继续咕...
* 增加`#角色`功能查询并展示Mys角色信息
* Yunzai需要跟随游戏版本升级的功能会在miao-plugin中逐步提供以保障基础功能相对长期可用
* 大部分功能目前默认关闭,可在`#喵喵设置`中启用
* 重写底层面板、角色数据获取与保存逻辑 * 重写底层面板、角色数据获取与保存逻辑
* 底层完全兼容面板及Mys数据对于miao-plugin的大部分场景可做到数据通用 * 底层完全兼容面板及Mys数据对于miao-plugin的大部分场景可做到数据通用
* 角色数据及天赋增加缓存逻辑有缓存数据情况下可在ck失效/验证码等情况下正常使用功能 * 角色数据及天赋增加缓存逻辑有缓存数据情况下可在ck失效/验证码等情况下正常使用大部分功能
* 面板底层数据结构优化Enka下使用statsIds存储圣遗物数据 * 面板底层数据结构及存储逻辑优化,兼容老版本数据
* 初步增加`#角色`功能查询并展示Mys角色信息尚未完善 * Enka服务下使用statsIds存储圣遗物数据能够更精确的计算角色属性
* Yunzai需要跟随游戏版本升级的功能会逐步在miao-plugin中提供以保障对应功能相对长期可用 * 其他功能及界面优化,部分已知问题调整
* 暂时默认关闭,如需开启可在`#喵喵设置`中启用
* 其他功能及界面优化
* `#上传深渊` 界面与样式调整 * `#上传深渊` 界面与样式调整
* `#刷新排名`、`#禁用排名`、`#启用排名`可由群管理员进行管理 * `#刷新排名`、`#禁用排名`、`#启用排名`可由群管理员进行管理

View File

@ -64,7 +64,7 @@ const Wife = {
if (!Common.cfg('avatarPoke')) { if (!Common.cfg('avatarPoke')) {
return false return false
} }
} else if (!Common.cfg('avatarWife')) { } else if (!Common.cfg('avatarCard')) {
return false return false
} }

View File

@ -2,7 +2,7 @@ import { App } from '../components/index.js'
import { profileHelp } from './profile/ProfileCommon.js' import { profileHelp } from './profile/ProfileCommon.js'
import { profileArtisList } from './profile/ProfileArtis.js' import { profileArtisList } from './profile/ProfileArtis.js'
import { profileDetail } from './profile/ProfileDetail.js' import { profileDetail } from './profile/ProfileDetail.js'
import { profileStat } from './profile/ProfileStat.js' import ProfileStat from './profile/ProfileStat.js'
import ProfileList from './profile/ProfileList.js' import ProfileList from './profile/ProfileList.js'
import { uploadCharacterImg, delProfileImg, profileImgList } from './character/ImgUpload.js' import { uploadCharacterImg, delProfileImg, profileImgList } from './character/ImgUpload.js'
import { enemyLv } from './profile/ProfileUtils.js' import { enemyLv } from './profile/ProfileUtils.js'
@ -71,13 +71,13 @@ app.reg({
profileStat: { profileStat: {
rule: /^#(面板|喵喵|角色|武器|天赋|技能|圣遗物)?练度统计$/, rule: /^#(面板|喵喵|角色|武器|天赋|技能|圣遗物)?练度统计$/,
fn: profileStat, fn: ProfileStat.stat,
name: '面板练度统计' name: '面板练度统计'
}, },
avatarList: { avatarList: {
rule: /^(#(角色|查询|查询角色|角色查询|人物)[ |0-9]*$)|(^(#*uid|#*UID)\+*[1|2|5-9][0-9]{8}$)|(^#[\+|]*[1|2|5-9][0-9]{8})/, rule: /^(#(角色|查询|查询角色|角色查询|人物)[ |0-9]*$)|(^(#*uid|#*UID)\+*[1|2|5-9][0-9]{8}$)|(^#[\+|]*[1|2|5-9][0-9]{8})/,
fn: profileStat, fn: ProfileStat.avatarList,
name: '角色查询' name: '角色查询'
}, },

View File

@ -1,77 +1,86 @@
import { Cfg, Common } from '../../components/index.js' import { Cfg, Common } from '../../components/index.js'
import { MysApi, Player, Character } from '../../models/index.js' import { MysApi, Player, Character } from '../../models/index.js'
export async function profileStat (e) { const ProfileStat = {
let isMatch = /^#(面板|喵喵|角色|武器|天赋|技能|圣遗物)练度统计?$/.test(e.original_msg || e.msg || '') async stat (e) {
if (!Cfg.get('profileStat', false) && !isMatch) { let isMatch = /^#(面板|喵喵|角色|武器|天赋|技能|圣遗物)练度统计?$/.test(e.original_msg || e.msg || '')
return false if (!Cfg.get('profileStat', false) && !isMatch) {
return false
}
return await ProfileStat.render(e)
},
async avatarList (e) {
if (!Cfg.get('avatarList', false)) {
return false
}
return await ProfileStat.render(e, true)
},
async render (e, isAvatarList = false) {
// 缓存时间,单位小时
let msg = e.msg.replace('#', '').trim()
if (msg === '角色统计' || msg === '武器统计') {
// 暂时避让一下抽卡分析的关键词
return false
}
let mys = await MysApi.init(e)
if (!mys || !mys.uid) return false
const uid = mys.uid
let player = Player.create(e)
await player.refreshMysInfo()
let avatarRet = await player.refreshAndGetAvatarData({
detail: 1,
talent: 0,
rank: true,
retType: 'array',
sort: true
})
if (avatarRet.length === 0) {
e.reply(`暂未获得#${uid}角色数据请绑定CK或 #更新面板`)
return true
}
let talentNotice = []
if (!mys.isSelfCookie) {
talentNotice.push('未绑定CK信息可能展示不完全')
}
let faceChar = Character.get(player.face || avatarRet[0]?.id)
let face = {
banner: faceChar.imgs?.banner,
face: faceChar.imgs?.face,
name: player.name || `#${uid}`,
sign: player.sign,
level: player.level
}
let info = player.getInfo()
info.stats = info.stats || {}
info.statMap = {
achievement: '成就',
wayPoint: '锚点',
avatar: '角色',
avatar5: '五星角色',
goldCount: '金卡总数'
}
return await Common.render(isAvatarList ? 'character/avatar-list' : 'character/profile-stat', {
save_id: uid,
uid,
info,
updateTime: player.getUpdateTime(),
isSelfCookie: e.isSelfCookie,
talentLvMap: '0,1,1,1,2,2,3,3,3,4,5'.split(','),
face,
avatars: avatarRet,
talentNotice
}, { e, scale: 1.4 })
} }
// 缓存时间,单位小时
let msg = e.msg.replace('#', '').trim()
if (msg === '角色统计' || msg === '武器统计') {
// 暂时避让一下抽卡分析的关键词
return false
}
let isAvatarList = !/练度统计/.test(msg)
let mys = await MysApi.init(e)
if (!mys || !mys.uid) return false
const uid = mys.uid
let player = Player.create(e)
await player.refreshMysInfo()
let avatarRet = await player.refreshAndGetAvatarData({
detail: 1,
talent: 0,
rank: true,
retType: 'array',
sort: true
})
if (avatarRet.length === 0) {
e.reply(`暂未获得#${uid}角色数据请绑定CK或 #更新面板`)
return true
}
let talentNotice = []
if (!mys.isSelfCookie) {
talentNotice.push('未绑定CK信息可能展示不完全')
}
let faceChar = Character.get(player.face || avatarRet[0]?.id)
let face = {
banner: faceChar.imgs?.banner,
face: faceChar.imgs?.face,
name: player.name || `#${uid}`,
sign: player.sign,
level: player.level
}
let info = player.getInfo()
info.stats = info.stats || {}
info.statMap = {
achievement: '成就',
wayPoint: '锚点',
avatar: '角色',
avatar5: '五星角色',
goldCount: '金卡总数'
}
return await Common.render(isAvatarList ? 'character/avatar-list' : 'character/profile-stat', {
save_id: uid,
uid,
info,
updateTime: player.getUpdateTime(),
isSelfCookie: e.isSelfCookie,
talentLvMap: '0,1,1,1,2,2,3,3,3,4,5'.split(','),
face,
avatars: avatarRet,
talentNotice
}, { e, scale: 1.4 })
} }
export default ProfileStat

View File

@ -1,5 +1,5 @@
import lodash from 'lodash' import lodash from 'lodash'
import plugin from './common-lib/plugin.js' import Plugin from './common/Plugin.js'
class App { class App {
constructor (cfg) { constructor (cfg) {
@ -27,7 +27,7 @@ class App {
let rules = [] let rules = []
let check = [] let check = []
let event = cfg.event let event = cfg.event
let cls = class extends plugin { let cls = class extends Plugin {
constructor () { constructor () {
super({ super({
name: `喵喵:${cfg.name || cfg.id}`, name: `喵喵:${cfg.name || cfg.id}`,

View File

@ -1,6 +1,6 @@
import fs from 'fs' import fs from 'fs'
import lodash from 'lodash' import lodash from 'lodash'
import cfgData from './cfg-lib/cfg-data.js' import cfgData from './cfg/CfgData.js'
const _path = process.cwd() const _path = process.cwd()
const _cfgPath = `${_path}/plugins/miao-plugin/components/` const _cfgPath = `${_path}/plugins/miao-plugin/components/`

View File

@ -1,5 +1,5 @@
import Cfg from './Cfg.js' import Cfg from './Cfg.js'
import render from './common-lib/render.js' import render from './common/Render.js'
import { Version } from './index.js' import { Version } from './index.js'
import lodash from 'lodash' import lodash from 'lodash'

View File

@ -1,5 +1,5 @@
import lodash from 'lodash' import lodash from 'lodash'
import Elem from './common-lib/elem.js' import Elem from './common/Elem.js'
import { Cfg } from '../components/index.js' import { Cfg } from '../components/index.js'
let Format = { let Format = {

View File

@ -1,4 +1,39 @@
export const cfgSchema = { export const cfgSchema = {
apps: {
title: 'Yunzai功能开启使用喵喵版功能',
cfg: {
avatarList: {
title: '#角色 #UID',
key: '角色列表',
def: false
},
avatarCard: {
title: '#刻晴 #老婆',
key: '角色卡片',
def: true
},
uploadAbyssData: {
title: '#深渊',
key: '深渊',
def: false
},
profileStat: {
title: '#练度统计',
key: '练度统计',
def: false
},
help: {
title: '#帮助 #菜单',
key: '帮助',
def: false
},
avatarPoke: {
title: '戳一戳展示角色卡片',
key: '戳一戳',
def: true
}
}
},
profile: { profile: {
title: '角色面板相关设置', title: '角色面板相关设置',
cfg: { cfg: {
@ -12,12 +47,6 @@ export const cfgSchema = {
key: '面板替换', key: '面板替换',
def: true def: true
}, },
profileStat: {
title: '面板练度统计',
key: '练度统计',
def: false,
desc: '使用【#面板练度统计】功能取代【#练度统计】功能,默认关闭'
},
groupRank: { groupRank: {
title: '群面板排名', title: '群面板排名',
key: '排名', key: '排名',
@ -63,34 +92,6 @@ export const cfgSchema = {
} }
} }
}, },
char: {
title: '玩家&老婆卡片展示',
cfg: {
avatarCard: {
title: '角色查询',
key: '角色',
def: true,
desc: '使用喵喵版角色卡片作为默认角色卡片功能',
showDesc: false
},
uploadAbyssData: {
title: '上传深渊',
key: '深渊',
def: false,
desc: '使用【#上传深渊】功能取代【#深渊】功能,默认关闭'
},
avatarWife: {
title: '老婆查询',
key: '老婆',
def: true
},
avatarPoke: {
title: '戳一戳卡片',
key: '戳一戳',
def: true
}
}
},
wiki: { wiki: {
title: '角色资料与信息查询', title: '角色资料与信息查询',
cfg: { cfg: {
@ -137,12 +138,6 @@ export const cfgSchema = {
input: (n) => Math.min(200, Math.max(50, (n * 1 || 100))), input: (n) => Math.min(200, Math.max(50, (n * 1 || 100))),
desc: '可选值50~200建议100。设置高精度会提高图片的精细度但因图片较大可能会影响渲染与发送速度' desc: '可选值50~200建议100。设置高精度会提高图片的精细度但因图片较大可能会影响渲染与发送速度'
}, },
help: {
title: '喵喵作为默认帮助',
key: '帮助',
def: false,
desc: '开启后将使用喵喵版帮助作为Yunzai的默认帮助默认关闭'
},
commaGroup: { commaGroup: {
title: '数字逗号分组', title: '数字逗号分组',
key: '逗号', key: '逗号',

View File

@ -19,7 +19,7 @@
<div class="cfg-line"> <div class="cfg-line">
{{cfgItem.title}} {{cfgItem.title}}
<span class="cfg-hint"> #喵喵设置{{cfgItem.key}} <span class="cfg-hint"> #喵喵设置{{cfgItem.key}}
{{if cfgItem.type==='num'}} {{cfgItem.def}}{{else}} + 开启/关闭{{/if}} {{if cfgItem.type==='num'}} {{cfgItem.def}}{{else}} 开启/关闭{{/if}}
</span> </span>
{{if cfgItem.type === 'num'}} {{if cfgItem.type === 'num'}}
<div class="cfg-status">{{cfg[cfgKey]}}</div> <div class="cfg-status">{{cfg[cfgKey]}}</div>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 854 KiB

After

Width:  |  Height:  |  Size: 839 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 170 KiB

After

Width:  |  Height:  |  Size: 348 KiB

View File

@ -275,4 +275,4 @@ let eta = {
迪希雅: '2023-03-01', 迪希雅: '2023-03-01',
米卡: '2023-03-01' 米卡: '2023-03-01'
} }
await down('艾尔海森,珐露珊,莱依拉,流浪者,纳西妲,瑶瑶', true) await down('迪希雅,米卡', true)