2022-08-05 11:42:07 +00:00
|
|
|
import datetime
|
|
|
|
|
|
|
|
from telegram.ext import CallbackContext, JobQueue
|
|
|
|
|
2022-08-06 12:37:41 +00:00
|
|
|
from core.cookies.services import PublicCookiesService
|
2022-08-05 11:42:07 +00:00
|
|
|
from logger import Log
|
|
|
|
from utils.job.manager import listener_jobs_class
|
2022-08-06 09:27:34 +00:00
|
|
|
from utils.service.inject import inject
|
2022-08-05 11:42:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
@listener_jobs_class()
|
|
|
|
class PublicCookies:
|
|
|
|
|
|
|
|
@inject
|
2022-08-31 06:48:03 +00:00
|
|
|
def __init__(self, public_cookies_service: PublicCookiesService = None):
|
2022-08-05 11:42:07 +00:00
|
|
|
self.public_cookies_service = public_cookies_service
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def build_jobs(cls, job_queue: JobQueue):
|
|
|
|
jobs = cls()
|
|
|
|
job_queue.run_repeating(jobs.refresh, datetime.timedelta(hours=2))
|
|
|
|
|
|
|
|
async def refresh(self, _: CallbackContext):
|
|
|
|
Log.info("正在刷新公共Cookies池")
|
|
|
|
await self.public_cookies_service.refresh()
|
|
|
|
Log.info("刷新公共Cookies池成功")
|