refactor: improved error handling, timeouts and use temp files

This commit is contained in:
2026-05-21 22:14:29 +02:00
parent 0a31601b77
commit 1e08391e0e
3 changed files with 26 additions and 18 deletions
+13 -5
View File
@@ -90,11 +90,19 @@ def load_missing_modules():
os.makedirs(custom_modules_path, exist_ok=True)
try:
f = requests.get(
"https://raw.githubusercontent.com/The-MoonTg-project/custom_modules/main/full.txt"
).text
except Exception:
logging.error("Failed to fetch custom modules list")
resp = requests.get(
"https://raw.githubusercontent.com/The-MoonTg-project/custom_modules/main/full.txt",
timeout=10,
)
if not resp.ok:
logging.error(
"Failed to fetch custom modules list: HTTP %s",
resp.status_code,
)
return
f = resp.text
except Exception as e:
logging.error("Failed to fetch custom modules list: %s", e)
return
modules_dict = {
line.split("/")[-1].split()[0]: line.strip() for line in f.splitlines()