2022-08-06 06:36:44 +00:00
|
|
|
import datetime
|
2023-03-16 03:25:10 +00:00
|
|
|
from typing import TYPE_CHECKING
|
2022-08-06 06:36:44 +00:00
|
|
|
|
2022-09-08 01:08:37 +00:00
|
|
|
from core.plugin import Plugin, job
|
2023-03-14 01:27:22 +00:00
|
|
|
from plugins.genshin.sign import SignSystem
|
|
|
|
from plugins.tools.sign import SignJobType
|
2022-09-08 01:08:37 +00:00
|
|
|
from utils.log import logger
|
2022-08-06 06:36:44 +00:00
|
|
|
|
2023-03-16 03:25:10 +00:00
|
|
|
if TYPE_CHECKING:
|
|
|
|
from telegram.ext import ContextTypes
|
|
|
|
|
2022-08-06 06:36:44 +00:00
|
|
|
|
2022-09-08 01:08:37 +00:00
|
|
|
class SignJob(Plugin):
|
2023-03-14 01:27:22 +00:00
|
|
|
def __init__(self, sign_system: SignSystem):
|
|
|
|
self.sign_system = sign_system
|
2022-10-10 05:34:06 +00:00
|
|
|
|
2022-09-08 01:08:37 +00:00
|
|
|
@job.run_daily(time=datetime.time(hour=0, minute=1, second=0), name="SignJob")
|
2023-03-16 03:25:10 +00:00
|
|
|
async def sign(self, context: "ContextTypes.DEFAULT_TYPE"):
|
2023-03-14 01:27:22 +00:00
|
|
|
logger.info("正在执行自动签到")
|
|
|
|
await self.sign_system.do_sign_job(context, job_type=SignJobType.START)
|
|
|
|
logger.success("执行自动签到完成")
|
|
|
|
await self.re_sign(context)
|
|
|
|
|
2023-03-16 03:25:10 +00:00
|
|
|
async def re_sign(self, context: "ContextTypes.DEFAULT_TYPE"):
|
2023-03-14 01:27:22 +00:00
|
|
|
logger.info("正在执行自动重签")
|
|
|
|
await self.sign_system.do_sign_job(context, job_type=SignJobType.REDO)
|
|
|
|
logger.success("执行自动重签完成")
|