Flush Cookies Cache on Initialization

This commit is contained in:
洛水居室 2022-12-14 23:34:44 +08:00
parent 611ad8dd4e
commit 393ab40459
No known key found for this signature in database
GPG Key ID: C9DE87DA724B88FC

View File

@ -1,3 +1,4 @@
import asyncio
import datetime import datetime
from telegram.ext import CallbackContext from telegram.ext import CallbackContext
@ -11,8 +12,16 @@ class PublicCookies(Plugin):
def __init__(self, public_cookies_service: PublicCookiesService = None): def __init__(self, public_cookies_service: PublicCookiesService = None):
self.public_cookies_service = public_cookies_service 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") @job.run_repeating(interval=datetime.timedelta(hours=2), name="PublicCookiesRefresh")
async def refresh(self, _: CallbackContext): async def refresh(self, _: CallbackContext):
logger.info("正在刷新公共Cookies池") logger.info("正在刷新公共Cookies池")
await self.public_cookies_service.refresh() await self.public_cookies_service.refresh()
logger.info("刷新公共Cookies池成功") logger.success("刷新公共Cookies池成功")