Prechádzať zdrojové kódy

outside article monitor

luojunhui 1 mesiac pred
rodič
commit
889cf2a12b

+ 16 - 11
tasks/monitor_tasks/outside_gzh_articles_monitor.py

@@ -1,4 +1,5 @@
 import time
+import datetime
 
 from tqdm import tqdm
 from pymysql.cursors import DictCursor
@@ -38,7 +39,7 @@ class OutsideGzhArticlesManager(Const):
         update_query = f"""
             update outside_gzh_account_monitor
             set illegal_status = %s, illegal_reason = %s
-            where id = %s and illegal_reason = %s
+            where id = %s and illegal_status = %s
         """
         self.long_articles_client.save(
             query=update_query,
@@ -126,13 +127,14 @@ class OutsideGzhArticlesCollector(OutsideGzhArticlesManager):
                 self.feishu_bot_api.bot(
                     title="文章违规告警",
                     detail={
-                        "account_name": article["account_name"],
-                        "title": article["title"],
-                        "reason": illegal_reason,
-                        "publish_timestamp": create_timestamp,
-                        "account_source": article["account_source"],
+                        "账号名称": article["account_name"],
+                        "标题": article["title"],
+                        "违规理由": illegal_reason,
+                        "发布日期": datetime.datetime.fromtimestamp(create_timestamp).strftime('%Y-%m-%d %H:%M:%S'),
+                        "账号合作商": article["account_source"],
                     },
                     env="outside_gzh_monitor",
+                    mention=False
                 )
 
             elif response_code == self.SUCCESS_CODE:
@@ -195,16 +197,18 @@ class OutsideGzhArticlesMonitor(OutsideGzhArticlesManager):
         response_code = article_detail["code"]
         if response_code == self.ILLEGAL_CODE:
             illegal_reason = article_detail.get("msg")
+            # illegal_reason = '测试报警功能'
             self.feishu_bot_api.bot(
                 title="文章违规告警",
                 detail={
-                    "account_name": article["account_name"],
-                    "title": article["title"],
-                    "reason": illegal_reason,
-                    "publish_date": article["publish_date"],
-                    "account_source": article["account_source"],
+                    "账号名称": article["account_name"],
+                    "标题": article["title"],
+                    "违规理由": illegal_reason,
+                    "发布日期": str(article["publish_date"]),
+                    "账号合作商": article["account_source"],
                 },
                 env="outside_gzh_monitor",
+                mention=False
             )
             article_id = article["id"]
             self.update_article_illegal_status(article_id, illegal_reason)
@@ -216,6 +220,7 @@ class OutsideGzhArticlesMonitor(OutsideGzhArticlesManager):
         for article in tqdm(article_list):
             try:
                 self.check_each_article(article)
+
             except Exception as e:
                 print(
                     f"crawler failed: account_name: {article['account_name']}\n"