feishu.groovy 587 B

12345678910111213141516171819202122
  1. #!/usr/bin/env groovy
  2. import groovy.json.JsonOutput
  3. import org.feishu.SignUtil
  4. def send(String webhook, String secret, Map card) {
  5. Long ts = System.currentTimeMillis() / 1000
  6. String sign = SignUtil.genSign(secret, ts)
  7. def body = [
  8. timestamp: ts,
  9. sign : sign,
  10. msg_type : "interactive",
  11. card : card
  12. ]
  13. httpRequest(
  14. httpMode: 'POST',
  15. requestBody: JsonOutput.toJson(body),
  16. contentType: 'APPLICATION_JSON',
  17. url: webhook,
  18. consoleLogResponseBody: true,
  19. validResponseCodes: '200'
  20. )
  21. }