#雷神排名 使用个人作为排行头像展示

This commit is contained in:
Kokomi 2022-11-16 04:58:19 +08:00
parent 1d34b24acd
commit fd7afd241e
7 changed files with 34 additions and 20 deletions

View File

@ -3,6 +3,7 @@
* 喵喵设置中增加排名限制门槛,支持限制 有16个角色数据/包含御三家角色 才能参与排名防止被非群成员uid刷榜 * 喵喵设置中增加排名限制门槛,支持限制 有16个角色数据/包含御三家角色 才能参与排名防止被非群成员uid刷榜
* `#雷神面板`圣遗物支持展示强化次数 * `#雷神面板`圣遗物支持展示强化次数
* 增加命令`#刷新排名`,获取群成员面板数据,刷新当前排名 **@munnks** * 增加命令`#刷新排名`,获取群成员面板数据,刷新当前排名 **@munnks**
* `#雷神排名` 使用个人作为排行头像展示(首次使用可使用`#刷新排名`以更新uid信息
# 2.0.1~2.0.8 # 2.0.1~2.0.8

View File

@ -29,7 +29,7 @@ export async function profileList (e) {
// 获取面板数据 // 获取面板数据
let profiles = Profile.getAll(uid) let profiles = Profile.getAll(uid)
// 检测标志位 // 检测标志位
await ProfileRank.setRankUidInfo({ uid, profiles, qq: e.user_id, uidType: isSelfUid ? 'ck' : 'bind' }) await ProfileRank.setUidInfo({ uid, profiles, qq: e.user_id, uidType: isSelfUid ? 'ck' : 'bind' })
let groupId = e.group_id let groupId = e.group_id
if (groupId) { if (groupId) {

View File

@ -81,21 +81,11 @@ export async function resetRank (e) {
e.reply(`本群${charName}排名已重置...`) e.reply(`本群${charName}排名已重置...`)
} }
const getUid = async function (qq) { /**
let uidReg = /[1-9][0-9]{8}/ * 刷新群排名信息
let nCookie = global.NoteCookie || false * @param e
if (nCookie && nCookie[qq]) { * @returns {Promise<boolean>}
let nc = nCookie[qq] */
if (nc.uid && uidReg.test(nc.uid)) {
return nc.uid
}
}
let uid = await redis.get(`Yz:genshin:mys:qq-uid:${qq}`)
if (uid && uidReg.test(uid)) {
return uid
}
}
export async function refreshRank (e) { export async function refreshRank (e) {
let groupId = e.group_id let groupId = e.group_id
if (!groupId) { if (!groupId) {
@ -111,7 +101,7 @@ export async function refreshRank (e) {
for (let { uid, type } of groupUids[qq]) { for (let { uid, type } of groupUids[qq]) {
let profiles = Profile.getAll(uid) let profiles = Profile.getAll(uid)
// 刷新rankLimit // 刷新rankLimit
await ProfileRank.setRankUidInfo({ uid, profiles, qq, uidType: type }) await ProfileRank.setUidInfo({ uid, profiles, qq, uidType: type })
let rank = await ProfileRank.create({ groupId, uid, qq }) let rank = await ProfileRank.create({ groupId, uid, qq })
for (let id in profiles) { for (let id in profiles) {
let profile = profiles[id] let profile = profiles[id]
@ -157,6 +147,16 @@ async function renderCharRankList ({ e, uids, char, mode, groupId }) {
avg: Format.comma(dmg.avg, 1) avg: Format.comma(dmg.avg, 1)
} }
} }
if (uid) {
let userInfo = await ProfileRank.getUidInfo(uid)
if (userInfo && userInfo.qq) {
let member = e.group?.pickMember(userInfo.qq * 1)
let img = member?.getAvatarUrl(140)
if (img) {
tmp.qqFace = img
}
}
}
list.push(tmp) list.push(tmp)
} }
} }

View File

@ -28,7 +28,7 @@ app.reg('reset-rank', resetRank, {
}) })
app.reg('refresh-rank', refreshRank, { app.reg('refresh-rank', refreshRank, {
rule: /^#(刷新)(全部)?(排名|排行)$/, rule: /^#(刷新|更新|重新加载)(群内|群|全部)*(排名|排行)$/,
name: '重置排名' name: '重置排名'
}) })

View File

@ -53,7 +53,7 @@ const Common = {
let ret = {} let ret = {}
let uidMap = {} let uidMap = {}
let groupMemMap = await e.group.getMemberMap() let groupMemMap = await e.group?.getMemberMap()
// 优先匹配ck uid // 优先匹配ck uid
for (let [qq] of groupMemMap) { for (let [qq] of groupMemMap) {
if (noteUids[qq]) { if (noteUids[qq]) {

View File

@ -178,7 +178,7 @@ export default class ProfileRank {
return ret return ret
} }
static async setRankUidInfo ({ uid, qq, profiles, uidType = 'bind' }) { static async setUidInfo ({ uid, qq, profiles, uidType = 'bind' }) {
if (!uid) { if (!uid) {
return false return false
} }
@ -219,6 +219,15 @@ export default class ProfileRank {
await redis.set(`miao:rank:uid-info:${uid}`, JSON.stringify(data), { EX: 3600 * 24 * 365 }) await redis.set(`miao:rank:uid-info:${uid}`, JSON.stringify(data), { EX: 3600 * 24 * 365 })
} }
static async getUidInfo (uid) {
try {
let data = await redis.get(`miao:rank:uid-info:${uid}`)
return JSON.parse(data)
} catch (e) {
}
return false
}
/** /**
* 1: '无限制', * 1: '无限制',
* 2: '绑定有CK的用户', * 2: '绑定有CK的用户',

View File

@ -44,7 +44,11 @@
<span class="idx-{{idx+1}} mode-{{mode}}">{{idx+1}}</span> <span class="idx-{{idx+1}} mode-{{mode}}">{{idx+1}}</span>
</div> </div>
<div class="item-icon char-icon star{{ds.star}}"> <div class="item-icon char-icon star{{ds.star}}">
{{if ds.qqFace}}
<span class="img" style="background-image:url({{ds.qqFace}})"></span>
{{else}}
<span class="img" style="background-image:url({{_res_path}}{{ds.imgs?.face}})"></span> <span class="img" style="background-image:url({{_res_path}}{{ds.imgs?.face}})"></span>
{{/if}}
</div> </div>
<div class="char-info char-name"> <div class="char-info char-name">