jack 7 сар өмнө
parent
commit
7efe3aaa49

+ 1 - 1
archive/message_coinmarketcap.py

@@ -53,7 +53,7 @@ class CheckCoinmarketcap:
             context += '\n{}'.format(datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
             print(context)
             # 推送到 message
-            GotifyNotifier('实时coin价格', context, 'AgfOJESqDKftBTQ').send_message()
+            GotifyNotifier('实时coin价格', context, 'coin').send_message()
         else:
             print('no data!')
 

+ 2 - 2
archive/message_maizi_gas.py

@@ -51,10 +51,10 @@ try:
 
     if int(fastest) > 30 or int(fast) > 30 or int(standard) > 30 or int(low) > 30 or int(base) > 30:
         # 推送到 message
-        GotifyNotifier('gas 费大于 30', result, 'AgfOJESqDKftBTQ').send_message()
+        GotifyNotifier('gas 费大于 30', result, 'coin').send_message()
     elif int(fastest) < 5 or int(fast) < 5 or int(standard) < 5 or int(low) < 5 or int(base) < 5:
         # 推送到 message
-        GotifyNotifier('gas 费小于 5', result, 'AgfOJESqDKftBTQ').send_message()
+        GotifyNotifier('gas 费小于 5', result, 'coin').send_message()
 
 
 except Exception as e:

+ 1 - 1
archive/message_vix.py

@@ -65,7 +65,7 @@ class CheckVIX:
             print(f'发送消息: {context}')
             context += '\n{}'.format(datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
             # 推送到 message
-            GotifyNotifier('vix恐慌指数', context, 'AgfOJESqDKftBTQ').send_message()
+            GotifyNotifier('vix恐慌指数', context, 'coin').send_message()
         else:
             print(f"VIX恐慌指数小于{self.check_value},不发送消息\n{context}")
 

+ 1 - 1
base/base_daily_logs_send.py

@@ -63,7 +63,7 @@ class LogsHandle(object):
             S = SendEmail(subject=subject, title=title, text=text)
             S.send()
 
-            G = GotifyNotifier(title=title, message=text, token='A9KF--mx_12PjSu')
+            G = GotifyNotifier(title=title, message=text, token='base')
             G.send_message()
         else:
             print("No error logs found for today.")

+ 35 - 0
message/message_chaincatcher.py

@@ -0,0 +1,35 @@
+from playwright.sync_api import sync_playwright
+from bs4 import BeautifulSoup
+import time
+from datetime import datetime
+
+from utils.utils_send_gotify import *
+
+
+def chaincatcher_news():
+    url = "https://www.chaincatcher.com/news"
+    with sync_playwright() as p:
+        browser = p.chromium.launch(headless=True)
+        page = browser.new_page()
+        page.goto(url)
+        time.sleep(2)
+        start_time = time.time()
+        while time.time() - start_time < 10:
+            page.mouse.wheel(0, 100)
+            time.sleep(0.1)
+        page_content = page.content()
+        browser.close()
+        soup = BeautifulSoup(page_content, 'html.parser')
+        contents = [span.get_text(strip=True) for span in soup.find_all('span', class_='text', attrs={'data-v-aea07cf0': True}) if "微信扫码" not in span]
+        result = '\n'.join(contents)
+        result += f'\n推送时间: {datetime.now().strftime("%Y年%m月%d日 %H时%M分%S秒")}'
+
+        if result:
+            gotify_notifier = GotifyNotifier(title='ChainCatcher News', message=result, token_name='news')
+            gotify_notifier.send_message()
+            print(result)
+        else:
+            print("No news found.")
+
+
+chaincatcher_news()

+ 1 - 1
message/message_coin_detail.py

@@ -194,7 +194,7 @@ def main():
                 text += f"Failed to fetch Gas data. retry count: {retry}"
 
     if text:
-        GotifyNotifier('Real-time coin price\n', text, 'AgfOJESqDKftBTQ').send_message()
+        GotifyNotifier('Real-time coin price\n', text, 'coin').send_message()
     else:
         print('No Data')
 

+ 1 - 1
message/message_dlt.py

@@ -148,7 +148,7 @@ class CheckDlt:
         title = f'dlt {subject}'
 
         # 推送到 message
-        GotifyNotifier(title, text, 'A3bqt9Dlbs.fPUb').send_message()
+        GotifyNotifier(title, text, 'dlt').send_message()
 
         # 发送到邮件
         SendEmail(title, title, text).send()

+ 1 - 1
message/message_get_one_week_weather.py

@@ -58,7 +58,7 @@ class Weather():
             one_week_weather)
 
         # 推送到 message
-        GotifyNotifier('天气预报数', text, 'A9KF--mx_12PjSu').send_message()
+        GotifyNotifier('天气预报数', text, 'weather').send_message()
 
         self.logs_handle.logs_write('Weather forecast', '天气预报数据已获取', 'done', False)
 

+ 1 - 1
remind/auto_remind.py

@@ -48,7 +48,7 @@ class AutoRemind:
 
                     # 组装完标题和正文, 准备发送消息
                     # 推送到 message
-                    GotifyNotifier(title, context, 'AT2QGp_vyCX4akW').send_message()
+                    GotifyNotifier(title, context, 'news').send_message()
 
                     # 推送到 serverchan
                     ServerChanNotifier(title, context.replace('\n', '\n\n')).send_message()

+ 6 - 0
utils/utils_ql_create_tasks.py

@@ -185,6 +185,12 @@ def main():
                         "command": "python3 {}/message_airdrop_tasks.py".format(message_path),
                         "schedule": "0 8,20 * * *",
                         "labels": ["message"]
+                    },
+                    {
+                        "name": "链捕手快讯消息推送",
+                        "command": "python3 {}/message_chaincatcher.py".format(message_path),
+                        "schedule": "0 * * * *",
+                        "labels": ["message"]
                     }
                 ],
                 'manual': [

+ 19 - 2
utils/utils_send_gotify.py

@@ -4,12 +4,29 @@ import httpx
 
 
 class GotifyNotifier:
-    def __init__(self, title, message, token='A9KF--mx_12PjSu'):
+    def __init__(self, title, message, token_name=''):
         self.gotify_url = 'https://gotify.erhe.top'
-        self.app_token = token
+        self.app_token = self.match_token_name(token_name)
         self.title = title
         self.message = message
 
+    def match_token_name(self, name):
+        token_name_dict = {
+            'base': 'A8EVb0Cmxnb2vfk',
+            'coin': 'AgfOJESqDKftBTQ',
+            'dlt': 'A3bqt9Dlbs.fPUb',
+            'AirdropTasksNews': 'Aoe0VKt-kkZnm8d',
+            'weather': 'A9KF--mx_12PjSu',
+            'news': 'AT2QGp_vyCX4akW',
+            'test': 'A0Xg6ZE5946iBYg',
+        }
+
+        token = token_name_dict.get(name)
+        if token:
+            return token
+        else:
+            return token_name_dict['base']
+
     def send_message(self):
         # 构建POST请求的headers
         headers = {