Class FeishuWebhookService

java.lang.Object
com.bytedesk.core.webhook.channel.FeishuWebhookService

@Component public class FeishuWebhookService extends Object
推送到飞书的webhook
  • Field Details

    • restTemplate

      private final org.springframework.web.client.RestTemplate restTemplate
  • Constructor Details

    • FeishuWebhookService

      public FeishuWebhookService()
  • Method Details

    • sendTextMessage

      public boolean sendTextMessage(String webhookUrl, String text)
      发送文本消息
      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

      public boolean sendPostMessage(String webhookUrl, String title, String content)
      发送富文本消息
      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

      public boolean sendImageMessage(String webhookUrl, String imageKey)
      发送图片消息
      Parameters:
      webhookUrl - webhook地址
      imageKey - 图片key
      Returns:
      是否发送成功
    • sendShareChatMessage

      public boolean sendShareChatMessage(String webhookUrl, String shareChatId)
      发送群名片
      Parameters:
      webhookUrl - webhook地址
      shareChatId - 群ID
      Returns:
      是否发送成功
    • sendCardMessage

      public boolean sendCardMessage(String webhookUrl, Map<String,Object> card)
      发送卡片消息
      Parameters:
      webhookUrl - webhook地址
      card - 卡片内容
      Returns:
      是否发送成功
    • sendSignedMessage

      public boolean sendSignedMessage(String webhookUrl, Map<String,Object> message, String secret)
      发送带签名的消息(用于签名校验安全设置)
      Parameters:
      webhookUrl - webhook地址
      message - 消息内容
      secret - 签名密钥
      Returns:
      是否发送成功
    • generateSign

      private String generateSign(String secret, int timestamp) throws NoSuchAlgorithmException, InvalidKeyException
      生成签名
      Parameters:
      secret - 密钥
      timestamp - 时间戳
      Returns:
      签名字符串
      Throws:
      NoSuchAlgorithmException
      InvalidKeyException
    • sendMessage

      private boolean sendMessage(String webhookUrl, Map<String,Object> message)
      发送消息到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