diff --git a/README.md b/README.md index c52a991..7a85228 100644 --- a/README.md +++ b/README.md @@ -7,10 +7,17 @@ ![output](https://github.com/ExpTechTW/RTS-GIF-Maker/assets/44525760/fa644258-edab-42cc-bf1b-897f89bb078d) ## 索引 +- [說明](#說明) - [貢獻者](#貢獻者) - [發佈規則](#發佈規則) - [合作](#合作) +## 說明 +- [main.py](https://github.com/ExpTechTW/RTS-GIF-Maker/blob/Release/main.py) 手動輸入時間戳生成 `GIF` 到 相同路徑 +- [webhook.py](https://github.com/ExpTechTW/RTS-GIF-Maker/blob/Release/webhook.py) 自動抓取 [ExpTech | 探索科技](https://github.com/ExpTechTW) 檢知報告api 生成 `GIF` 並使用 `webhook` 發送到 `Discord` +> [!WARNING] +> 開啟 [webhook.py](https://github.com/ExpTechTW/RTS-GIF-Maker/blob/Release/webhook.py) 時,會在相同路徑生成名為 `first_5_timestamp.json` 記錄最後五筆 ID + ## 貢獻者 - whes1015 `文檔` diff --git a/webhook.py b/webhook.py index 73ba710..0f702a8 100644 --- a/webhook.py +++ b/webhook.py @@ -152,8 +152,16 @@ def init(self) -> None: return if not os.path.exists(self.first_5_timestamp_folder): - with open(self.first_5_timestamp_folder, "w") as f: - json.dump(self.get_first_5_timestamp(), f, ensure_ascii=False, indent=4) + got_response = self.get_response_with_retry() + if got_response: + first_5_ids = self.get_first_5_timestamp(got_response) + with open(self.first_5_timestamp_folder, "w") as f: + json.dump(first_5_ids, f, ensure_ascii=False, indent=4) + self.first_5_timestamp = first_5_ids + else: + self.log("無法獲取初始資料,創建空的 JSON 文件", 2) + with open(self.first_5_timestamp_folder, "w") as f: + json.dump([], f, ensure_ascii=False, indent=4) else: self.first_5_timestamp = self.get_data_from_json() @@ -225,7 +233,7 @@ def start(self): while retry_count < max_retries: try: - response = requests.get(f"https://api-2.exptech.dev/api/v1/trem/rts-image/{timestamp}",) + response = requests.get(f"https://api-1.exptech.dev/api/v1/trem/rts-image/{timestamp}",) if response.status_code == 200: result_image = self.raw.copy()