From 81874114813cbd5c1917ac949298c5bcdb14425a Mon Sep 17 00:00:00 2001 From: xtaodada Date: Mon, 15 Aug 2022 11:08:16 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Support=20set=20max=5Fupdate=5Ffile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ci.py | 2 ++ config.ini.example | 1 + defs/source.py | 8 +++++--- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ci.py b/ci.py index 089ba7d..d0b46a5 100644 --- a/ci.py +++ b/ci.py @@ -25,6 +25,7 @@ config.read("config.ini") bot_token: str = "" admin_id: int = 0 channel_id: int = 0 +max_update_file: int = 10 api_id: int = 0 api_hash: str = "" api_id = config.getint("pyrogram", "api_id", fallback=api_id) @@ -32,6 +33,7 @@ api_hash = config.get("pyrogram", "api_hash", fallback=api_hash) bot_token = config.get("basic", "bot_token", fallback=bot_token) admin_id = config.getint("basic", "admin", fallback=admin_id) channel_id = config.getint("basic", "channel_id", fallback=channel_id) +max_update_file = config.getint("basic", "max_update_file", fallback=max_update_file) """ Init httpx client """ # 使用自定义 UA headers = { diff --git a/config.ini.example b/config.ini.example index 481dbce..4bcaa2a 100644 --- a/config.ini.example +++ b/config.ini.example @@ -6,6 +6,7 @@ api_hash = 0123456789abc0123456789abc bot_token = 111:abc admin = 777000 channel_id = 0 +max_update_file = 10 [plugins] root = plugins diff --git a/defs/source.py b/defs/source.py index ab77444..4df4b46 100644 --- a/defs/source.py +++ b/defs/source.py @@ -5,7 +5,7 @@ from typing import List, Optional from httpx import AsyncClient -from ci import sqlite, headers +from ci import sqlite, headers, max_update_file from json import load from defs.format_time import now_time from defs.utils import Module @@ -45,9 +45,11 @@ async def update_data() -> None: def compare() -> List[Module]: global old_modules_index - old_modules_index = {i.name: i.latestRelease for i in old_modules} + old_modules_index.clear() + for i in old_modules: + old_modules_index[i.name] = i.latestRelease data = [i for i in new_modules if i.latestRelease != old_modules_index.get(i.name, "")] - return [] if len(data) > 7 else data + return [] if len(data) > max_update_file else data async def download(url: str, name: str, pack_name: str) -> (str, str):