mirror of
https://github.com/PaiGramTeam/MibooGram.git
synced 2024-11-22 15:37:21 +00:00
28 lines
941 B
Python
28 lines
941 B
Python
import asyncio
|
|
import datetime
|
|
|
|
from telegram.ext import CallbackContext
|
|
|
|
from core.cookies.services import PublicCookiesService
|
|
from core.plugin import Plugin, job
|
|
from utils.log import logger
|
|
|
|
|
|
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.success("刷新公共Cookies池成功")
|