Browse Source

增加报警提示

zhangyong 8 months ago
parent
commit
9f4ace9862
3 changed files with 14 additions and 20 deletions
  1. 2 18
      common/feishu_utils.py
  2. 11 1
      data_channel/ks_ls.py
  3. 1 1
      video_rewriting/video_processor.py

+ 2 - 18
common/feishu_utils.py

@@ -364,13 +364,9 @@ class Feishu:
 
     # 飞书机器人-改造计划完成通知
     @classmethod
-    def finish_bot(cls, text):
+    def finish_bot(cls, text, url, content):
         try:
-            url = "https://open.feishu.cn/open-apis/bot/v2/hook/0553124e-7fc1-4f9b-8976-9db4218d25e2"
             headers = {'Content-Type': 'application/json'}
-            sheet_url = "https://w42nne6hzg.feishu.cn/sheets/ILb4sa0LahddRktnRipcu2vQnLb?sheet=ptgCXW"
-                # users = f"<at id=" + str(cls.get_userid(log_type)) + f">{mark_name}</at>"
-
             data = json.dumps({
                 "msg_type": "interactive",
                 "card": {
@@ -384,22 +380,10 @@ class Feishu:
                             "content": text,
                             "tag": "lark_md"
                         }
-                    }, {
-                        "actions": [{
-                            "tag": "button",
-                            "text": {
-                                "content": "**改造内容详情**",
-                                "tag": "lark_md"
-                            },
-                            "url": sheet_url,
-                            "type": "default",
-                            "value": {}
-                        }],
-                        "tag": "action"
                     }],
                     "header": {
                         "title": {
-                            "content": "【 有一条新的视频号内容改造成功 】",
+                            "content": content,
                             "tag": "plain_text"
                         }
                     }

+ 11 - 1
data_channel/ks_ls.py

@@ -2,7 +2,7 @@ import random
 import time
 import requests
 import json
-from common import Common
+from common import Common, Feishu
 from common.sql_help import sqlCollect
 
 class KSLS:
@@ -25,6 +25,14 @@ class KSLS:
             response = response.json()
             list = []
             data_all_list = response["data"]
+            if data_all_list == None or len(data_all_list) == 0:
+                try:
+                    if response["cdoe"] == 27006:
+                        Feishu.finish_bot(response["msg"],
+                                          "https://open.feishu.cn/open-apis/bot/v2/hook/575ca6a1-84b4-4a2f-983b-1d178e7b16eb", "【 Token 使用提示 】")
+                except Exception as exc:
+                    return list
+
             has_more = data_all_list["has_more"]
             next_cursor = str(data_all_list["next_cursor"])
             try:
@@ -85,5 +93,7 @@ class KSLS:
 
 
 if __name__ == '__main__':
+    Feishu.finish_bot('测试',
+                      "https://open.feishu.cn/open-apis/bot/v2/hook/575ca6a1-84b4-4a2f-983b-1d178e7b16eb", "【 Token 使用提示 】")
     # DYLS.get_video("7314923922602954022")
     KSLS.get_ksls_list("1","3xzicxg2nandemc",1,"1")

+ 1 - 1
video_rewriting/video_processor.py

@@ -149,7 +149,7 @@ class VideoProcessor:
                                     f"**原视频封面**: {video['cover']}\n"
                                     f"**原视频标题**: {video['old_title']}\n"
                                 )
-                                Feishu.finish_bot(text)
+                                Feishu.finish_bot(text, "https://open.feishu.cn/open-apis/bot/v2/hook/0553124e-7fc1-4f9b-8976-9db4218d25e2", "【 有一条新的视频号内容改造成功 】")
 
                         if values:
                             if name == "王雪珂":