jack 7 månader sedan
förälder
incheckning
d67443edc7
2 ändrade filer med 17 tillägg och 3 borttagningar
  1. 2 3
      daily/daily_3dos.py
  2. 15 0
      utils/utils_get_public_ip.py

+ 2 - 3
daily/daily_3dos.py

@@ -9,8 +9,7 @@ from concurrent.futures import ThreadPoolExecutor, as_completed
 sys.path.append(os.path.join(os.path.abspath(__file__).split('auto')[0] + 'auto'))
 from utils.utils_send_gotify import *
 from utils.utils_daily_task_scheduler import *
-
-DEBUG_MODE = 0
+from utils.utils_get_public_ip import get_public_ip
 
 
 def daily_claim_3dos(email, password):
@@ -171,7 +170,7 @@ def main():
 
 if __name__ == "__main__":
     print('开始 3dos 每日签到')
-    if DEBUG_MODE:
+    if get_public_ip != '154.21.201.205':
         file_path = os.path.join(os.getcwd(), "daily_3dos.txt")
     else:
         file_path = os.path.join(os.getcwd(), "auto", "daily", "daily_3dos.txt")

+ 15 - 0
utils/utils_get_public_ip.py

@@ -0,0 +1,15 @@
+# -*- coding: utf-8 -*-
+import httpx
+
+
+def get_public_ip():
+    try:
+        # 使用 httpx 发起请求
+        response = httpx.get("https://httpbin.org/ip", timeout=10)
+        response.raise_for_status()  # 检查请求是否成功
+        ip_data = response.json()
+        return ip_data["origin"]
+    except httpx.RequestError as e:
+        print(f"An error occurred while obtaining the public IP address.:{e}")
+        exit(1)
+