MiraiForum

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

    message.data.At对象的key,不能使MessageChain.get()拿到正确的at对象

    开发交流
    3
    8
    473
    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.
    • HollisMeynell
      HollisMeynell last edited by

      请问是我个例吗
      图片

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

        这是不支持也不合法的操作

        HollisMeynell 1 Reply Last reply Reply Quote 0
        • HollisMeynell
          HollisMeynell @Karlatemp last edited by

          @karlatemp 但是为什么其它类型的消息支持呀
          替代文字
          包括text,voice等消息都支持提取

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

            因为她们的数量都是唯一的,其预期和行为可以确定

            HollisMeynell 1 Reply Last reply Reply Quote 0
            • HollisMeynell
              HollisMeynell @Karlatemp last edited by

              @karlatemp 原来如此,明白了,那请问是不是只能通过遍历判断,或者有什么更好的主意

              At at = null;
                      for (var v : event.getMessage()){
                          if(v instanceof At) at = (At) v;
                      }
                      if(at != null)
              
              1 Reply Last reply Reply Quote 0
              • Karlatemp
                Karlatemp last edited by

                var at = (At) event.getMessage().stream().filter(it -> it instanceof At).findFirst().orElse(null);

                HollisMeynell 1 Reply Last reply Reply Quote 0
                • HollisMeynell
                  HollisMeynell @Karlatemp last edited by

                  @karlatemp 学到了,灰常感谢

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

                    https://github.com/mamoe/mirai/blob/dev/docs/Messages.md#元素唯一性

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