MiraiForum

    • 注册
    • 登录
    • 搜索
    • 热门
    • 最新
    • 未解决
    • 标签
    • 群组
    • 友情链接

    如何获取一个陌生人的QQ等级?

    开发交流
    1
    2
    243
    正在加载更多帖子
    • 从旧到新
    • 从新到旧
    • 最多赞同
    回复
    • 在新帖中回复
    登录后回复
    此主题已被删除。只有拥有主题管理权限的用户可以查看。
    • J
      jiajiaxd 最后由 jiajiaxd 编辑

      如何通过QQ号获取一个陌生人(对方从未发过消息)的QQ等级?
      我想通过此方法来判断申请进群的人等级是否大于指定值,避免小号。
      我尝试使用此方法:

      getCurrentBot().getStranger(event.getFromId()).queryProfile().getQLevel()
      

      但是会报错:

      2021-08-17 16:02:25 E/main: Exception in coroutine <unnamed>
      java.lang.NullPointerException: Cannot invoke "net.mamoe.mirai.contact.Stranger.queryProfile()" because the return value of "net.mamoe.mirai.Bot.getStranger(long)" is null
              at com.jiajiaxd.EventHandler.lambda$new$3(EventHandler.java:241)
              at net.mamoe.mirai.event.EventChannel$subscribeAlways$2$1.invoke(EventChannel.kt:511)
              at net.mamoe.mirai.event.EventChannel$subscribeAlways$2$1.invoke(EventChannel.kt:60)
              at kotlinx.coroutines.InterruptibleKt.runInterruptibleInExpectedContext(Interruptible.kt:46)
              at kotlinx.coroutines.InterruptibleKt.access$runInterruptibleInExpectedContext(Interruptible.kt:1)
              at kotlinx.coroutines.InterruptibleKt$runInterruptible$2.invokeSuspend(Interruptible.kt:38)
              at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
              at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
              at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
              at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
              at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
              at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)
      
      1 条回复 最后回复 回复 引用 0
      • J
        jiajiaxd 最后由 编辑

        已经解决
        https://github.com/mamoe/mirai/issues/1483
        // Java
        Mirai.getInstance().queryProfile

        // Kotlin
        Mirai.queryProfile

        jiajiaxd created this issue in mamoe/mirai

        closed 建议允许通过MemberJoinRequestEvent事件来获取申请人的详细资料 #1483

        1 条回复 最后回复 回复 引用 0
        • 1 / 1
        • First post
          Last post
        Powered by Mamoe Technologies & NodeBB | 友情链接 | 服务监控 | Contact