Skip to content

Commit 01a5d31

Browse files
committed
auto fragment
1 parent 8806393 commit 01a5d31

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

config.go renamed to config/config.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
package main
1+
package config
22

33
import (
44
"gopkg.in/yaml.v2"
55
"io/ioutil"
66
)
77

8+
var FRAGMENT = false
9+
810
type GmcConfig struct {
911
Server Server `yaml:"server"`
1012
Bot Bot `yaml:"bot"`

main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"strconv"
1010
"time"
1111

12+
"github.com/ProtobufBot/Go-Mirai-Client/config"
1213
"github.com/ProtobufBot/Go-Mirai-Client/pkg/util"
1314
"github.com/ProtobufBot/Go-Mirai-Client/service/bot"
1415
"github.com/ProtobufBot/Go-Mirai-Client/service/handler"
@@ -25,7 +26,7 @@ func init() {
2526

2627
func main() {
2728
port := "9000"
28-
conf, err := LoadConfig("application.yml")
29+
conf, err := config.LoadConfig("application.yml")
2930
if err == nil && conf != nil {
3031
if conf.Bot.Client.WsUrl != "" {
3132
bot.WsUrl = conf.Bot.Client.WsUrl

service/bot/api_handler.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"github.com/Mrs4s/MiraiGo/client"
99
"github.com/Mrs4s/MiraiGo/message"
1010
"github.com/Mrs4s/MiraiGo/utils"
11+
"github.com/ProtobufBot/Go-Mirai-Client/config"
1112
"github.com/ProtobufBot/Go-Mirai-Client/proto_gen/onebot"
1213
"github.com/ProtobufBot/Go-Mirai-Client/service/cache"
1314
log "github.com/sirupsen/logrus"
@@ -123,9 +124,10 @@ func HandleSendGroupMsg(cli *client.QQClient, req *onebot.SendGroupMsgReq) *oneb
123124
sendingMessage := &message.SendingMessage{Elements: miraiMsg}
124125
log.Infof("Bot(%d) Group(%d) <- %s", cli.Uin, req.GroupId, MiraiMsgToRawMsg(miraiMsg))
125126
preProcessGroupSendingMessage(cli, req.GroupId, sendingMessage)
126-
ret := cli.SendGroupMessage(req.GroupId, sendingMessage, true)
127+
ret := cli.SendGroupMessage(req.GroupId, sendingMessage, config.FRAGMENT)
127128
if ret == nil || ret.Id == -1 {
128-
log.Warnf("发送群消息失败,可能被风控")
129+
config.FRAGMENT = !config.FRAGMENT
130+
log.Warnf("发送群消息失败,可能被风控,下次发送将改变分片策略,FRAGMENT: %+v", config.FRAGMENT)
129131
return nil
130132
}
131133
cache.GroupMessageLru.Add(ret.Id, ret)

0 commit comments

Comments
 (0)