mirror of
https://github.com/yoimiya-kokomi/miao-plugin.git
synced 2024-11-16 04:35:42 +00:00
#雷神排名
使用个人作为排行头像展示
This commit is contained in:
parent
1d34b24acd
commit
fd7afd241e
@ -3,6 +3,7 @@
|
||||
* 喵喵设置中增加排名限制门槛,支持限制 有16个角色数据/包含御三家角色 才能参与排名,防止被非群成员uid刷榜
|
||||
* `#雷神面板`圣遗物支持展示强化次数
|
||||
* 增加命令`#刷新排名`,获取群成员面板数据,刷新当前排名 **@munnks**
|
||||
* `#雷神排名` 使用个人作为排行头像展示(首次使用可使用`#刷新排名`以更新uid信息)
|
||||
|
||||
# 2.0.1~2.0.8
|
||||
|
||||
|
@ -29,7 +29,7 @@ export async function profileList (e) {
|
||||
// 获取面板数据
|
||||
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
|
||||
if (groupId) {
|
||||
|
@ -81,21 +81,11 @@ export async function resetRank (e) {
|
||||
e.reply(`本群${charName}排名已重置...`)
|
||||
}
|
||||
|
||||
const getUid = async function (qq) {
|
||||
let uidReg = /[1-9][0-9]{8}/
|
||||
let nCookie = global.NoteCookie || false
|
||||
if (nCookie && nCookie[qq]) {
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新群排名信息
|
||||
* @param e
|
||||
* @returns {Promise<boolean>}
|
||||
*/
|
||||
export async function refreshRank (e) {
|
||||
let groupId = e.group_id
|
||||
if (!groupId) {
|
||||
@ -111,7 +101,7 @@ export async function refreshRank (e) {
|
||||
for (let { uid, type } of groupUids[qq]) {
|
||||
let profiles = Profile.getAll(uid)
|
||||
// 刷新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 })
|
||||
for (let id in profiles) {
|
||||
let profile = profiles[id]
|
||||
@ -157,6 +147,16 @@ async function renderCharRankList ({ e, uids, char, mode, groupId }) {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ app.reg('reset-rank', resetRank, {
|
||||
})
|
||||
|
||||
app.reg('refresh-rank', refreshRank, {
|
||||
rule: /^#(刷新)(全部)?(排名|排行)$/,
|
||||
rule: /^#(刷新|更新|重新加载)(群内|群|全部)*(排名|排行)$/,
|
||||
name: '重置排名'
|
||||
})
|
||||
|
||||
|
@ -53,7 +53,7 @@ const Common = {
|
||||
let ret = {}
|
||||
let uidMap = {}
|
||||
|
||||
let groupMemMap = await e.group.getMemberMap()
|
||||
let groupMemMap = await e.group?.getMemberMap()
|
||||
// 优先匹配ck uid
|
||||
for (let [qq] of groupMemMap) {
|
||||
if (noteUids[qq]) {
|
||||
|
@ -178,7 +178,7 @@ export default class ProfileRank {
|
||||
return ret
|
||||
}
|
||||
|
||||
static async setRankUidInfo ({ uid, qq, profiles, uidType = 'bind' }) {
|
||||
static async setUidInfo ({ uid, qq, profiles, uidType = 'bind' }) {
|
||||
if (!uid) {
|
||||
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 })
|
||||
}
|
||||
|
||||
static async getUidInfo (uid) {
|
||||
try {
|
||||
let data = await redis.get(`miao:rank:uid-info:${uid}`)
|
||||
return JSON.parse(data)
|
||||
} catch (e) {
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
* 1: '无限制',
|
||||
* 2: '绑定有CK的用户',
|
||||
|
@ -44,7 +44,11 @@
|
||||
<span class="idx-{{idx+1}} mode-{{mode}}">{{idx+1}}</span>
|
||||
</div>
|
||||
<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>
|
||||
{{/if}}
|
||||
</div>
|
||||
<div class="char-info char-name">
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user