diff --git a/cmd/gocq/qsign.go b/cmd/gocq/qsign.go index 1849a4da8..345b131f5 100644 --- a/cmd/gocq/qsign.go +++ b/cmd/gocq/qsign.go @@ -186,13 +186,15 @@ func energy(uin uint64, id string, _ string, salt []byte) ([]byte, error) { // 提交回调 buffer func signSubmit(uin string, cmd string, callbackID int64, buffer []byte, t string) { buffStr := hex.EncodeToString(buffer) - tail := 64 - endl := "..." - if len(buffStr) < tail { - tail = len(buffStr) - endl = "." + if base.Debug { + tail := 64 + endl := "..." + if len(buffStr) < tail { + tail = len(buffStr) + endl = "." + } + log.Debugf("submit (%v): uin=%v, cmd=%v, callbackID=%v, buffer=%v%s", t, uin, cmd, callbackID, buffStr[:tail], endl) } - log.Infof("submit (%v): uin=%v, cmd=%v, callbackID=%v, buffer=%v%s", t, uin, cmd, callbackID, buffStr[:tail], endl) signServer, _, err := requestSignServer( http.MethodGet, @@ -208,6 +210,12 @@ func signSubmit(uin string, cmd string, callbackID int64, buffer []byte, t strin // signCallback // 刷新 token 和签名的回调 func signCallback(uin string, results []gjson.Result, t string) { + for { // 等待至在线 + if cli.Online.Load() { + break + } + time.Sleep(1 * time.Second) + } for _, result := range results { cmd := result.Get("cmd").String() callbackID := result.Get("callbackId").Int() diff --git a/coolq/api.go b/coolq/api.go index 7c9e47d64..c129b329f 100644 --- a/coolq/api.go +++ b/coolq/api.go @@ -759,7 +759,7 @@ func (bot *CQBot) CQSendGroupMessage(groupID int64, m gjson.Result, autoEscape b } else { str := m.String() if str == "" { - log.Warn("群消息发送失败: 信息为空.") + log.Warnf("群 %v 消息发送失败: 信息为空.", groupID) return Failed(100, "EMPTY_MSG_ERROR", "消息为空") } if autoEscape { @@ -981,7 +981,7 @@ func (bot *CQBot) CQSendGroupForwardMessage(groupID int64, m gjson.Result) globa } ret := bot.Client.SendGroupForwardMessage(groupID, fe) if ret == nil || ret.Id == -1 { - log.Warnf("合并转发(群)消息发送失败: 账号可能被风控.") + log.Warnf("合并转发(群 %v)消息发送失败: 账号可能被风控.", groupID) return Failed(100, "SEND_MSG_API_ERROR", "请参考 go-cqhttp 端输出") } mid := bot.InsertGroupMessage(ret, source) @@ -1007,7 +1007,7 @@ func (bot *CQBot) CQSendPrivateForwardMessage(userID int64, m gjson.Result) glob } mid := bot.SendPrivateMessage(userID, 0, &message.SendingMessage{Elements: []message.IMessageElement{fe}}) if mid == -1 { - log.Warnf("合并转发(好友)消息发送失败: 账号可能被风控.") + log.Warnf("合并转发(好友 %v)消息发送失败: 账号可能被风控.", userID) return Failed(100, "SEND_MSG_API_ERROR", "请参考 go-cqhttp 端输出") } log.Infof("发送好友 %v(%v) 的合并转发消息: %v (%v)", userID, userID, limitedString(m.String()), mid) diff --git a/coolq/bot.go b/coolq/bot.go index e2e323146..ca6d72661 100644 --- a/coolq/bot.go +++ b/coolq/bot.go @@ -297,14 +297,14 @@ func (bot *CQBot) SendGroupMessage(groupID int64, m *message.SendingMessage) (in newElem = append(newElem, e) } if len(newElem) == 0 { - log.Warnf("群消息发送失败: 消息为空.") + log.Warnf("群 %v 消息发送失败: 消息为空.", groupID) return -1, errors.New("empty message") } m.Elements = newElem bot.checkMedia(newElem, groupID) ret := bot.Client.SendGroupMessage(groupID, m) if ret == nil || ret.Id == -1 { - log.Warnf("群消息发送失败: 账号可能被风控.") + log.Warnf("群 %v 发送消息失败: 账号可能被风控.", groupID) return -1, errors.New("send group message failed: blocked by server") } return bot.InsertGroupMessage(ret, source), nil