luojunhui 7 kuukautta sitten
vanhempi
commit
9ae31b3254
1 muutettua tiedostoa jossa 37 lisäystä ja 1 poistoa
  1. 37 1
      applications/feishuBotApi.py

+ 37 - 1
applications/feishuBotApi.py

@@ -7,6 +7,42 @@ import requests
 from applications.decoratorApi import retryOnTimeout
 
 
+def create_feishu_table(title, columns, rows):
+    """
+    create feishu table
+    :param title:
+    :param columns:
+    :param rows:
+    """
+    table_base = {
+        "header": {
+            "template": "blue",
+            "title": {
+                "content": title,
+                "tag": "plain_text"
+            }
+        },
+        "elements": [
+            {
+                "tag": "table",
+                "page_size": len(rows) + 1,
+                "row_height": "low",
+                "header_style": {
+                    "text_align": "left",
+                    "text_size": "normal",
+                    "background_style": "none",
+                    "text_color": "grey",
+                    "bold": True,
+                    "lines": 1
+                },
+                "columns": columns,
+                "rows": rows
+            }
+        ]
+    }
+    return table_base
+
+
 @retryOnTimeout()
 def bot(title, detail, mention=True):
     """
@@ -40,4 +76,4 @@ def bot(title, detail, mention=True):
             "header": {"title": {"content": head_title, "tag": "plain_text"}},
         },
     }
-    requests.request("POST", url=url, headers=headers, data=json.dumps(payload), timeout=10)
+    requests.request("POST", url=url, headers=headers, data=json.dumps(payload), timeout=10)