群内排名功能发布,默认关闭,请根据群友心理素质自行决定是否开启

* `#刻晴排行` 命令会触发排行更新,防止部分排行错位
* `#喵喵设置` 部分配置项及功能改进
* 其余一些已知问题修正及改进
This commit is contained in:
Kokomi 2022-11-13 05:35:46 +08:00
parent 53c88dbd82
commit 3a2c672aed
18 changed files with 375 additions and 315 deletions

View File

@ -1,13 +1,18 @@
# 2.0.7 # 2.0.8
* 增加群内排名功能 **暂未完全稳定,稳定后会开放配置开关** * 增加群内排名功能
* 默认关闭,如需启用可通过`#喵喵设置排名开启`进行打开
* 统计为bot本地统计只统计在群内主动查看过的面板数据 * 统计为bot本地统计只统计在群内主动查看过的面板数据
* 统计自本次更新后开始记录,历史数据不会回溯
* 可通过`#面板`、`#心海面板`、`#更新面板`等命令来触发排名数据更新 * 可通过`#面板`、`#心海面板`、`#更新面板`等命令来触发排名数据更新
* 增加`#最强雷神`、`#最高分甘雨`命令,查看当前统计中最高练度/最高圣遗物评分的面板数据 * 增加排名相关命令
* 增加`#重置排名`、`#重置刻晴排名`命令,来重置当前群的排名统计 * 增加`#最强雷神`、`#最高分甘雨`命令,查看当前统计中最高练度/最高圣遗物评分的面板数据
* 增加`#雷神排名`、`#甘雨圣遗物排名`命令,查看当前群中角色的排名数据
* 增加`#重置排名`、`#重置刻晴排名`命令,来重置当前群的排名统计
* `#喵喵设置` 部分配置项及功能改进
* 删除一些无效或暂不支持的配置项
* 配置存储位置变更为**config/cfg.js**。原设置会自动迁移
# 2.0.1~2.0.6 # 2.0.1~2.0.7
* `#日历` 页面样式微调,功能升级 * `#日历` 页面样式微调,功能升级
* 日历中会展示角色生日 * 日历中会展示角色生日

View File

