Class FeishuWebhookService
java.lang.Object
com.bytedesk.core.webhook.channel.FeishuWebhookService
推送到飞书的webhook
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final org.springframework.web.client.RestTemplate -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateSimpleCard(String title, String content, String buttonText, String buttonUrl) 创建简单的卡片消息private StringgenerateSign(String secret, int timestamp) 生成签名booleansendCardMessage(String webhookUrl, Map<String, Object> card) 发送卡片消息booleansendImageMessage(String webhookUrl, String imageKey) 发送图片消息private booleansendMessage(String webhookUrl, Map<String, Object> message) 发送消息到webhookbooleansendPostMessage(String webhookUrl, String title, String content) 发送富文本消息booleansendPostMessageWithAt(String webhookUrl, String title, String content, String[] atUserIds, boolean atAll) 发送富文本消息(带@功能)booleansendShareChatMessage(String webhookUrl, String shareChatId) 发送群名片boolean发送带签名的消息(用于签名校验安全设置)booleansendTextMessage(String webhookUrl, String text) 发送文本消息booleansendTextMessageWithAt(String webhookUrl, String text, String[] atUserIds, boolean atAll) 发送文本消息(带@功能)
-
Field Details
-
restTemplate
private final org.springframework.web.client.RestTemplate restTemplate
-
-
Constructor Details
-
FeishuWebhookService
public FeishuWebhookService()
-
-
Method Details
-
sendTextMessage
发送文本消息- Parameters:
webhookUrl- webhook地址text- 文本内容- Returns:
- 是否发送成功
-
sendTextMessageWithAt
public boolean sendTextMessageWithAt(String webhookUrl, String text, String[] atUserIds, boolean atAll) 发送文本消息(带@功能)- Parameters:
webhookUrl- webhook地址text- 文本内容atUserIds- 要@的用户ID列表atAll- 是否@所有人- Returns:
- 是否发送成功
-
sendPostMessage
发送富文本消息- Parameters:
webhookUrl- webhook地址title- 标题content- 富文本内容- Returns:
- 是否发送成功
-
sendPostMessageWithAt
public boolean sendPostMessageWithAt(String webhookUrl, String title, String content, String[] atUserIds, boolean atAll) 发送富文本消息(带@功能)- Parameters:
webhookUrl- webhook地址title- 标题content- 富文本内容atUserIds- 要@的用户ID列表atAll- 是否@所有人- Returns:
- 是否发送成功
-
sendImageMessage
发送图片消息- Parameters:
webhookUrl- webhook地址imageKey- 图片key- Returns:
- 是否发送成功
-
sendCardMessage
发送卡片消息- Parameters:
webhookUrl- webhook地址card- 卡片内容- Returns:
- 是否发送成功
-
sendSignedMessage
发送带签名的消息(用于签名校验安全设置)- Parameters:
webhookUrl- webhook地址message- 消息内容secret- 签名密钥- Returns:
- 是否发送成功
-
generateSign
private String generateSign(String secret, int timestamp) throws NoSuchAlgorithmException, InvalidKeyException 生成签名- Parameters:
secret- 密钥timestamp- 时间戳- Returns:
- 签名字符串
- Throws:
NoSuchAlgorithmExceptionInvalidKeyException
-
sendMessage
发送消息到webhook- Parameters:
webhookUrl- webhook地址message- 消息内容- Returns:
- 是否发送成功
-
createSimpleCard
public Map<String,Object> createSimpleCard(String title, String content, String buttonText, String buttonUrl) 创建简单的卡片消息- Parameters:
title- 标题content- 内容buttonText- 按钮文本buttonUrl- 按钮链接- Returns:
- 卡片消息Map
-