2024-04-06 06:58:18 +00:00
|
|
|
"""
|
|
|
|
Author: Night-stars-1 nujj1042633805@gmail.com
|
|
|
|
Date: 2024-02-21 22:50:45
|
2024-08-21 05:51:42 +00:00
|
|
|
LastEditTime: 2024-08-20 22:36:18
|
2023-11-25 01:08:51 +00:00
|
|
|
LastEditors: Night-stars-1 nujj1042633805@gmail.com
|
2024-04-06 06:58:18 +00:00
|
|
|
"""
|
2023-11-13 13:18:59 +00:00
|
|
|
import asyncio
|
|
|
|
|
2024-04-06 06:58:18 +00:00
|
|
|
from tenacity import Retrying, stop_after_attempt
|
2023-12-18 11:58:12 +00:00
|
|
|
|
2023-11-13 13:18:59 +00:00
|
|
|
from utils.api.login import Login
|
2023-12-04 14:21:41 +00:00
|
|
|
from utils.api.sign import BaseSign, CheckIn
|
2023-11-13 13:18:59 +00:00
|
|
|
from utils.config import ConfigManager
|
2023-11-24 08:06:21 +00:00
|
|
|
from utils.logger import InterceptHandler, log
|
2023-11-13 13:18:59 +00:00
|
|
|
from utils.request import notify_me
|
|
|
|
from utils.system_info import print_info
|
2023-11-19 12:19:54 +00:00
|
|
|
from utils.utils import get_token
|
2023-11-13 13:18:59 +00:00
|
|
|
|
|
|
|
_conf = ConfigManager.data_obj
|
|
|
|
|
2023-11-22 04:02:10 +00:00
|
|
|
|
2023-11-13 13:18:59 +00:00
|
|
|
async def main():
|
2023-11-18 10:37:51 +00:00
|
|
|
"""启动签到"""
|
2023-11-13 13:18:59 +00:00
|
|
|
print_info()
|
|
|
|
for account in _conf.accounts:
|
2023-12-18 11:58:12 +00:00
|
|
|
try:
|
|
|
|
for attempt in Retrying(stop=stop_after_attempt(2)):
|
|
|
|
with attempt:
|
|
|
|
login_obj = Login(account)
|
|
|
|
if cookies := await login_obj.login():
|
2024-04-06 06:58:18 +00:00
|
|
|
await login_obj.checkin_info()
|
|
|
|
sign_obj = BaseSign(account)
|
2023-12-18 11:58:12 +00:00
|
|
|
daily_tasks = await sign_obj.check_daily_tasks()
|
|
|
|
sign_task_obj = sign_obj.AVAILABLE_SIGNS # 签到任务对象合集
|
|
|
|
for task in daily_tasks:
|
|
|
|
log.info(f"开始执行{task.name}任务")
|
|
|
|
if task.showType:
|
|
|
|
log.info(f"{task.name}任务已完成")
|
|
|
|
continue
|
2024-04-06 06:58:18 +00:00
|
|
|
if not (
|
|
|
|
task_obj := sign_task_obj.get(task.name)
|
|
|
|
): # 签到任务对象
|
2023-12-18 11:58:12 +00:00
|
|
|
log.error(f"未找到{task.name}任务")
|
|
|
|
continue
|
|
|
|
if not getattr(account, task_obj.__name__):
|
|
|
|
log.info(f"任务{task.name}被禁用")
|
|
|
|
continue
|
2024-04-06 06:58:18 +00:00
|
|
|
token = (
|
|
|
|
await get_token(cookies["cUserId"])
|
|
|
|
if task_obj == CheckIn
|
|
|
|
else None
|
|
|
|
)
|
|
|
|
status, reason = await task_obj(account, token).sign()
|
2023-12-18 11:58:12 +00:00
|
|
|
if not status and reason == "cookie":
|
|
|
|
raise ValueError("Cookie失效")
|
|
|
|
user_info = await sign_obj.user_info()
|
|
|
|
log.info(f"{user_info.title} 成长值: {user_info.point}")
|
2024-04-06 06:58:18 +00:00
|
|
|
except ValueError:
|
2023-12-18 11:58:12 +00:00
|
|
|
...
|
2023-11-24 08:06:21 +00:00
|
|
|
notify_me(InterceptHandler.message)
|
2021-08-16 03:39:26 +00:00
|
|
|
|
2021-09-17 00:08:26 +00:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2023-11-25 08:22:20 +00:00
|
|
|
asyncio.run(main())
|