71 lines
2.2 KiB
Python
71 lines
2.2 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
验证预约福袋参与成功后锁定期保护逻辑
|
|
"""
|
|
|
|
import sys
|
|
import os
|
|
|
|
PROJECT_ROOT = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
|
sys.path.insert(0, PROJECT_ROOT)
|
|
|
|
|
|
def validate_reservation_lock_protection():
|
|
"""验证预约福袋参与成功后锁定期保护逻辑"""
|
|
print("开始验证预约福袋参与成功后锁定期保护逻辑...")
|
|
|
|
# 检查代码模式
|
|
patterns_to_check = [
|
|
"参与成功,处理锁定期并移除预约",
|
|
"has_other_reservations",
|
|
"设置保护期确保依次参与",
|
|
"protection_seconds=10",
|
|
"参与成功,清除锁定期(无其他预约)",
|
|
]
|
|
|
|
# 读取文件内容
|
|
file_path = os.path.join(PROJECT_ROOT, "douyin", "core", "douyin_fudai.py")
|
|
try:
|
|
with open(file_path, "r", encoding="utf-8") as f:
|
|
content = f.read()
|
|
except Exception as e:
|
|
print(f"❌ 无法读取文件 {file_path}: {e}")
|
|
return False
|
|
|
|
# 检查每个模式
|
|
missing_patterns = []
|
|
for pattern in patterns_to_check:
|
|
if pattern not in content:
|
|
missing_patterns.append(pattern)
|
|
|
|
if missing_patterns:
|
|
print("❌ 缺少以下代码模式:")
|
|
for pattern in missing_patterns:
|
|
print(f" - {pattern}")
|
|
return False
|
|
|
|
# 检查保护期逻辑是否存在
|
|
protection_logic_found = (
|
|
"has_other_reservations = False" in content
|
|
and "if has_other_reservations:" in content
|
|
and "protection_until = time.time() + 10.0" in content
|
|
and "max(self.reservation_focus_until_ts, protection_until)" in content
|
|
)
|
|
|
|
if not protection_logic_found:
|
|
print("❌ 保护期设置逻辑不完整")
|
|
return False
|
|
|
|
print("✅ 预约福袋参与成功后锁定期保护逻辑验证通过")
|
|
print(" - 参与成功后检查是否有其他预约")
|
|
print(" - 有其他预约时设置10秒保护期")
|
|
print(" - 无其他预约时清除锁定期")
|
|
print(" - 确保预约福袋依次参与,不被其他预约打断")
|
|
|
|
return True
|
|
|
|
|
|
if __name__ == "__main__":
|
|
success = validate_reservation_lock_protection()
|
|
sys.exit(0 if success else 1)
|