Support set max_update_file

This commit is contained in:
xtaodada 2022-08-15 11:08:16 +08:00
parent cef96a01a6
commit 8187411481
Signed by: xtaodada
GPG Key ID: 4CBB3F4FA8C85659
3 changed files with 8 additions and 3 deletions

2
ci.py
View File

@ -25,6 +25,7 @@ config.read("config.ini")
bot_token: str = "" bot_token: str = ""
admin_id: int = 0 admin_id: int = 0
channel_id: int = 0 channel_id: int = 0
max_update_file: int = 10
api_id: int = 0 api_id: int = 0
api_hash: str = "" api_hash: str = ""
api_id = config.getint("pyrogram", "api_id", fallback=api_id) 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) bot_token = config.get("basic", "bot_token", fallback=bot_token)
admin_id = config.getint("basic", "admin", fallback=admin_id) admin_id = config.getint("basic", "admin", fallback=admin_id)
channel_id = config.getint("basic", "channel_id", fallback=channel_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 """ """ Init httpx client """
# 使用自定义 UA # 使用自定义 UA
headers = { headers = {

View File

@ -6,6 +6,7 @@ api_hash = 0123456789abc0123456789abc
bot_token = 111:abc bot_token = 111:abc
admin = 777000 admin = 777000
channel_id = 0 channel_id = 0
max_update_file = 10
[plugins] [plugins]
root = plugins root = plugins

View File

@ -5,7 +5,7 @@ from typing import List, Optional
from httpx import AsyncClient from httpx import AsyncClient
from ci import sqlite, headers from ci import sqlite, headers, max_update_file
from json import load from json import load
from defs.format_time import now_time from defs.format_time import now_time
from defs.utils import Module from defs.utils import Module
@ -45,9 +45,11 @@ async def update_data() -> None:
def compare() -> List[Module]: def compare() -> List[Module]:
global old_modules_index 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, "")] 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): async def download(url: str, name: str, pack_name: str) -> (str, str):