iTXTech / mirai-native

强大的 mirai 原生插件加载器
GNU Affero General Public License v3.0
371 stars 141 forks source link

将获取用户等级功能加入Mirai Native APIs的请求 #128

Closed zxin8580 closed 3 years ago

zxin8580 commented 3 years ago

特性描述 https://github.com/mamoe/mirai/issues/967#issue-801216225

请问mirai native能否考虑将此功能列入Mirai Native APIs供调用

PeratX commented 3 years ago

好的,相关功能可能会在2.0.0的beta的某个版本中加入,请留意commit和wiki更新

PeratX commented 3 years ago

目前个人开发重心在 mcl-installer ,待该项目完善后(一两天),才会转来开发mirai native

zxin8580 commented 3 years ago

哇,别说一两天,一两周也愿意等(。・`ω´・)

PeratX commented 3 years ago

getStrangerInfo已更新,编码如下,修改相关代码就可以获取多出来的qLevelemailsign

    fun getStrangerInfo(pluginId: Int, account: Long) = call("CQ_getStrangerInfo", pluginId, "") {
        return@call runBlocking {
            val profile = CacheManager.findUser(account)?.queryProfile()
                ?: Mirai.queryProfile(MiraiNative.bot, account)
            return@runBlocking buildPacket {
                writeLong(account)
                writeString(profile.nickname)
                writeInt(profile.sex.ordinal)
                writeInt(profile.age)
                writeInt(profile.qLevel)
                writeString(profile.email)
                writeString(profile.sign)
            }.encodeBase64()
        }
    }
zxin8580 commented 3 years ago

感谢大佬~

zxin8580 commented 3 years ago

https://github.com/iTXTech/mirai-native/blob/e521e09a7614f98f462d1d9c3d3ed85ed5817e7d/src/main/kotlin/org/itxtech/mirainative/bridge/MiraiBridge.kt#L428

大佬,我昨天测试了一下member.queryProfile()好像会对getGroupMemberList()的执行效率有挺大影响,尝试注释掉并返回sex,age=0后效率恢复正常了

PeratX commented 3 years ago

是的,mirai默认没有缓存这些数据,所以全部查询的话确实会很慢