mirror of
https://github.com/PaiGramTeam/MibooGram.git
synced 2024-11-16 04:45:27 +00:00
✨ 添加公共Cookie池刷新任务
2小时执行一次
This commit is contained in:
parent
5f533a29b8
commit
5a3810c44a
@ -35,7 +35,6 @@ class PublicCookiesService:
|
||||
"""刷新公共Cookies 定时任务
|
||||
:return:
|
||||
"""
|
||||
Log.info("正在初始化公共Cookies")
|
||||
user_list: List[int] = []
|
||||
cookies_list = await self._repository.get_all_cookies(RegionEnum.HYPERION) # 从数据库获取2
|
||||
for cookies in cookies_list:
|
||||
|
26
jobs/public_cookies.py
Normal file
26
jobs/public_cookies.py
Normal file
@ -0,0 +1,26 @@
|
||||
import datetime
|
||||
|
||||
from telegram.ext import CallbackContext, JobQueue
|
||||
|
||||
from apps.cookies.services import PublicCookiesService
|
||||
from logger import Log
|
||||
from utils.apps.inject import inject
|
||||
from utils.job.manager import listener_jobs_class
|
||||
|
||||
|
||||
@listener_jobs_class()
|
||||
class PublicCookies:
|
||||
|
||||
@inject
|
||||
def __init__(self, public_cookies_service: PublicCookiesService):
|
||||
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池成功")
|
Loading…
Reference in New Issue
Block a user