mower-ng/mower/solvers/sign_in/spring_festival.py
zhbaor fc6d9bfa35
All checks were successful
ci/woodpecker/push/check_format Pipeline was successful
新春限时签到活动修复
2025-02-05 12:33:16 +08:00

79 lines
2.8 KiB
Python

"""
Copyright (c) 2025 zhbaor <zhbaor@zhaozuohong.vip>
This file is part of mower-ng (https://git.zhaozuohong.vip/mower-ng/mower-ng).
Mower-ng is free software: you may copy, redistribute and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation, version 3 or later.
This file is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
from datetime import timedelta
from mower.utils.email import notify
from mower.utils.graph import SceneGraphSolver
from mower.utils.scene import Scene
from mower.utils.solver import BaseSolver
from mower.utils.vector import va
from .utils import index_entry
activity_name = "新春限时签到活动"
class SpringFestival(BaseSolver):
solver_name = "春节签到"
solver_max_duration = timedelta(minutes=3)
def run(self):
self.send_email = False
self.finish_email = True
self.in_progress = False
return super().run()
def transition(self) -> bool:
if (scene := self.scene()) == Scene.MATERIEL:
if self.send_email:
self.sleep()
self.send_email = False
self.finish_email = False
notify(f"{activity_name}奖励领取")
self.cback(5, id="materiel")
elif scene == Scene.INDEX:
if pos := index_entry("sign_in/spring_festival/entry", activity_name):
self.in_progress = True
self.ctap(pos)
return
notify(f"未找到{activity_name}签到入口")
return True
elif scene == Scene.ANNOUNCEMENT:
if not self.in_progress:
SceneGraphSolver().step(Scene.INDEX)
return
if pos := self.find("sign_in/spring_festival/receive"):
if self.ctap(pos, 5):
self.send_email = True
return
if pos := self.find("sign_in/spring_festival/collect"):
if self.ctap(pos, 5):
self.send_email = True
return
if pos := self.find("sign_in/spring_festival/login_day"):
scope = pos[0], va(pos[0], (425, 125))
if self.find("sign_in/spring_festival/done", scope=scope):
if self.ctap(pos, 5):
self.send_email = True
return
if self.finish_email:
notify(f"今日{activity_name}奖励已领完")
return True
else:
SceneGraphSolver().step(Scene.INDEX)