@ -4,27 +4,14 @@ import { exec } from 'child_process'
import { Cfg, Common, Data, App } from '../components/index.js' import { Cfg, Common, Data, App } from '../components/index.js'
import { MysApi } from '../models/index.js' import { MysApi } from '../models/index.js'
let cfgMap = { let keys = lodash.map(Cfg.getCfgSchemaMap(), (i) => i.key)
角色: 'char.char',
面板: 'char.profile',
老婆: 'char.wife',
戳一戳: 'char.poke',
小清新: 'char.se',
查他人: 'char.queryOther',
图鉴: 'wiki.wiki',
图片: 'wiki.pic',
统计: 'wiki.stat',
深渊: 'wiki.abyss',
渲染: 'sys.scale',
帮助: 'sys.help'
}
let app = App.init({ let app = App.init({
id: 'admin', id: 'admin',
name: '喵喵设置', name: '喵喵设置',
desc: '喵喵设置' desc: '喵喵设置'
}) })
let sysCfgReg = new RegExp(`^#喵喵设置\\s*(${lodash.keys(cfgMap).join('|')})?\\s*(.*)$`) let sysCfgReg = new RegExp(`^#喵喵设置\\s*(${keys.join('|')})?\\s*(.*)$`)
app.reg('update-res', updateRes, { app.reg('update-res', updateRes, {
rule: /^#喵喵(强制)?(更新图像|图像更新)$/, rule: /^#喵喵(强制)?(更新图像|图像更新)$/,
@ -38,10 +25,6 @@ app.reg('sys-cfg', sysCfg, {
rule: sysCfgReg, rule: sysCfgReg,
desc: '【#管理】系统设置' desc: '【#管理】系统设置'
}) })
app.reg('profile-cfg', profileCfg, {
rule: /^#喵喵面板(?:设置)?.*/,
desc: '面板设置'
})
export default app export default app
@ -65,6 +48,7 @@ async function sysCfg (e) {
let cfgReg = sysCfgReg let cfgReg = sysCfgReg
let regRet = cfgReg.exec(e.msg) let regRet = cfgReg.exec(e.msg)
let cfgSchemaMap = Cfg.getCfgSchemaMap()
if (!regRet) { if (!regRet) {
return true return true
@ -74,48 +58,27 @@ async function sysCfg (e) {
// 设置模式 // 设置模式
let val = regRet[2] || '' let val = regRet[2] || ''
let cfgKey = cfgMap[regRet[1]] let cfgSchema = cfgSchemaMap[regRet[1]]
if (cfgKey === 'sys.scale') { if (cfgSchema.input) {
val = Math.min(200, Math.max(50, val * 1 || 100)) val = cfgSchema.input(val)
} else { } else {
val = !/关闭/.test(val) val = !/关闭/.test(val)
} }
Cfg.set(cfgSchema.cfgKey, val)
if (cfgKey) {
Cfg.set(cfgKey, val)
}
} }
let cfg = { let schema = Cfg.getCfgSchema()
chars: getStatus('char.char'), let cfg = Cfg.getCfg()
profile: getStatus('char.profile'), let imgPlus = fs.existsSync(plusPath)
wife: getStatus('char.wife'),
poke: getStatus('char.poke'),
se: getStatus('char.se', false),
other: getStatus('char.queryOther'),
wiki: getStatus('wiki.wiki'),
pic: getStatus('wiki.pic'),
stat: getStatus('wiki.stat'),
abyss: getStatus('wiki.abyss', false),
imgPlus: fs.existsSync(plusPath),
help: getStatus('sys.help', false),
scale: Cfg.get('sys.scale', 100)
}
// 渲染图像 // 渲染图像
return await Common.render('admin/index', { return await Common.render('admin/index', {
...cfg schema,
cfg,
imgPlus
}, { e, scale: 1.4 }) }, { e, scale: 1.4 })
} }
const getStatus = function (rote, def = true) {
if (Cfg.get(rote, def)) {
return '<div class="cfg-status" >已开启</div>'
} else {
return '<div class="cfg-status status-off">已关闭</div>'
}
}
async function updateRes (e) { async function updateRes (e) {
if (!await checkAuth(e)) { if (!await checkAuth(e)) {
return true return true
@ -208,63 +171,3 @@ async function updateMiaoPlugin (e) {
}) })
return true return true
} }
async function profileCfg (e) {
if (!await checkAuth(e)) {
return true
}
let keyMap = {
好友: 'friend',
: 'group',
陌生人: 'stranger'
}
let regRet = /喵喵面板(?:设置)?\s*(好友|群|群聊|陌生人)?\s*(\d*)\s*(开启|关闭|删除)?\s*$/.exec(e.msg)
if (!regRet) {
return false
}
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 true
}
cfg.groups.push({
group,
idx: idx + 1,
status: getStatus(`profile.groups.${group}.status`, true)
})
})
// 渲染图像
return await Common.render('admin/profile', {
...cfg
}, { e, scale: 1.4 })
}

View File

