mirror of
https://github.com/PaiGramTeam/PamGram.git
synced 2024-11-21 21:58:04 +00:00
🔧 支持使用配置文件是否启用 genshin.py
模块的缓存
This commit is contained in:
parent
bf90ca55f9
commit
291b21f674
@ -53,6 +53,9 @@ LOGGER_LOCALS_MAX_STRING=80
|
||||
# CONNECT_TIMEOUT = 10
|
||||
# POOL_TIMEOUT = 10
|
||||
|
||||
# genshin.py 缓存配置 可选配置项
|
||||
# GENSHIN_TTL = 3600
|
||||
|
||||
# mtp 客户端 可选配置项
|
||||
# API_ID=12345
|
||||
# API_HASH="abcdefg"
|
||||
|
@ -63,6 +63,8 @@ class BotConfig(BaseSettings):
|
||||
connect_timeout: Optional[float] = None
|
||||
pool_timeout: Optional[float] = None
|
||||
|
||||
genshin_ttl: Optional[int] = None
|
||||
|
||||
enka_network_api_agent: str = ""
|
||||
pass_challenge_api: str = ""
|
||||
pass_challenge_app_key: str = ""
|
||||
|
@ -18,6 +18,7 @@ from typing_extensions import ParamSpec
|
||||
|
||||
from core.base.redisdb import RedisDB
|
||||
from core.bot import bot
|
||||
from core.config import config
|
||||
from core.cookies.services import CookiesService, PublicCookiesService
|
||||
from core.error import ServiceNotFoundError
|
||||
from core.user.services import UserService
|
||||
@ -47,8 +48,8 @@ public_cookies_service = cast(PublicCookiesService, public_cookies_service)
|
||||
redis_db = bot.services.get(RedisDB)
|
||||
redis_db = cast(RedisDB, redis_db)
|
||||
genshin_cache: Optional[genshin.RedisCache] = None
|
||||
if redis_db:
|
||||
genshin_cache = genshin.RedisCache(redis_db.client)
|
||||
if redis_db and config.genshin_ttl:
|
||||
genshin_cache = genshin.RedisCache(redis_db.client, ttl=config.genshin_ttl)
|
||||
|
||||
REGION_MAP = {
|
||||
"1": RegionEnum.HYPERION,
|
||||
@ -204,7 +205,7 @@ async def async_re_sub(
|
||||
# noinspection PyCallingNonCallable
|
||||
replaced = repl(match)
|
||||
result += temp[: match.span(1)[0]] + (replaced or repl)
|
||||
temp = temp[match.span(1)[1] :]
|
||||
temp = temp[match.span(1)[1]:]
|
||||
else:
|
||||
while match := re.search(pattern, temp, flags=flags):
|
||||
replaced = None
|
||||
@ -215,5 +216,5 @@ async def async_re_sub(
|
||||
# noinspection PyCallingNonCallable
|
||||
replaced = repl(match)
|
||||
result += temp[: match.span(1)[0]] + (replaced or repl)
|
||||
temp = temp[match.span(1)[1] :]
|
||||
temp = temp[match.span(1)[1]:]
|
||||
return result + temp
|
||||
|
Loading…
Reference in New Issue
Block a user