diff --git a/cmd/gocq/main.go b/cmd/gocq/main.go index c620080..1cb85ca 100644 --- a/cmd/gocq/main.go +++ b/cmd/gocq/main.go @@ -365,6 +365,7 @@ func PasswordHashDecrypt(encryptedPasswordHash string, key []byte) ([]byte, erro func newClient() *client.QQClient { c := client.NewClientEmpty() + c.UseFragmentMessage = base.ForceFragmented c.OnServerUpdated(func(bot *client.QQClient, e *client.ServerUpdatedEvent) bool { if !base.UseSSOAddress { log.Infof("收到服务器地址更新通知, 根据配置文件已忽略.") diff --git a/coolq/api.go b/coolq/api.go index 44a52e8..ece7076 100644 --- a/coolq/api.go +++ b/coolq/api.go @@ -1470,18 +1470,18 @@ func (bot *CQBot) CQDownloadFile(url string, headers gjson.Result, threadCount i h := map[string]string{} if headers.IsArray() { for _, sub := range headers.Array() { - str := strings.SplitN(sub.String(), "=", 2) - if len(str) == 2 { - h[str[0]] = str[1] + first, second, ok := strings.Cut(sub.String(), "=") + if ok { + h[first] = second } } } if headers.Type == gjson.String { lines := strings.Split(headers.String(), "\r\n") for _, sub := range lines { - str := strings.SplitN(sub, "=", 2) - if len(str) == 2 { - h[str[0]] = str[1] + first, second, ok := strings.Cut(sub, "=") + if ok { + h[first] = second } } } @@ -1772,12 +1772,10 @@ func (bot *CQBot) CQSetGroupAnonymousBan(groupID int64, flag string, duration in return Failed(100, "INVALID_FLAG", "无效的flag") } if g := bot.Client.FindGroup(groupID); g != nil { - s := strings.SplitN(flag, "|", 2) - if len(s) != 2 { + id, nick, ok := strings.Cut(flag, "|") + if !ok { return Failed(100, "INVALID_FLAG", "无效的flag") } - id := s[0] - nick := s[1] if err := g.MuteAnonymous(id, nick, duration); err != nil { log.Warnf("anonymous ban error: %v", err) return Failed(100, "CALL_API_ERROR", err.Error()) diff --git a/coolq/bot.go b/coolq/bot.go index 00ec19c..aea4845 100644 --- a/coolq/bot.go +++ b/coolq/bot.go @@ -289,7 +289,7 @@ func (bot *CQBot) SendGroupMessage(groupID int64, m *message.SendingMessage) int } m.Elements = newElem bot.checkMedia(newElem, groupID) - ret := bot.Client.SendGroupMessage(groupID, m, base.ForceFragmented) + ret := bot.Client.SendGroupMessage(groupID, m) if ret == nil || ret.Id == -1 { log.Warnf("群消息发送失败: 账号可能被风控.") return -1 diff --git a/go.mod b/go.mod index c23a948..58c1749 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.18 require ( github.com/Microsoft/go-winio v0.5.1 - github.com/Mrs4s/MiraiGo v0.0.0-20220405134734-9cb9e80d99d8 + github.com/Mrs4s/MiraiGo v0.0.0-20220523030651-b28ec81f546e github.com/RomiChan/syncx v0.0.0-20220320130821-c88644afda9c github.com/RomiChan/websocket v1.4.3-0.20220123145318-307a86b127bc github.com/fumiama/go-hide-param v0.1.4 diff --git a/server/http.go b/server/http.go index a471011..710610d 100644 --- a/server/http.go +++ b/server/http.go @@ -212,9 +212,9 @@ func checkAuth(req *http.Request, token string) int { if auth == "" { auth = req.URL.Query().Get("access_token") } else { - authN := strings.SplitN(auth, " ", 2) - if len(authN) == 2 { - auth = authN[1] + _, after, ok := strings.Cut(auth, " ") + if ok { + auth = after } }