@ -46,7 +46,9 @@ function checkCharacter (e) {
if (!msg || !/^#/.exec(msg)) { if (!msg || !/^#/.exec(msg)) {
return false return false
} }
if (!Common.cfg('avatarCard')) {
return false
}
let uidRet = /[0-9]{9}/.exec(msg) let uidRet = /[0-9]{9}/.exec(msg)
if (uidRet) { if (uidRet) {
e.uid = uidRet[0] e.uid = uidRet[0]
@ -54,10 +56,6 @@ function checkCharacter (e) {
} }
let name = msg.replace(/#|老婆|老公|卡片/g, '').trim() let name = msg.replace(/#|老婆|老公|卡片/g, '').trim()
if (Common.isDisable(e, 'char.char')) {
return false
}
let char = Character.get(name.trim()) let char = Character.get(name.trim())
if (!char) { if (!char) {

View File

@ -44,7 +44,7 @@ async function renderCard (e, ds, renderType = 'card') {
if (!char) { if (!char) {
return false return false
} }
let bg = char.getCardImg(Cfg.get('char.se', false)) let bg = char.getCardImg(Cfg.get('charPicSe', false))
if (renderType === 'photo') { if (renderType === 'photo') {
e.reply(segment.image(process.cwd() + '/plugins/miao-plugin/resources/' + bg.img)) e.reply(segment.image(process.cwd() + '/plugins/miao-plugin/resources/' + bg.img))
return true return true

View File

@ -1,6 +1,6 @@
// #老婆 // #老婆
import lodash from 'lodash' import lodash from 'lodash'
import { Cfg } from '../../components/index.js' import { Common } from '../../components/index.js'
import { Character, MysApi } from '../../models/index.js' import { Character, MysApi } from '../../models/index.js'
import { getAvatarList, renderAvatar } from './AvatarCard.js' import { getAvatarList, renderAvatar } from './AvatarCard.js'
@ -39,10 +39,10 @@ export async function wife (e) {
if (!msg && !e.isPoke) return false if (!msg && !e.isPoke) return false
if (e.isPoke) { if (e.isPoke) {
if (Cfg.isDisable(e, 'char.poke')) { if (!Common.cfg('avatarPoke')) {
return false return false
} }
} else if (Cfg.isDisable(e, 'char.wife')) { } else if (!Common.cfg('avatarWife')) {
return false return false
} }

View File

@ -7,8 +7,7 @@ export async function groupRank (e) {
if (!groupId) { if (!groupId) {
return false return false
} }
const cfg = await Data.importCfg('cfg') const groupRank = Common.cfg('groupRank')
const groupRank = cfg?.diyCfg?.groupRank || false
let msg = e.original_msg || e.msg let msg = e.original_msg || e.msg
let type = '' let type = ''
if (/(排名|排行|列表)/.test(msg)) { if (/(排名|排行|列表)/.test(msg)) {
@ -36,14 +35,23 @@ export async function groupRank (e) {
return await renderProfile(e, char) return await renderProfile(e, char)
} else { } else {
if (mode === 'dmg' && !ProfileDmg.dmgRulePath(char.name)) { if (mode === 'dmg' && !ProfileDmg.dmgRulePath(char.name)) {
e.reply(`${char.name}暂不支持伤害计算..`) e.reply(`暂无排名:${char.name}暂不支持伤害计算,无法进行排名..`)
} else { } else {
e.reply('暂无排名信息') e.reply('暂无排名:请通过【#面板】查看角色面板以更新排名信息...')
} }
} }
} else if (type === 'list') { } else if (type === 'list') {
let uids = await ProfileRank.getGroupUidList(groupId, char.id, mode) if (mode === 'dmg' && !ProfileDmg.dmgRulePath(char.name)) {
return renderCharRankList({ e, uids, char, mode, groupId }) e.reply(`暂无排名:${char.name}暂不支持伤害计算,无法进行排名..`)
} else {
let uids = await ProfileRank.getGroupUidList(groupId, char.id, mode)
if (uids.length > 0) {
return renderCharRankList({ e, uids, char, mode, groupId })
} else {
e.reply('暂无排名:请通过【#面板】查看角色面板以更新排名信息...')
}
}
return true
} }
} }
@ -75,18 +83,21 @@ export async function resetRank (e) {
async function renderCharRankList ({ e, uids, char, mode, groupId }) { async function renderCharRankList ({ e, uids, char, mode, groupId }) {
let list = [] let list = []
for (let ds of uids) { for (let ds of uids) {
let uid = ds.value let uid = ds.value
let profile = Profile.get(uid, char.id) let profile = Profile.get(uid, char.id)
if (profile) { if (profile) {
let mark = profile.getArtisMark(false) let profileRank = await ProfileRank.create({ groupId, uid })
let data = await profileRank.getRank(profile, true)
let mark = data?.mark?.data
let avatar = new Avatar(profile, uid) let avatar = new Avatar(profile, uid)
let tmp = { let tmp = {
uid, uid,
...avatar.getData('id,star,name,sName,level,fetter,cons,weapon,elem,talent,artisSet,imgs'), ...avatar.getData('id,star,name,sName,level,fetter,cons,weapon,elem,talent,artisSet,imgs'),
artisMark: Data.getData(mark, 'mark,markClass') artisMark: Data.getData(mark, 'mark,markClass')
} }
let dmg = await profile.calcDmg({ mode: 'single' }) let dmg = data?.dmg?.data
if (dmg && dmg.avg) { if (dmg && dmg.avg) {
let title = dmg.title let title = dmg.title
// 稍微缩短下title // 稍微缩短下title

View File

@ -25,7 +25,7 @@ const _path = process.cwd()
const helpPath = `${_path}/plugins/miao-plugin/resources/help` const helpPath = `${_path}/plugins/miao-plugin/resources/help`
async function help (e) { async function help (e) {
if (!/喵喵/.test(e.msg) && !Cfg.get('sys.help', false)) { if (!/喵喵/.test(e.msg) && !Cfg.get('help', false)) {
return false return false
} }

View File

@ -1,4 +1,4 @@
import { Common, Cfg, App } from '../components/index.js' import { Common, App } from '../components/index.js'
import { Character } from '../models/index.js' import { Character } from '../models/index.js'
import { getTargetUid, getProfile, profileHelp, inputProfile } from './character/ProfileCommon.js' import { getTargetUid, getProfile, profileHelp, inputProfile } from './character/ProfileCommon.js'
import { profileArtis, profileArtisList } from './character/ProfileArtis.js' import { profileArtis, profileArtisList } from './character/ProfileArtis.js'
@ -71,13 +71,16 @@ export async function profileDetail (e) {
if (!msg) { if (!msg) {
return false return false
} }
if (!/详细|详情|面板|面版|圣遗物|伤害/.test(msg)) {
return false
}
let mode = 'profile' let mode = 'profile'
let uidRet = /[0-9]{9}/.exec(msg) let uidRet = /[0-9]{9}/.exec(msg)
if (uidRet) { if (uidRet) {
e.uid = uidRet[0] e.uid = uidRet[0]
msg = msg.replace(uidRet[0], '') msg = msg.replace(uidRet[0], '')
} }
let name = msg.replace(/#|老婆|老公/g, '').trim() let name = msg.replace(/#|老婆|老公/g, '').trim()
msg = msg.replace('面版', '面板') msg = msg.replace('面版', '面板')
let dmgRet = /伤害(\d?)$/.exec(name) let dmgRet = /伤害(\d?)$/.exec(name)
@ -110,27 +113,11 @@ export async function profileDetail (e) {
mode = 'artis' mode = 'artis'
name = name.replace('圣遗物', '').trim() name = name.replace('圣遗物', '').trim()
} }
if (!Common.cfg('avatarProfile')) {
if (!e.isMaster) { // 面板开关关闭
if (Common.isDisable(e, 'char.profile')) { return false
// 面板开关关闭
return false
}
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 false
}
} 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 false
}
}
} }
let char = Character.get(name.trim()) let char = Character.get(name.trim())
if (!char) { if (!char) {
return false return false
} }

View File

@ -31,10 +31,6 @@ app.reg('upload-data', uploadData, {
export default app export default app
async function consStat (e) { async function consStat (e) {
if (Cfg.isDisable(e, 'wiki.stat')) {
return false
}
let consData = await HutaoApi.getCons() let consData = await HutaoApi.getCons()
let overview = await HutaoApi.getOverview() let overview = await HutaoApi.getOverview()
@ -114,10 +110,6 @@ async function consStat (e) {
} }
async function abyssPct (e) { async function abyssPct (e) {
if (Cfg.isDisable(e, 'wiki.stat')) {
return false
}
let mode = /使用/.test(e.msg) ? 'use' : 'pct' let mode = /使用/.test(e.msg) ? 'use' : 'pct'
let modeName let modeName
let abyssData let abyssData
@ -393,7 +385,7 @@ async function abyssTeam (e) {
async function uploadData (e) { async function uploadData (e) {
let isMatch = /^#(喵喵|上传)深渊(数据)?$/.test(e.original_msg || e.msg || '') let isMatch = /^#(喵喵|上传)深渊(数据)?$/.test(e.original_msg || e.msg || '')
if (!Cfg.get('wiki.abyss', false) && !isMatch) { if (!Cfg.get('uploadAbyssData', false) && !isMatch) {
return false return false
} }
let mys = await MysApi.init(e, { auth: 'all' }) let mys = await MysApi.init(e, { auth: 'all' })

View File

@ -37,17 +37,20 @@ function checkCharacter (e) {
mode = 'cons' mode = 'cons'
} else if (/(图鉴|资料)/.test(ret[2])) { } else if (/(图鉴|资料)/.test(ret[2])) {
mode = 'wiki' mode = 'wiki'
if (!Common.cfg('charWiki')) {
return false
}
} else if (/图|画|写真|照片/.test(ret[2])) { } else if (/图|画|写真|照片/.test(ret[2])) {
mode = 'pic' mode = 'pic'
if (!Common.cfg('charPic')) {
return false
}
} else if (/(材料|养成|成长)/.test(ret[2])) { } else if (/(材料|养成|成长)/.test(ret[2])) {
mode = 'material' mode = 'material'
} }
if (['cons', 'talent'].includes(mode) && !Common.cfg('charWikiTalent')) {
if ((mode === 'pic' && Common.isDisable(e, 'wiki.pic')) ||
(mode !== 'pic' && Common.isDisable(e, 'wiki.wiki'))) {
return false return false
} }
let char = Character.get(ret[1]) let char = Character.get(ret[1])
if (!char) { if (!char) {
return false return false
@ -63,7 +66,7 @@ async function wiki (e) {
let char = e.char let char = e.char
if (mode === 'pic') { if (mode === 'pic') {
let img = char.getCardImg(Cfg.get('char.se', false), false) let img = char.getCardImg(Cfg.get('charPicSe', false), false)
if (img && img.img) { if (img && img.img) {
e.reply(segment.image(process.cwd() + '/plugins/miao-plugin/resources/' + img.img)) e.reply(segment.image(process.cwd() + '/plugins/miao-plugin/resources/' + img.img))
} else { } else {

View File

@ -1,5 +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'
const _path = process.cwd() const _path = process.cwd()
const _cfgPath = `${_path}/plugins/miao-plugin/components/` const _cfgPath = `${_path}/plugins/miao-plugin/components/`
@ -7,38 +8,44 @@ let cfg = {}
try { try {
if (fs.existsSync(_cfgPath + 'cfg.json')) { if (fs.existsSync(_cfgPath + 'cfg.json')) {
cfg = JSON.parse(fs.readFileSync(_cfgPath + 'cfg.json', 'utf8')) || {} cfg = await cfgData.loadOldData()
cfgData.saveCfg(cfg)
fs.unlinkSync(_cfgPath + 'cfg.json')
} else {
cfg = await cfgData.getCfg()
cfgData.saveCfg(cfg)
} }
cfg = await cfgData.getCfg()
} catch (e) { } catch (e) {
// do nth // do nth
} }
let Cfg = { let Cfg = {
get (rote, def = '') { get (rote) {
return lodash.get(cfg, rote, def) return lodash.get(cfg, rote)
}, },
set (rote, val) { set (rote, val) {
lodash.set(cfg, rote, val) cfg[rote] = val
fs.writeFileSync(_cfgPath + 'cfg.json', JSON.stringify(cfg, null, '\t')) cfgData.saveCfg(cfg)
}, },
del (rote) { del (rote) {
lodash.set(cfg, rote, undefined) lodash.set(cfg, rote, undefined)
fs.writeFileSync(_cfgPath + 'cfg.json', JSON.stringify(cfg, null, '\t')) fs.writeFileSync(_cfgPath + 'cfg.json', JSON.stringify(cfg, null, '\t'))
}, },
getCfg () {
return cfg
},
getCfgSchema () {
return cfgData.getCfgSchema()
},
getCfgSchemaMap () {
return cfgData.getCfgSchemaMap()
},
scale (pct = 1) { scale (pct = 1) {
let scale = Cfg.get('sys.scale', 100) let scale = Cfg.get('renderScale', 100)
scale = Math.min(2, Math.max(0.5, scale / 100)) scale = Math.min(2, Math.max(0.5, scale / 100))
pct = pct * scale pct = pct * scale
return `style=transform:scale(${pct})` return `style=transform:scale(${pct})`
},
isDisable (e, rote) {
if (Cfg.get(rote, true)) {
return false
}
if (/^#*喵喵/.test(e.msg || '')) {
return false
}
return true
} }
} }

View File

@ -8,6 +8,5 @@ function sleep (ms) {
export default { export default {
render, render,
cfg: Cfg.get, cfg: Cfg.get,
isDisable: Cfg.isDisable,
sleep sleep
} }

View File

@ -0,0 +1,58 @@
import { cfgSchema } from '../../config/system/cfg_system.js'
import lodash from 'lodash'
import { Data } from '../index.js'
import fs from 'node:fs'
let cfgData = {
async loadOldData () {
const _path = process.cwd()
const _cfgPath = `${_path}/plugins/miao-plugin/components/`
if (!fs.existsSync(_cfgPath + 'cfg.json')) {
return false
}
let old = Data.readJSON('/components/cfg.json')
let cfg = await Data.importModule('/config/cfg.js')
let ret = {}
lodash.forEach(cfgSchema, (cfgGroup) => {
lodash.forEach(cfgGroup.cfg, (cfgItem, cfgKey) => {
ret[cfgKey] = Data.def(cfg[cfgKey], cfgItem.oldCfgKey ? Data.getVal(old, cfgItem.oldCfgKey) : undefined, cfgItem.def)
})
})
return ret
},
saveCfg (cfg) {
let ret = []
lodash.forEach(cfgSchema, (cfgGroup) => {
ret.push(`/** ************ 【${cfgGroup.title}】 ************* */`)
lodash.forEach(cfgGroup.cfg, (cfgItem, cfgKey) => {
ret.push(`// ${cfgItem.desc || cfgItem.title}`)
let val = Data.def(cfg[cfgKey], cfgItem.def)
if (cfgItem.input) {
val = cfgItem.input(val)
}
ret.push(`export const ${cfgKey} = ${val.toString()}`, '')
})
})
fs.writeFileSync(`${process.cwd()}/plugins/miao-plugin/config/cfg.js`, ret.join('\n'), 'utf8')
},
async getCfg () {
return lodash.toPlainObject(await Data.importModule('/config/cfg.js'))
},
getCfgSchemaMap () {
let ret = {}
lodash.forEach(cfgSchema, (cfgGroup) => {
lodash.forEach(cfgGroup.cfg, (cfgItem, cfgKey) => {
ret[cfgItem.key] = cfgItem
cfgItem.cfgKey = cfgKey
})
})
return ret
},
getCfgSchema () {
return cfgSchema
}
}
export default cfgData

38
config/cfg_default.js Normal file
View File

@ -0,0 +1,38 @@
/** ************ 【玩家&老婆卡片展示】 ************* */
// 使用喵喵版角色卡片作为默认角色卡片功能
export const avatarCard = true
// 面板查询
export const avatarProfile = true
// 群面板排名
export const groupRank = false
// 使用【#上传深渊】功能取代【#深渊功能】,默认关闭
export const uploadAbyssData = false
// 老婆查询
export const avatarWife = true
// 戳一戳卡片
export const avatarPoke = true
/** ************ 【角色资料与信息查询】 ************* */
// #刻晴图鉴 的图鉴信息
export const charWiki = true
// #刻晴天赋/#刻晴命座 的天赋信息
export const charWikiTalent = true
// 角色图片
export const charPic = true
// 启用后会启用角色图及增量包中的小清新图像,勇士啊,你准备好了吗
export const charPicSe = false
/** ************ 【系统设置】 ************* */
// 可选值50~200建议100。设置高精度会提高图片的精细度但因图片较大可能会影响渲染与发送速度
export const renderScale = 100
// 开启后将使用喵喵版帮助作为Yunzai的默认帮助
export const help = false

View File

@ -1,2 +1,101 @@
export const groupRank = false export const cfgSchema = {
export const isSys = true char: {
title: '玩家&老婆卡片展示',
cfg: {
avatarCard: {
title: '角色查询',
key: '角色',
def: true,
desc: '使用喵喵版角色卡片作为默认角色卡片功能',
showDesc: false,
oldCfgKey: 'char.char'
},
avatarProfile: {
title: '面板查询',
key: '面板',
def: true,
oldCfgKey: 'char.profile'
},
groupRank: {
title: '群面板排名',
key: '排名',
def: false,
desc: '群内的面板伤害及圣遗物排名与查看功能,默认关闭。请根据群友心理素质自行决定是否开启'
},
uploadAbyssData: {
title: '上传深渊',
key: '深渊',
def: false,
oldCfgKey: 'wiki.abyss',
desc: '使用【#上传深渊】功能取代【#深渊功能】,默认关闭'
},
avatarWife: {
title: '老婆查询',
key: '老婆',
def: true,
oldCfgKey: 'char.wife'
},
avatarPoke: {
title: '戳一戳卡片',
key: '戳一戳',
def: true,
oldCfgKey: 'char.poke'
}
}
},
wiki: {
title: '角色资料与信息查询',
cfg: {
charWiki: {
title: '角色图鉴-图鉴',
key: '图鉴',
def: true,
showDesc: false,
desc: '#刻晴图鉴 的图鉴信息'
},
charWikiTalent: {
title: '角色图鉴-天赋',
key: '天赋',
def: true,
oldCfgKey: 'wiki.wiki',
showDesc: false,
desc: '#刻晴天赋/#刻晴命座 的天赋信息'
},
charPic: {
title: '角色图片',
key: '图片',
def: true,
oldCfgKey: 'wiki.pic'
},
charPicSe: {
title: '小清新角色图',
key: '小清新',
def: false,
oldCfgKey: 'char.se',
desc: '启用后会启用角色图及增量包中的小清新图像,勇士啊,你准备好了吗'
}
}
},
sys: {
title: '系统设置',
cfg: {
renderScale: {
title: '渲染精度',
key: '渲染',
type: 'num',
def: 100,
input: (n) => Math.min(200, Math.max(50, (n * 1 || 100))),
oldCfgKey: 'sys.scale',
desc: '可选值50~200建议100。设置高精度会提高图片的精细度但因图片较大可能会影响渲染与发送速度'
},
help: {
title: '喵喵作为默认帮助',
key: '帮助',
def: false,
oldCfgKey: 'sys.help',
desc: '开启后将使用喵喵版帮助作为Yunzai的默认帮助默认关闭'
}
}
}
}

View File

@ -198,7 +198,7 @@ export default class Avatar extends Base {
names, names,
abbrs: [...abbrs, ...abbrs2], abbrs: [...abbrs, ...abbrs2],
imgs, imgs,
name: (abbrs.length > 1 || abbrs2[0].length > 7) ? abbrs.join('+') : abbrs2[0], name: (abbrs.length > 1 || abbrs2[0]?.length > 7) ? abbrs.join('+') : abbrs2[0],
sName: abbrs.join('+') sName: abbrs.join('+')
} }
} }

View File

@ -27,49 +27,75 @@ export default class ProfileRank {
return false return false
} }
let ret = {} let ret = {}
const markKey = this.key(profile, 'mark') for (let typeKey of ['mark', 'dmg']) {
let markRank = await redis.zRevRank(markKey, this.uid) let typeRank = await this.getTypeRank(profile, typeKey, force)
if (!lodash.isNumber(markRank) || force) { ret[typeKey] = typeRank
let mark = profile.getArtisMark(false) if (!ret.rank || ret.rank <= typeRank.rank) {
if (mark && mark._mark) { ret.rank = typeRank.rank
await redis.zAdd(markKey, { score: mark._mark, value: this.uid }) ret.rankType = typeKey
markRank = await redis.zRevRank(markKey, this.uid)
} }
} }
if (lodash.isNumber(markRank)) {
let markCount = await redis.zCard(markKey)
ret.markRank = markRank + 1
ret.markCount = markCount
}
if (profile.hasDmg) {
const dmgKey = this.key(profile, 'dmg')
let dmgRank = await redis.zRevRank(dmgKey, this.uid)
if (!lodash.isNumber(dmgRank) || force) {
let dmg = await profile.calcDmg({ mode: 'single' })
if (dmg && dmg.avg) {
await redis.zAdd(dmgKey, { score: dmg.avg, value: this.uid })
dmgRank = await redis.zRevRank(dmgKey, this.uid)
}
}
if (lodash.isNumber(dmgRank)) {
let dmgCount = await redis.zCard(dmgKey)
ret.dmgRank = dmgRank + 1
ret.dmgCount = dmgCount
}
}
if (lodash.isEmpty(ret)) {
return false
}
if (!ret.dmgRank || ret.markRank < ret.dmgRank) {
ret.rank = ret.markRank
ret.rankType = 'mark'
} else {
ret.rank = ret.dmgRank
ret.rankType = 'dmg'
}
return ret return ret
} }
async getTypeRank (profile, type, force) {
if (!profile.hasData || !type) {
return false
}
if (type === 'dmg' && !profile.hasDmg) {
return false
}
const typeKey = this.key(profile, type)
let value
let rank
if (force) {
value = await this.getTypeValue(profile, type)
} else {
rank = await redis.zRevRank(typeKey, this.uid)
if (!lodash.isNumber(rank)) {
value = await this.getTypeValue(profile, type)
}
}
if (value && value.score) {
await redis.zAdd(typeKey, { score: value.score, value: this.uid })
}
if (!lodash.isNumber(rank)) {
rank = await redis.zRevRank(typeKey, this.uid)
}
if (force) {
return {
rank: rank + 1,
value: value.score,
data: value.data
}
}
return {
rank: rank + 1
}
}
async getTypeValue (profile, type) {
if (type === 'mark') {
let mark = profile.getArtisMark(false)
if (mark && mark._mark) {
return {
score: mark._mark * 1,
data: mark
}
}
}
if (type === 'dmg' && profile.hasDmg) {
let dmg = await profile.calcDmg({ mode: 'single' })
if (dmg && dmg.avg) {
return {
score: dmg.avg,
data: dmg
}
}
}
return false
}
/** /**
* 获取群排行UID * 获取群排行UID
* @param groupId * @param groupId

View File

@ -10,73 +10,38 @@
<div class="title">#喵喵设置</div> <div class="title">#喵喵设置</div>
</div> </div>
</div> </div>
{{each schema cfgGroup}}
<div class="cfg-box"> <div class="cfg-box">
<div class="cfg-group">玩家&老婆卡片展示</div> <div class="cfg-group">{{cfgGroup.title}}</div>
<ul class="cfg-ul"> <ul class="cfg-ul">
{{each cfgGroup.cfg cfgItem cfgKey}}
<li class="cfg-li"> <li class="cfg-li">
<div class="cfg-line"> <div class="cfg-line">
角色查询 {{cfgItem.title}}
<span class="cfg-hint"> #喵喵设置角色 + 开启/关闭</span> <span class="cfg-hint"> #喵喵设置{{cfgItem.key}}
{{@chars}} {{if cfgItem.type==='num'}} {{cfgItem.def}}{{else}} + 开启/关闭{{/if}}
</div> </span>
</li> {{if cfgItem.type === 'num'}}
<li class="cfg-li"> <div class="cfg-status">{{cfg[cfgKey]}}</div>
<div class="cfg-line"> {{else}}
面板查询 {{if cfg[cfgKey]}}
<span class="cfg-hint"> #喵喵设置面板 + 开启/关闭</span> <div class="cfg-status">已开启</div>
{{@profile}} {{else}}
</div> <div class="cfg-status status-off">已关闭</div>
</li> {{/if}}
<li class="cfg-li"> {{/if}}
<div class="cfg-line">
老婆查询
<span class="cfg-hint"> #喵喵设置老婆 + 开启/关闭</span>
{{@wife}}
</div>
</li>
<li class="cfg-li">
<div class="cfg-line">
戳一戳卡片
<span class="cfg-hint"> #喵喵设置戳一戳 + 开启/关闭</span>
{{@poke}}
</div> </div>
{{if cfgItem.desc && cfgItem.showDesc!== false}}
<div class="cfg-desc">{{cfgItem.desc}}</div>
{{/if}}
</li> </li>
{{/each}}
</ul> </ul>
</div> </div>
{{/each}}
<div class="cfg-box"> <div class="cfg-box">
<div class="cfg-group">角色资料与信息查询</div> <div class="cfg-group">其他设置</div>
<ul class="cfg-ul"> <ul class="cfg-ul">
<li class="cfg-li">
<div class="cfg-line">
角色图鉴
<span class="cfg-hint"> #喵喵设置图鉴 + 开启/关闭</span>
{{@wiki}}
</div>
<div class="cfg-desc">角色天赋、角色命座、角色图鉴(尚未完成)等资料</div>
</li>
<li class="cfg-li">
<div class="cfg-line">
深渊统计
<span class="cfg-hint"> #喵喵设置统计 + 开启/关闭</span>
{{@stat}}
</div>
<div class="cfg-desc">角色持有率、深渊出场率、深渊配队等统计信息</div>
</li>
<li class="cfg-li">
<div class="cfg-line">
上传深渊
<span class="cfg-hint"> #喵喵设置深渊 + 开启/关闭</span>
{{@abyss}}
</div>
<div class="cfg-desc">使用【#上传深渊】功能取代【#深渊】功能,默认关闭</div>
</li>
<li class="cfg-li">
<div class="cfg-line">
角色图片
<span class="cfg-hint"> #喵喵设置图片 + 开启/关闭</span>
{{@pic}}
</div>
</li>
<li class="cfg-li"> <li class="cfg-li">
<div class="cfg-line"> <div class="cfg-line">
角色图片扩展包 角色图片扩展包
@ -87,39 +52,8 @@
<div class="cfg-status status-off">未安装</div> <div class="cfg-status status-off">未安装</div>
{{/if}} {{/if}}
</div> </div>
<div class="cfg-desc">角色图片的扩展包,包含更多的角色图片</div> <div class="cfg-desc">安装角色的扩展插图,图片较多可能需要一定时间,在返回提示前请勿重复执行</div>
</li>
<li class="cfg-li">
<div class="cfg-line">
小清新角色图
<span class="cfg-hint"> #喵喵设置小清新 + 开启/关闭</span>
{{@se}}
</div>
<div class="cfg-desc">启用后会启用角色图及增量包中的小清新图像,勇士啊,你准备好了吗</div>
</li> </li>
</ul> </ul>
</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">#喵喵设置渲染100 </span>
<div class="cfg-status">{{scale}}</div>
</div>
<div class="cfg-desc">可选值50~200建议100。设置高精度会提高图片的精细度但因图片较大可能会影响渲染与发送速度</div>
</li>
<li class="cfg-li">
<div class="cfg-line">
喵喵作为默认帮助
<span class="cfg-hint">#喵喵设置帮助 + 开启/关闭 </span>
{{@help}}
</div>
<div class="cfg-desc">开启后将使用喵喵版帮助作为Yunzai的默认帮助</div>
</li>
</ul>
</div>
{{/block}} {{/block}}