Skip to content

Commit 1fe8fe4

Browse files
authored
🎨 #3179 【企业微信】群机器人发送消息接口中增加发送语音类型消息的方法
1 parent 344263b commit 1fe8fe4

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpGroupRobotService.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,15 @@ public interface WxCpGroupRobotService {
9898
*/
9999
void sendFile(String webhookUrl, String mediaId) throws WxErrorException;
100100

101+
/**
102+
* 发送文件类型的消息
103+
*
104+
* @param webhookUrl webhook地址
105+
* @param mediaId 语音文件id
106+
* @throws WxErrorException 异常
107+
*/
108+
void sendVoice(String webhookUrl, String mediaId) throws WxErrorException;
109+
101110
/**
102111
* 发送模板卡片消息
103112
* @param webhookUrl

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpGroupRobotServiceImpl.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,14 @@ public void sendFile(String webhookUrl, String mediaId) throws WxErrorException
9292
.setMediaId(mediaId).toJson());
9393
}
9494

95+
96+
@Override
97+
public void sendVoice(String webhookUrl, String mediaId) throws WxErrorException {
98+
this.cpService.postWithoutToken(webhookUrl, new WxCpGroupRobotMessage()
99+
.setMsgType(GroupRobotMsgType.VOICE)
100+
.setMediaId(mediaId).toJson());
101+
}
102+
95103
@Override
96104
public void sendTemplateCardMessage(String webhookUrl, WxCpGroupRobotMessage wxCpGroupRobotMessage) throws WxErrorException {
97105
this.cpService.postWithoutToken(webhookUrl, wxCpGroupRobotMessage.toJson());

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/constant/WxCpConsts.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,11 @@ public static class GroupRobotMsgType {
536536
*/
537537
public static final String FILE = "file";
538538

539+
/**
540+
* 文件类型消息.
541+
*/
542+
public static final String VOICE = "voice";
543+
539544
/**
540545
* 模版类型消息.
541546
*/

0 commit comments

Comments
 (0)