feat: wait-login 支持 --force,供搜狐发布等 Cookie 失效仍开窗检测
All checks were successful
技能自动化发布 / release (push) Successful in 31s
All checks were successful
技能自动化发布 / release (push) Successful in 31s
Made-with: Cursor
This commit is contained in:
@@ -294,21 +294,23 @@ def cmd_login(account_id):
|
||||
print(f"ℹ️ 详细轮询日志见:{log_file}(可将 JIANGCHANG_LOG_LEVEL=DEBUG 打开更细粒度)")
|
||||
|
||||
|
||||
def cmd_wait_login(account_id) -> int:
|
||||
def cmd_wait_login(account_id, force: bool = False) -> int:
|
||||
"""
|
||||
跨技能编排:若未登录则打开浏览器并在限时内等待登录。
|
||||
返回 0:已登录(原本已登录或本次登录成功);1:失败(超时 / 用户关浏览器 / 其它)。
|
||||
stdout 首行:OK:WAIT_LOGIN 或 ERROR:WAIT_LOGIN_*。
|
||||
stdout 含 OK:WAIT_LOGIN 或 ERROR:WAIT_LOGIN_*。
|
||||
|
||||
force=True:即使库内 login_status=1 也仍打开浏览器并限时检测(供搜狐发布等「页面仍要求登录」场景)。
|
||||
"""
|
||||
log = get_skill_logger()
|
||||
log.info("wait_login_command account_id=%r", account_id)
|
||||
log.info("wait_login_command account_id=%r force=%s", account_id, force)
|
||||
target = get_account_by_id(account_id)
|
||||
if not target:
|
||||
log.warning("wait_login_aborted account_not_found account_id=%r", account_id)
|
||||
print("ERROR:ACCOUNT_NOT_FOUND")
|
||||
return 1
|
||||
# 库内 login_status=1 时跳过开窗(仅性能提示;与真实 Cookie 可能不同步,此时应再执行 wait-login 覆盖)
|
||||
if int(target.get("login_status") or 0) == 1:
|
||||
# 库内 login_status=1 时跳过开窗(与真实 Cookie 可能不同步时用 force=True)
|
||||
if int(target.get("login_status") or 0) == 1 and not force:
|
||||
print("OK:WAIT_LOGIN")
|
||||
return 0
|
||||
|
||||
|
||||
Reference in New Issue
Block a user