feat: add sweep and task reward automation

This commit is contained in:
admin committed 2026-10-04 19:17:10 +08:00
1 parent 8479cf4981
commit 44d9a617d1
21 files changed
+516 -8

No files matched your search

+40
View File
@@ -0,0 +1,40 @@
"""Run from the project root: python claim_sweep.py [--times N] [--dry-run]."""
import argparse
import sys
import time
from pathlib import Path
from automation.engine import Matcher, WorkflowError, load_flow
from automation.offers import MacGameDesktop
from automation.sweep import SweepRunner
ROOT = Path(__file__).resolve().parent
def main():
parser = argparse.ArgumentParser(description='首页小金猪:快速扫荡并返回首页')
parser.add_argument('--times', type=int, default=1, help='扫荡次数,1 到 20 次;默认 1 次')
parser.add_argument('--dry-run', action='store_true', help='只验证首页并显示计划,不点击')
args = parser.parse_args()
if sys.platform != 'darwin':
print('当前脚本已验证 macOS;Windows 版将在校准入口完成后接入。', file=sys.stderr)
return 2
try:
desktop = MacGameDesktop()
desktop.activate()
print('3 秒后开始;请保持游戏在前台。鼠标移到主屏幕左上角可紧急停止。', flush=True)
time.sleep(3)
runner = SweepRunner(desktop, Matcher(ROOT / 'assets'),
load_flow(ROOT / 'workflows/sweep_claim.json'), desktop.region_for)
runner.run(args.times, args.dry_run)
return 0
except KeyboardInterrupt:
print('已停止。', file=sys.stderr)
return 130
except Exception as exc:
print('流程停止:' + str(exc), file=sys.stderr)
return 1
if __name__ == '__main__':
raise SystemExit(main())