chore: auto release commit (2026-06-19 11:19:10)
All checks were successful
技能自动化发布 / release (push) Successful in 5s
All checks were successful
技能自动化发布 / release (push) Successful in 5s
This commit is contained in:
51
scripts/service/account_mark_commands.py
Normal file
51
scripts/service/account_mark_commands.py
Normal file
@@ -0,0 +1,51 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""Account status mark CLI commands."""
|
||||
from db.accounts_repo import (
|
||||
get_account_by_id,
|
||||
update_account_error,
|
||||
update_account_last_used,
|
||||
update_account_session_status,
|
||||
)
|
||||
from service._svc_common import _err_json, _ok_json, _say
|
||||
from util.logging_config import get_skill_logger
|
||||
|
||||
|
||||
def cmd_account_mark_session(account_id: int, session_status: str) -> None:
|
||||
"""account mark-session <id> --session-status <status>"""
|
||||
log = get_skill_logger()
|
||||
log.info("account_mark_session id=%s status=%s", account_id, session_status)
|
||||
valid_statuses = ("unknown", "likely_valid", "needs_login", "expired")
|
||||
if session_status not in valid_statuses:
|
||||
_say(_err_json("ERROR:CLI_BAD_ARGS",
|
||||
f"session_status 必须为 {valid_statuses} 之一。"))
|
||||
return
|
||||
acc = get_account_by_id(account_id)
|
||||
if not acc:
|
||||
_say(_err_json("ERROR:ACCOUNT_NOT_FOUND", f"账号 id={account_id} 不存在。"))
|
||||
return
|
||||
update_account_session_status(account_id, session_status)
|
||||
_say(_ok_json({"id": account_id, "session_status": session_status}))
|
||||
|
||||
|
||||
def cmd_account_mark_error(account_id: int, error_code: str, error_message: str) -> None:
|
||||
"""account mark-error <id> --code <code> --message <message>"""
|
||||
log = get_skill_logger()
|
||||
log.info("account_mark_error id=%s code=%s", account_id, error_code)
|
||||
acc = get_account_by_id(account_id)
|
||||
if not acc:
|
||||
_say(_err_json("ERROR:ACCOUNT_NOT_FOUND", f"账号 id={account_id} 不存在。"))
|
||||
return
|
||||
update_account_error(account_id, error_code, error_message)
|
||||
_say(_ok_json({"id": account_id, "error_code": error_code}))
|
||||
|
||||
|
||||
def cmd_account_mark_used(account_id: int) -> None:
|
||||
"""account mark-used <id>"""
|
||||
log = get_skill_logger()
|
||||
log.info("account_mark_used id=%s", account_id)
|
||||
acc = get_account_by_id(account_id)
|
||||
if not acc:
|
||||
_say(_err_json("ERROR:ACCOUNT_NOT_FOUND", f"账号 id={account_id} 不存在。"))
|
||||
return
|
||||
update_account_last_used(account_id)
|
||||
_say(_ok_json({"id": account_id, "marked": "used"}))
|
||||
Reference in New Issue
Block a user