1
0
mirror of synced 2026-02-13 07:37:48 +08:00

🆕 #3725【企业微信】 增加markdown_v2的消息类型支持

This commit is contained in:
xiaoyun461
2025-10-04 01:31:24 +08:00
committed by GitHub
parent 9aa2781e68
commit 10f71234e4
5 changed files with 86 additions and 0 deletions

View File

@@ -70,6 +70,23 @@ public interface WxCpGroupRobotService {
*/
void sendMarkdown(String webhookUrl, String content) throws WxErrorException;
/**
* 发送markdown_v2类型的消息
*
* @param content markdown内容最长不超过4096个字节必须是utf8编码
* @throws WxErrorException 异常
*/
void sendMarkdownV2(String content) throws WxErrorException;
/**
* 发送markdown_v2类型的消息
*
* @param webhookUrl webhook地址
* @param content markdown内容最长不超过4096个字节必须是utf8编码
* @throws WxErrorException 异常
*/
void sendMarkdownV2(String webhookUrl, String content) throws WxErrorException;
/**
* 发送image类型的消息
*

View File

@@ -42,6 +42,11 @@ public class WxCpGroupRobotServiceImpl implements WxCpGroupRobotService {
this.sendMarkdown(this.getWebhookUrl(), content);
}
@Override
public void sendMarkdownV2(String content) throws WxErrorException {
this.sendMarkdownV2(this.getWebhookUrl(), content);
}
@Override
public void sendImage(String base64, String md5) throws WxErrorException {
this.sendImage(this.getWebhookUrl(), base64, md5);
@@ -70,6 +75,14 @@ public class WxCpGroupRobotServiceImpl implements WxCpGroupRobotService {
.toJson());
}
@Override
public void sendMarkdownV2(String webhookUrl, String content) throws WxErrorException {
this.cpService.postWithoutToken(webhookUrl, new WxCpGroupRobotMessage()
.setMsgType(GroupRobotMsgType.MARKDOWN_V2)
.setContent(content)
.toJson());
}
@Override
public void sendImage(String webhookUrl, String base64, String md5) throws WxErrorException {
this.cpService.postWithoutToken(webhookUrl, new WxCpGroupRobotMessage()

View File

@@ -252,6 +252,12 @@ public class WxCpGroupRobotMessage implements Serializable {
messageJson.add("markdown", text);
break;
}
case MARKDOWN_V2: {
JsonObject text = new JsonObject();
text.addProperty("content", this.getContent());
messageJson.add("markdown_v2", text);
break;
}
case IMAGE: {
JsonObject text = new JsonObject();
text.addProperty("base64", this.getBase64());

View File

@@ -630,6 +630,11 @@ public class WxCpConsts {
*/
public static final String MARKDOWN = "markdown";
/**
* markdown_v2消息.
*/
public static final String MARKDOWN_V2 = "markdown_v2";
/**
* 图文消息(点击跳转到外链).
*/