|
@@ -0,0 +1,40 @@
|
|
|
+package com.tzld.piaoquan.longarticle.utils;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.codec.binary.Base64;
|
|
|
+
|
|
|
+import javax.crypto.Mac;
|
|
|
+import javax.crypto.spec.SecretKeySpec;
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
|
+import java.security.InvalidKeyException;
|
|
|
+import java.security.NoSuchAlgorithmException;
|
|
|
+
|
|
|
+@Slf4j
|
|
|
+public class LarkRobotUtil {
|
|
|
+
|
|
|
+
|
|
|
+ private static final String URL = "https://open.feishu.cn/open-apis/bot/v2/hook/93787b70-33d3-42c1-beae-c09310c9b38b";
|
|
|
+
|
|
|
+ private static final HttpPoolClientUtil HTTP_POOL_CLIENT_UTIL_DEFAULT = HttpClientUtil.create(3000, 10000, 20, 100, 3, 3000);
|
|
|
+
|
|
|
+
|
|
|
+ public static void sendMessage(String msg) {
|
|
|
+ sendMessage("text", "长文发布报警:" + msg);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void sendMessage(String type, String msg) {
|
|
|
+ try {
|
|
|
+ JSONObject param = new JSONObject();
|
|
|
+ param.put("msg_type", type);
|
|
|
+ JSONObject content = new JSONObject();
|
|
|
+ content.put("text", msg);
|
|
|
+ param.put("content", content);
|
|
|
+ HTTP_POOL_CLIENT_UTIL_DEFAULT.post(URL, param.toJSONString());
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("Lark sendMessage error", e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|