diff --git a/src/main/java/io/github/doocs/im/constant/GroupAtAllFlag.java b/src/main/java/io/github/doocs/im/constant/GroupAtAllFlag.java
new file mode 100644
index 0000000000000000000000000000000000000000..d0524ad993984888b0b924586271b505b592d5d8
--- /dev/null
+++ b/src/main/java/io/github/doocs/im/constant/GroupAtAllFlag.java
@@ -0,0 +1,24 @@
+package io.github.doocs.im.constant;
+
+/**
+ * 群组@全体成员标识
+ *
+ * @author Vensin
+ * @since 2025/1/25 13:52
+ */
+public final class GroupAtAllFlag {
+
+ /**
+ * 群组消息 @all
+ */
+ public static final int AT_ALL = 1;
+
+ /**
+ * 群组消息 @指定成员
+ */
+ public static final int AT_MEMBER = 0;
+
+ private GroupAtAllFlag() {
+
+ }
+}
diff --git a/src/main/java/io/github/doocs/im/model/request/GroupAtInfo.java b/src/main/java/io/github/doocs/im/model/request/GroupAtInfo.java
new file mode 100644
index 0000000000000000000000000000000000000000..9f96ccde03f4f99f5fac0e3e071bf40e20b9d00e
--- /dev/null
+++ b/src/main/java/io/github/doocs/im/model/request/GroupAtInfo.java
@@ -0,0 +1,84 @@
+package io.github.doocs.im.model.request;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import java.io.Serializable;
+
+/**
+ * 群@消息
+ *
+ * @author Vensin
+ * @since 2025/1/25 13:43
+ */
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class GroupAtInfo implements Serializable {
+
+ private static final long serialVersionUID = -11238790123456789L;
+
+ /**
+ * 为1表示 @all,为0表示 @某个群成员
+ * {@link io.github.doocs.im.constant.GroupAtAllFlag}
+ */
+ @JsonProperty("GroupAtAllFlag")
+ private Integer groupAtAllFlag;
+
+ /**
+ * 表示 @的具体的群成员,如果为 @all,则无需填写该字段
+ * 消息体里面@的用户按顺序逐一对应,该字段上送的是用户的userId,消息体里的'@'后面内容任意,一般为用户的昵称
+ */
+ @JsonProperty("GroupAt_Account")
+ private String groupAtAccount;
+
+ public static GroupAtInfo.Builder builder() {
+ return new GroupAtInfo.Builder();
+ }
+
+
+ public Integer getGroupAtAllFlag() {
+ return groupAtAllFlag;
+ }
+
+ public void setGroupAtAllFlag(Integer groupAtAllFlag) {
+ this.groupAtAllFlag = groupAtAllFlag;
+ }
+
+ public String getGroupAtAccount() {
+ return groupAtAccount;
+ }
+
+ public void setGroupAtAccount(String groupAtAccount) {
+ this.groupAtAccount = groupAtAccount;
+ }
+
+
+ public static class Builder {
+ private Integer groupAtAllFlag;
+ private String groupAtAccount;
+
+ private Builder() {
+ }
+
+ public Builder groupAtAllFlag(Integer groupAtAllFlag) {
+ this.groupAtAllFlag = groupAtAllFlag;
+ return this;
+ }
+
+ public Builder groupAtAccount(String groupAtAccount) {
+ this.groupAtAccount = groupAtAccount;
+ return this;
+ }
+
+ public GroupAtInfo build() {
+ GroupAtInfo groupAtInfo = new GroupAtInfo();
+ groupAtInfo.groupAtAllFlag = this.groupAtAllFlag;
+ groupAtInfo.groupAtAccount = this.groupAtAccount;
+ return groupAtInfo;
+ }
+
+ public static Builder builder() {
+ return new Builder();
+ }
+ }
+
+}
diff --git a/src/main/java/io/github/doocs/im/model/request/SendGroupMsgRequest.java b/src/main/java/io/github/doocs/im/model/request/SendGroupMsgRequest.java
index 7203b9a6e68fbf69a5ffed8588c2e9ed37b411fe..51163007f947ba54eb4ce0a79fa6e23296b6dfa4 100644
--- a/src/main/java/io/github/doocs/im/model/request/SendGroupMsgRequest.java
+++ b/src/main/java/io/github/doocs/im/model/request/SendGroupMsgRequest.java
@@ -48,6 +48,12 @@ public class SendGroupMsgRequest extends GenericRequest implements Serializable
@JsonProperty("From_Account")
private String fromAccount;
+ /**
+ * 群组消息设置@的用户,跟消息体里面@的用户按顺序逐一对应。
+ */
+ @JsonProperty("GroupAtInfo")
+ private List groupAtInfos;
+
/**
* 线推送信息配置,详细可参阅 消息格式描述
*/
@@ -129,6 +135,14 @@ public class SendGroupMsgRequest extends GenericRequest implements Serializable
this.topicId = topicId;
}
+ public SendGroupMsgRequest(String groupId, Long random, String msgPriority, List msgBody,
+ String fromAccount, OfflinePushInfo offlinePushInfo, List forbidCallbackControl,
+ Integer onlineOnlyFlag, List sendMsgControl, String cloudCustomData,
+ Integer supportMessageExtension, String toAccount, String topicId, List groupAtInfos) {
+ this(groupId, random, msgPriority, msgBody, fromAccount, offlinePushInfo, forbidCallbackControl, onlineOnlyFlag, sendMsgControl, cloudCustomData, supportMessageExtension, toAccount, topicId);
+ this.groupAtInfos = groupAtInfos;
+ }
+
private SendGroupMsgRequest(Builder builder) {
this.groupId = builder.groupId;
this.random = builder.random;
@@ -143,6 +157,7 @@ public class SendGroupMsgRequest extends GenericRequest implements Serializable
this.supportMessageExtension = builder.supportMessageExtension;
this.toAccount = builder.toAccount;
this.topicId = builder.topicId;
+ this.groupAtInfos = builder.groupAtInfos;
}
public static Builder builder() {
@@ -253,12 +268,20 @@ public class SendGroupMsgRequest extends GenericRequest implements Serializable
this.topicId = topicId;
}
+ public List getGroupAtInfos() {
+ return groupAtInfos;
+ }
+
+ public void setGroupAtInfos(List groupAtInfos) {
+ this.groupAtInfos = groupAtInfos;
+ }
public static final class Builder {
private String groupId;
private Long random;
private String msgPriority;
private List msgBody;
+ private List groupAtInfos;
private String fromAccount;
private OfflinePushInfo offlinePushInfo;
private List forbidCallbackControl;
@@ -296,6 +319,11 @@ public class SendGroupMsgRequest extends GenericRequest implements Serializable
return this;
}
+ public Builder groupAtInfos(List groupAtInfos) {
+ this.groupAtInfos = groupAtInfos;
+ return this;
+ }
+
public Builder fromAccount(String fromAccount) {
this.fromAccount = fromAccount;
return this;
diff --git a/src/test/java/io/github/doocs/im/core/GroupTest.java b/src/test/java/io/github/doocs/im/core/GroupTest.java
index 3b0e26d86e0a751063f5c4293ad9d3374df0d61c..9f769bc25939aaf5a7da8cc34fa053cc0bd4af0d 100644
--- a/src/test/java/io/github/doocs/im/core/GroupTest.java
+++ b/src/test/java/io/github/doocs/im/core/GroupTest.java
@@ -702,4 +702,23 @@ class GroupTest {
System.out.println(result);
Assertions.assertEquals(ErrorCode.SUCCESS.getCode(), result.getErrorCode());
}
+
+ @Test
+ void testGroupMessageWithAtInfo() throws IOException {
+ TIMTextMsgElement msgEle = new TIMTextMsgElement();
+ msgEle.setMsgContent(new TIMTextMsgElement.TextMsgContent("Hello @小鬼 欢迎加入小组"));
+
+ SendGroupMsgRequest request = SendGroupMsgRequest.builder()
+ .groupId("shg_90")
+ .fromAccount("260")
+ .msgBody(Collections.singletonList(msgEle))
+ .groupAtInfos(Collections.singletonList(GroupAtInfo.builder()
+ .groupAtAllFlag(GroupAtAllFlag.AT_MEMBER)
+ .groupAtAccount("276").build()))
+ .build();
+
+ SendGroupMsgResult result = client.group.sendGroupMsg(request);
+ System.out.println(result);
+ Assertions.assertEquals(ErrorCode.SUCCESS.getCode(), result.getErrorCode());
+ }
}
\ No newline at end of file