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

* `#刻晴排行` 命令会触发排行更新,防止部分排行错位
* `#喵喵设置` 部分配置项及功能改进
* 其余一些已知问题修正及改进
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本地统计只统计在群内主动查看过的面板数据
* 统计自本次更新后开始记录,历史数据不会回溯
* 可通过`#面板`、`#心海面板`、`#更新面板`等命令来触发排名数据更新
* 增加`#最强雷神`、`#最高分甘雨`命令,查看当前统计中最高练度/最高圣遗物评分的面板数据
* 增加`#重置排名`、`#重置刻晴排名`命令,来重置当前群的排名统计
* 增加排名相关命令
* 增加`#最强雷神`、`#最高分甘雨`命令,查看当前统计中最高练度/最高圣遗物评分的面板数据
* 增加`#雷神排名`、`#甘雨圣遗物排名`命令,查看当前群中角色的排名数据
* 增加`#重置排名`、`#重置刻晴排名`命令,来重置当前群的排名统计
* `#喵喵设置` 部分配置项及功能改进
* 删除一些无效或暂不支持的配置项
* 配置存储位置变更为**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 { MysApi } from '../models/index.js'
let cfgMap = {
角色: '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 keys = lodash.map(Cfg.getCfgSchemaMap(), (i) => i.key)
let app = App.init({
id: 'admin',
name: '喵喵设置',
desc: '喵喵设置'
})
let sysCfgReg = new RegExp(`^#喵喵设置\\s*(${lodash.keys(cfgMap).join('|')})?\\s*(.*)$`)
let sysCfgReg = new RegExp(`^#喵喵设置\\s*(${keys.join('|')})?\\s*(.*)$`)
app.reg('update-res', updateRes, {
rule: /^#喵喵(强制)?(更新图像|图像更新)$/,
@ -38,10 +25,6 @@ app.reg('sys-cfg', sysCfg, {
rule: sysCfgReg,
desc: '【#管理】系统设置'
})
app.reg('profile-cfg', profileCfg, {
rule: /^#喵喵面板(?:设置)?.*/,
desc: '面板设置'
})
export default app
@ -65,6 +48,7 @@ async function sysCfg (e) {
let cfgReg = sysCfgReg
let regRet = cfgReg.exec(e.msg)
let cfgSchemaMap = Cfg.getCfgSchemaMap()
if (!regRet) {
return true
@ -74,48 +58,27 @@ async function sysCfg (e) {
// 设置模式
let val = regRet[2] || ''
let cfgKey = cfgMap[regRet[1]]
if (cfgKey === 'sys.scale') {
val = Math.min(200, Math.max(50, val * 1 || 100))
let cfgSchema = cfgSchemaMap[regRet[1]]
if (cfgSchema.input) {
val = cfgSchema.input(val)
} else {
val = !/关闭/.test(val)
}
if (cfgKey) {
Cfg.set(cfgKey, val)
}
Cfg.set(cfgSchema.cfgKey, val)
}
let cfg = {
chars: getStatus('char.char'),
profile: getStatus('char.profile'),
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)
}
let schema = Cfg.getCfgSchema()
let cfg = Cfg.getCfg()
let imgPlus = fs.existsSync(plusPath)
// 渲染图像
return await Common.render('admin/index', {
...cfg
schema,
cfg,
imgPlus
}, { 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) {
if (!await checkAuth(e)) {
return true
@ -208,63 +171,3 @@ async function updateMiaoPlugin (e) {
})
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)) {
return false
}
if (!Common.cfg('avatarCard')) {
return false
}
let uidRet = /[0-9]{9}/.exec(msg)
if (uidRet) {
e.uid = uidRet[0]
@ -54,10 +56,6 @@ function checkCharacter (e) {
}
let name = msg.replace(/#|老婆|老公|卡片/g, '').trim()
if (Common.isDisable(e, 'char.char')) {
return false
}
let char = Character.get(name.trim())
if (!char) {

View File

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

View File

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

View File

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

View File

@ -25,7 +25,7 @@ const _path = process.cwd()
const helpPath = `${_path}/plugins/miao-plugin/resources/help`
async function help (e) {
if (!/喵喵/.test(e.msg) && !Cfg.get('sys.help', false)) {
if (!/喵喵/.test(e.msg) && !Cfg.get('help', 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 { getTargetUid, getProfile, profileHelp, inputProfile } from './character/ProfileCommon.js'
import { profileArtis, profileArtisList } from './character/ProfileArtis.js'
@ -71,13 +71,16 @@ export async function profileDetail (e) {
if (!msg) {
return false
}
if (!/详细|详情|面板|面版|圣遗物|伤害/.test(msg)) {
return false
}
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)
@ -110,27 +113,11 @@ export async function profileDetail (e) {
mode = 'artis'
name = name.replace('圣遗物', '').trim()
}
if (!e.isMaster) {
if (Common.isDisable(e, 'char.profile')) {
// 面板开关关闭
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
}
}
if (!Common.cfg('avatarProfile')) {
// 面板开关关闭
return false
}
let char = Character.get(name.trim())
if (!char) {
return false
}

View File

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

View File

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

View File

@ -1,5 +1,6 @@
import fs from 'fs'
import lodash from 'lodash'
import cfgData from './cfg-lib/cfg-data.js'
const _path = process.cwd()
const _cfgPath = `${_path}/plugins/miao-plugin/components/`
@ -7,38 +8,44 @@ let cfg = {}
try {
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) {
// do nth
}
let Cfg = {
get (rote, def = '') {
return lodash.get(cfg, rote, def)
get (rote) {
return lodash.get(cfg, rote)
},
set (rote, val) {
lodash.set(cfg, rote, val)
fs.writeFileSync(_cfgPath + 'cfg.json', JSON.stringify(cfg, null, '\t'))
cfg[rote] = val
cfgData.saveCfg(cfg)
},
del (rote) {
lodash.set(cfg, rote, undefined)
fs.writeFileSync(_cfgPath + 'cfg.json', JSON.stringify(cfg, null, '\t'))
},
getCfg () {
return cfg
},
getCfgSchema () {
return cfgData.getCfgSchema()
},
getCfgSchemaMap () {
return cfgData.getCfgSchemaMap()
},
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))
pct = pct * scale
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 {
render,
cfg: Cfg.get,
isDisable: Cfg.isDisable,
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 isSys = true
export const cfgSchema = {
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,
abbrs: [...abbrs, ...abbrs2],
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('+')
}
}

View File

@ -27,49 +27,75 @@ export default class ProfileRank {
return false
}
let ret = {}
const markKey = this.key(profile, 'mark')
let markRank = await redis.zRevRank(markKey, this.uid)
if (!lodash.isNumber(markRank) || force) {
let mark = profile.getArtisMark(false)
if (mark && mark._mark) {
await redis.zAdd(markKey, { score: mark._mark, value: this.uid })
markRank = await redis.zRevRank(markKey, this.uid)
for (let typeKey of ['mark', 'dmg']) {
let typeRank = await this.getTypeRank(profile, typeKey, force)
ret[typeKey] = typeRank
if (!ret.rank || ret.rank <= typeRank.rank) {
ret.rank = typeRank.rank
ret.rankType = typeKey
}
}
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
}
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
* @param groupId

View File

@ -10,73 +10,38 @@
<div class="title">#喵喵设置</div>
</div>
</div>
{{each schema cfgGroup}}
<div class="cfg-box">
<div class="cfg-group">玩家&老婆卡片展示</div>
<div class="cfg-group">{{cfgGroup.title}}</div>
<ul class="cfg-ul">
{{each cfgGroup.cfg cfgItem cfgKey}}
<li class="cfg-li">
<div class="cfg-line">
角色查询
<span class="cfg-hint"> #喵喵设置角色 + 开启/关闭</span>
{{@chars}}
</div>
</li>
<li class="cfg-li">
<div class="cfg-line">
面板查询
<span class="cfg-hint"> #喵喵设置面板 + 开启/关闭</span>
{{@profile}}
</div>
</li>
<li class="cfg-li">
<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}}
{{cfgItem.title}}
<span class="cfg-hint"> #喵喵设置{{cfgItem.key}}
{{if cfgItem.type==='num'}} {{cfgItem.def}}{{else}} + 开启/关闭{{/if}}
</span>
{{if cfgItem.type === 'num'}}
<div class="cfg-status">{{cfg[cfgKey]}}</div>
{{else}}
{{if cfg[cfgKey]}}
<div class="cfg-status">已开启</div>
{{else}}
<div class="cfg-status status-off">已关闭</div>
{{/if}}
{{/if}}
</div>
{{if cfgItem.desc && cfgItem.showDesc!== false}}
<div class="cfg-desc">{{cfgItem.desc}}</div>
{{/if}}
</li>
{{/each}}
</ul>
</div>
{{/each}}
<div class="cfg-box">
<div class="cfg-group">角色资料与信息查询</div>
<div class="cfg-group">其他设置</div>
<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">
<div class="cfg-line">
角色图片扩展包
@ -87,39 +52,8 @@
<div class="cfg-status status-off">未安装</div>
{{/if}}
</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>
<div class="cfg-desc">安装角色的扩展插图,图片较多可能需要一定时间,在返回提示前请勿重复执行</div>
</li>
</ul>
</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}}