mirror of
https://github.com/yoimiya-kokomi/miao-plugin.git
synced 2024-11-16 04:35:42 +00:00
重置排名时支持扫描群成员重新录入排名 (#267)
* 重置排名时支持扫描群成员重新录入排名 * fix bug:解决重置排行部分取不到uid的情况 Co-authored-by: hehe <390223734@qq.com>
This commit is contained in:
parent
6f7909d3e3
commit
725a1c25d4
@ -68,6 +68,12 @@ export async function resetRank (e) {
|
||||
let name = msg.replace(/(#|重置|重设|排名|排行|群|群内|面板|详情|面版)/g, '').trim()
|
||||
let charId = ''
|
||||
let charName = '全部角色'
|
||||
let groupMemList = []
|
||||
let groupMemMap = await e.group.getMemberMap()
|
||||
groupMemMap.forEach((v, k) => {
|
||||
groupMemList.push(k)
|
||||
});
|
||||
|
||||
if (name) {
|
||||
let char = Character.get(name)
|
||||
if (!char) {
|
||||
@ -77,7 +83,7 @@ export async function resetRank (e) {
|
||||
charId = char.id
|
||||
charName = char.name
|
||||
}
|
||||
await ProfileRank.resetRank(groupId, charId)
|
||||
await ProfileRank.resetRank(groupId, groupMemList, charId)
|
||||
e.reply(`本群${charName}排名已重置...`)
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
import lodash from 'lodash'
|
||||
import moment from 'moment'
|
||||
import { Common } from '../components/index.js'
|
||||
import { Common, Profile } from '../components/index.js'
|
||||
|
||||
export default class ProfileRank {
|
||||
constructor (data) {
|
||||
@ -136,7 +136,7 @@ export default class ProfileRank {
|
||||
* @param charId
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
static async resetRank (groupId, charId = '') {
|
||||
static async resetRank (groupId, groupMemList, charId = '') {
|
||||
let keys = await redis.keys(`miao:rank:${groupId}:*`)
|
||||
for (let key of keys) {
|
||||
let charRet = /^miao:rank:\d+:(?:mark|dmg):(\d{8})$/.exec(key)
|
||||
@ -149,6 +149,36 @@ export default class ProfileRank {
|
||||
if (charId === '') {
|
||||
await redis.del(`miao:rank:${groupId}:cfg`)
|
||||
}
|
||||
|
||||
let 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
|
||||
}
|
||||
}
|
||||
|
||||
for (let qq of groupMemList) {
|
||||
let uid = await getUid(qq)
|
||||
if (!uid) { continue }
|
||||
let rankObj = await ProfileRank.create({ groupId, uid, qq})
|
||||
if (charId === ''){
|
||||
await Profile.forEach(uid, async function (profile) {
|
||||
await rankObj.getRank(profile, true)
|
||||
});
|
||||
}
|
||||
else {
|
||||
let profile = Profile.get(uid, charId)
|
||||
await rankObj.getRank(profile, true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static async getGroupCfg (groupId) {
|
||||
|
Loading…
Reference in New Issue
Block a user