MiraiForum

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

    如何去掉引用回复的 @TA?

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

      使用组件:mirai-core

      机器人发消息引用回复消息时,总是自带一个@TA,如何去掉这个@TA符号?

      如图所示:
      b0a71a25-84dc-4672-a32c-43a267d7dce4-96B8A87D1F3B393331DEBFC27B889902.jpg

      java源码

      for (QuoteReply quote : quoteList) {
          MessageSource source = quote.getSource();
          MessageChain originalMessage = chainService.selectMessageChain(source);
              if (originalMessage == null) {
                  // 客户端显示的quote是一个附带 @TA 的引用,即便我使用 new QuoteReply 也是会带 @TA
                  // 关键代码:我把引用 "quote" 传入到了作为了 MessageChain参数
                  nodeList.add(new ForwardMessage.Node(botId, (int) (System.currentTimeMillis() / 1000), "警告:未存储该消息的原数据", quote));
                  break;
              }
              if (source.getFromId() == sender.getId()) {
                  inputGPTMessageList.add(formatQuote(originalMessage, source, "user"));
              } else {
                  inputGPTMessageList.add(formatQuote(originalMessage, source, "assistant"));
              }
      }
      

      如何取掉这个@TA符号

      abc408880155 1 条回复 最后回复 回复 引用 0
      • abc408880155
        abc408880155 @2446694 最后由 编辑

        @2446694 我这样没有出现多余的艾特

        public static MessageChain quoteReply(MessageEvent event, MessageChain msg) {
        return buildMessageChain(getQuoteReply(event), msg);
        }
        public static MessageChain quoteReply(MessageEvent event, String msg) {
        return buildMessageChain(getQuoteReply(event), msg);
        }

        1 条回复 最后回复 回复 引用 0
        • abc408880155
          abc408880155 最后由 编辑

          public static QuoteReply getQuoteReply(MessageEvent event) {
              return new QuoteReply(event.getMessage());
          }
          
          2 1 条回复 最后回复 回复 引用 0
          • 2
            2446694 @abc408880155 最后由 编辑

            @abc408880155 我使用了new QuoteReply(new PlainText("未存储该元数据"));
            但还是会显示@TA,然后我发现,电脑上没有显示@TA,只有手机上显示了@TA,QQ版本是当前最新版

            2 abc408880155 2 条回复 最后回复 回复 引用 0
            • 2
              2446694 @2446694 最后由 编辑

              @2446694 组件是:mirai-core-2.15.0M1

              1 条回复 最后回复 回复 引用 0
              • abc408880155
                abc408880155 @2446694 最后由 编辑

                @2446694 不清楚,不过的确会出现这种情况,但和你又有点不一样,Mac端偶尔会出现多余的艾特,iPhone和Android从没出现过。似乎只是单纯的显示问题。

                图一 Mac
                6d2d3440854254b50981dce4f9addaa7.png

                图二 iPhone
                5d432265e4d69d2b2ad05fbedeb10b8e.png

                2 1 条回复 最后回复 回复 引用 0
                • 2
                  2446694 @abc408880155 最后由 编辑

                  @abc408880155 我用的是安卓QQ8.9.50
                  我裂了,不论我用何种方式声明QuoteReply,都会带一个@TA,强迫症看着很爽

                  abc408880155 1 条回复 最后回复 回复 引用 0
                  • abc408880155
                    abc408880155 @2446694 最后由 编辑

                    @2446694 怪了,我的安卓手机Q版本为8.9.50.10650,但没出现过多余@TA,Bot登陆协议为watch

                    2 1 条回复 最后回复 回复 引用 0
                    • 2
                      2446694 @abc408880155 最后由 编辑

                      @abc408880155 对了,我用到是聊天记录的形式

                       subject.sendMessage(new ForwardMessage(
                                              preview,
                                              String.format("%s的聊天记录", botName),
                                              String.format("[回复 @%s]", event.getSenderName()),
                                              String.format("回复 @%s", event.getSenderName()),
                                              String.format("查看%d条回复消息", nodeList.size()),
                                              nodeList
                                      ));
                      
                      abc408880155 2 条回复 最后回复 回复 引用 0
                      • abc408880155
                        abc408880155 @2446694 最后由 编辑

                        此回复已被删除!
                        1 条回复 最后回复 回复 引用 0
                        • abc408880155
                          abc408880155 @2446694 最后由 编辑

                          @2446694 之前没注意到你回复的是聊天记录,我说的都是单纯的回复群消息

                          public static void sendGroupMessage(List<Long> groupIDs, Object message) {
                          for (Long groupID : groupIDs) {
                          try {
                          Group group = bot.getGroup(groupID);
                          if (message instanceof MessageChain) {
                          group.sendMessage((MessageChain) message);
                          } else if (message instanceof String) {
                          group.sendMessage((String) message);
                          } else {
                          log.error("Invalid message type: {}", message.getClass().getName());
                          }
                          } catch (NullPointerException e) {
                          log.error("Failed to send message to group {} - group is null: {}", groupID, e.getMessage());
                          } catch (IllegalStateException e) {
                          log.error("Failed to send message to group {} - account may be blocked: {}", groupID, e.getMessage());
                          } catch (Exception e) {
                          log.error("Failed to send message to group {}: {}", groupID, e.getMessage());
                          }
                          }
                          }
                          
                          1 条回复 最后回复 回复 引用 0
                          • 1 / 1
                          • First post
                            Last post
                          Powered by Mamoe Technologies & NodeBB | 友情链接 | 服务监控 | Contact