🐛 Fix a update bug
This commit is contained in:
parent
11a3dca264
commit
b575e41016
3
ci.py
3
ci.py
@ -5,7 +5,7 @@ from os.path import exists
|
||||
|
||||
from pyrogram import Client
|
||||
from apscheduler.schedulers.asyncio import AsyncIOScheduler
|
||||
from httpx import AsyncClient, get
|
||||
from httpx import get
|
||||
from sqlitedict import SqliteDict
|
||||
|
||||
if not exists("data"):
|
||||
@ -37,7 +37,6 @@ channel_id = config.getint("basic", "channel_id", fallback=channel_id)
|
||||
headers = {
|
||||
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36"
|
||||
}
|
||||
client = AsyncClient(timeout=10.0, headers=headers, follow_redirects=True)
|
||||
|
||||
|
||||
# 自定义类型
|
||||
|
@ -3,7 +3,9 @@ from os.path import exists
|
||||
from shutil import copyfile
|
||||
from typing import List, Optional
|
||||
|
||||
from ci import client, sqlite
|
||||
from httpx import AsyncClient
|
||||
|
||||
from ci import sqlite, headers
|
||||
from json import load
|
||||
from defs.format_time import now_time
|
||||
from defs.utils import Module
|
||||
@ -28,7 +30,8 @@ async def update_data() -> None:
|
||||
global new_modules, old_modules, new_modules_index
|
||||
if exists(f"data{sep}modules.json"):
|
||||
copyfile(f"data{sep}modules.json", f"data{sep}old_modules.json")
|
||||
data = await client.get("https://modules.lsposed.org/modules.json")
|
||||
async with AsyncClient(timeout=10.0, headers=headers, follow_redirects=True) as client:
|
||||
data = await client.get("https://raw.githubusercontent.com/Xposed-Modules-Repo/modules/gh-pages/modules.json")
|
||||
with open(f"data{sep}modules.json", "w", encoding="utf-8") as f:
|
||||
f.write(data.text)
|
||||
data = data.json()
|
||||
@ -48,9 +51,10 @@ def compare() -> List[Module]:
|
||||
|
||||
|
||||
async def download(url: str, name: str, pack_name: str) -> (str, str):
|
||||
async with AsyncClient(timeout=10.0, headers=headers, follow_redirects=True) as client:
|
||||
content = await client.get(url)
|
||||
if content.status_code == 404:
|
||||
content = (await client.get(f"https://modules.lsposed.org/module/{pack_name}.json")).json()
|
||||
content = (await client.get(f"https://raw.githubusercontent.com/Xposed-Modules-Repo/modules/gh-pages/module/{pack_name}.json")).json()
|
||||
data = Module(content)
|
||||
url = None
|
||||
if data.releases and data.releases[0].releaseAssets:
|
||||
|
@ -41,16 +41,16 @@ async def run_every_30_minute():
|
||||
try:
|
||||
msg = await send_track_msg(file, track_msg)
|
||||
except FloodWait as e:
|
||||
print(f"Send document flood - Sleep for {e.x} second(s)")
|
||||
print(f"Send document flood - Need wait for {e.value} second(s)")
|
||||
await sleep(uniform(0.5, 1.0))
|
||||
msg = await send_track_msg(file, track_msg)
|
||||
except ButtonUrlInvalid:
|
||||
print(f"Send button error")
|
||||
print("Send button error")
|
||||
msg = await app.send_document(channel_id, file,
|
||||
caption=track_msg.text,
|
||||
force_document=True,
|
||||
parse_mode="html", )
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
with contextlib.suppress(FileNotFoundError):
|
||||
remove(file)
|
||||
@ -64,9 +64,9 @@ async def run_every_30_minute():
|
||||
await sleep(e.value + uniform(0.5, 1.0))
|
||||
msg = await send_track_msg(None, track_msg)
|
||||
except ButtonUrlInvalid:
|
||||
print(f"Send button error")
|
||||
print("Send button error")
|
||||
msg = await app.send_message(channel_id, track_msg.text, parse_mode="html", )
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
await sleep(uniform(0.5, 2.0))
|
||||
data_ = sqlite.get(i.name, {"msg_link": ""})
|
||||
|
@ -1,4 +1,4 @@
|
||||
Pyrogram>=2.0.35
|
||||
Pyrogram>=2.0.40
|
||||
Tgcrypto>=1.2.3
|
||||
httpx>=0.22.0
|
||||
apscheduler>=3.8.1
|
||||
|
Loading…
Reference in New Issue
Block a user