diff --git a/plugins/jobs/public_cookies.py b/plugins/jobs/public_cookies.py index df223e7..eacd0a9 100644 --- a/plugins/jobs/public_cookies.py +++ b/plugins/jobs/public_cookies.py @@ -1,3 +1,4 @@ +import asyncio import datetime from telegram.ext import CallbackContext @@ -11,8 +12,16 @@ class PublicCookies(Plugin): def __init__(self, public_cookies_service: PublicCookiesService = None): self.public_cookies_service = public_cookies_service + async def __async_init__(self): + async def _refresh(): + logger.info("正在刷新公共Cookies池") + await self.public_cookies_service.refresh() + logger.success("刷新公共Cookies池成功") + + asyncio.create_task(_refresh()) + @job.run_repeating(interval=datetime.timedelta(hours=2), name="PublicCookiesRefresh") async def refresh(self, _: CallbackContext): logger.info("正在刷新公共Cookies池") await self.public_cookies_service.refresh() - logger.info("刷新公共Cookies池成功") + logger.success("刷新公共Cookies池成功")