修复自动化启动时序与失败重试机制

This commit is contained in:
Christ committed 2026-07-27 12:40:40 +08:00
1 parent f68c8b8add
commit 6e678999fc
9 files changed
+296 -28

No files matched your search

+9 -2
View File
@@ -1580,18 +1580,25 @@ func (a *Account) currentSenderState() (WSConn, string, error) {
a.mu.Lock()
defer a.mu.Unlock()
if a.conn == nil {
return nil, "", fmt.Errorf("账号 %s 当前没有可用 WebSocket 连接", a.CookieID)
return nil, "", fmt.Errorf("%w: 账号 %s 当前没有可用 WebSocket 连接", automation.ErrMessageNotSent, a.CookieID)
}
myID := strings.TrimSpace(a.UserID)
if myID == "" {
myID = protocol.TransCookies(a.CookieStr)["unb"]
}
if myID == "" {
return nil, "", fmt.Errorf("账号 %s 缺少 unb,无法发送消息", a.CookieID)
return nil, "", fmt.Errorf("%w: 账号 %s 缺少 unb,无法发送消息", automation.ErrMessageNotSent, a.CookieID)
}
return a.conn, myID, nil
}
// AutomationReady 报告自动化消息是否可以立即使用当前 WS 连接发送。
func (a *Account) AutomationReady() bool {
a.mu.Lock()
defer a.mu.Unlock()
return a.conn != nil && a.runtimeState == RuntimeOnline
}
func (a *Account) replaceCookieStr(cookieStr string) {
a.replaceCredentialState(cookieStr, credentialStateFingerprint(cookieStr, ""))
}