MiraiForum

    • Register
    • Login
    • Search
    • Popular
    • Recent
    • Unsolved
    • Tags
    • Groups
    • 友情链接

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

    开发交流
    1
    2
    250
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • J
      jiajiaxd last edited by 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 Reply Last reply Reply Quote 0
      • J
        jiajiaxd last edited by

        已经解决
        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 Reply Last reply Reply Quote 0
        • 1 / 1
        • First post
          Last post
        Powered by Mamoe Technologies & NodeBB | 友情链接 | 服务监控 | Contact