1
0
mirror of https://github.com/Mrs4s/go-cqhttp.git synced 2025-05-04 19:17:37 +08:00

all: update MiraiGo and some minor changes

This commit is contained in:
wdvxdr 2022-05-23 11:13:44 +08:00
parent 18a091145a
commit c141501ae5
No known key found for this signature in database
GPG Key ID: 703F8C071DE7A1B6
5 changed files with 14 additions and 15 deletions

View File

@ -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("收到服务器地址更新通知, 根据配置文件已忽略.")

View File

@ -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())

View File

@ -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

2
go.mod
View File

@ -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

View File

@ -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
}
}