MiraiForum

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

    如何获取某一权限下的所有被授权人id

    开发交流
    4
    9
    201
    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.
    • L
      Lost-Swords last edited by

      如题 语言是java PermissionService似乎只能获取某一被授权人的全部权限列表

      1 Reply Last reply Reply Quote 0
      • wssy001
        wssy001 ⭐2021⭐ last edited by wssy001

        请说出你是用的是什么模块(mirai -core 还是 mirai-console),另外,你是否使用的是第三方的插件,也请说明。如果对于你这个需求,mirai-core可以让机器人获取全部群成员,通过 并行流 + 筛选 获取全部符合结果的群

        ContactList<NormalMember> members = event.getBot()
                .getGroup(1L)
                .getMembers();
        
        List<Long> idList = members.parallelStream()
        //        更改为你自己的逻辑
                .filter(v -> true)
                .map(NormalMember::getId)
                .collect(Collectors.toList());
        
        if (idList.isEmpty()){
        
        }
        
        L 4 Replies Last reply Reply Quote 0
        • L
          Lost-Swords @wssy001 last edited by

          This post is deleted!
          1 Reply Last reply Reply Quote 0
          • L
            Lost-Swords @wssy001 last edited by

            This post is deleted!
            1 Reply Last reply Reply Quote 0
            • L
              Lost-Swords @wssy001 last edited by

              @wssy001 筛选比较麻烦 还有PermissionService的判断权限似乎需要Permitee对象 我从Group或User里拿不到这个对象

              H 1 Reply Last reply Reply Quote 0
              • L
                Lost-Swords @wssy001 last edited by

                @wssy001 mirai-console

                1 Reply Last reply Reply Quote 0
                • H
                  hundun000 ⭐2021⭐ @Lost-Swords last edited by

                  @lost-swords PermissionService.testPermission需要的是PermitteeId,你可以构造它by groupId/userId 链接

                  1 Reply Last reply Reply Quote 0
                  • jie65535
                    jie65535 last edited by

                    PermissionService.yml image
                    某一权限所有被授权ID,配置文件里面就是这么保存的。
                    至于有没有开放接口给你获取这个,可以查一下源码。

                    1 Reply Last reply Reply Quote 0
                    • jie65535
                      jie65535 last edited by

                      翻到代码了 AbstractConcurrentPermissionService

                      1 Reply Last reply Reply Quote 0
                      • 1 / 1
                      • First post
                        Last post
                      Powered by Mamoe Technologies & NodeBB | 友情链接 | 服务监控 | Contact