MCPcopy Create free account
hub / github.com/smallfawn/QLScriptPublic / run

Method run

daily/sfsy.py:982–1061  ·  view source on GitHub ↗

运行账号任务 Returns: Dict: 包含账号统计信息的字典

(self)

Source from the content-addressed store, hash-verified

980 self.logger.error(f'账号{self.account_index} 登录失败,已重试{MAX_PROXY_RETRIES}次,所有代理均不可用')
981
982 def run(self) -> Dict[str, Any]:
983 """运行账号任务
984
985 Returns:
986 Dict: 包含账号统计信息的字典
987 """
988 if not self.login_success:
989 return {
990 'success': False,
991 'phone': '',
992 'points_before': 0,
993 'points_after': 0,
994 'points_earned': 0
995 }
996
997 # 随机延迟
998 wait_time = random.randint(1000, 3000) / 1000.0
999 time.sleep(wait_time)
1000
1001 # 初始化任务执行器
1002 executor = TaskExecutor(self.http_client, self.logger, self.config, self.user_id)
1003
1004 # 先执行APP签到
1005 app_sign_success, app_error_msg = executor.app_sign_in()
1006 time.sleep(1)
1007
1008 # 执行新签到
1009 new_sign_success, new_sign_error = executor.new_sign_in()
1010 time.sleep(1)
1011
1012 # 再执行小程序签到
1013 sign_success, error_msg = executor.sign_in()
1014
1015 # 如果签到失败且错误信息包含“活动太火爆”,尝试重新登录
1016 if not sign_success and '活动太火爆' in error_msg:
1017 max_retries = 3
1018 for retry in range(max_retries):
1019 self.logger.warning(f'签到失败(代理IP问题),{2}秒后重新获取代理并重试(第{retry + 1}次)...')
1020 time.sleep(2)
1021
1022 try:
1023 # 重新创建HTTP客户端(会自动获取新代理)
1024 self.http_client = SFHttpClient(self.config, self.proxy_manager)
1025
1026 # 重新登录
1027 success, self.user_id, self.phone = self.http_client.login(self.account_url)
1028
1029 if success:
1030 # 更新执行器的HTTP客户端
1031 executor.http = self.http_client
1032 executor.user_id = self.user_id
1033
1034 # 重试签到
1035 sign_success, error_msg = executor.sign_in()
1036
1037 if sign_success:
1038 self.logger.success('重新登录后签到成功')
1039 break

Callers 2

run_single_accountFunction · 0.95
mainFunction · 0.95

Calls 11

app_sign_inMethod · 0.95
new_sign_inMethod · 0.95
sign_inMethod · 0.95
run_all_tasksMethod · 0.95
TaskExecutorClass · 0.85
SFHttpClientClass · 0.85
sleepMethod · 0.80
warningMethod · 0.80
successMethod · 0.80
loginMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected