Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Beta489 #494

Merged
merged 45 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
a6ebe57
beta447
Hoshinonyaruko Jun 29, 2024
1d63fae
beta448
Hoshinonyaruko Jul 1, 2024
cd34627
beta449
Hoshinonyaruko Jul 4, 2024
b790b29
beta450
Hoshinonyaruko Jul 4, 2024
7a9b56a
beta451
Hoshinonyaruko Jul 4, 2024
e17d0d4
beta452
Hoshinonyaruko Jul 4, 2024
1318175
beta453
Hoshinonyaruko Jul 4, 2024
b7f291c
beta454
Hoshinonyaruko Jul 4, 2024
f921895
beta455
Hoshinonyaruko Jul 9, 2024
24108c6
btea455
Hoshinonyaruko Jul 9, 2024
7cdc968
beta456
Hoshinonyaruko Jul 9, 2024
b5d784e
beta457
Hoshinonyaruko Jul 9, 2024
61e4001
beta458
Hoshinonyaruko Jul 9, 2024
6d4116a
beta460
Hoshinonyaruko Jul 9, 2024
2c1f1b7
beta460
Hoshinonyaruko Jul 11, 2024
5c312cd
beta461
Hoshinonyaruko Jul 12, 2024
58304eb
beta462
Hoshinonyaruko Jul 13, 2024
7e7c9f3
beta463
Hoshinonyaruko Jul 15, 2024
188f250
beta464
Hoshinonyaruko Jul 15, 2024
af0296d
beta465
Hoshinonyaruko Jul 18, 2024
500135c
beta467
Hoshinonyaruko Jul 21, 2024
c1a588c
beta468
Hoshinonyaruko Jul 21, 2024
1df8e15
beta469
Hoshinonyaruko Jul 21, 2024
f57ab7b
beta470
Hoshinonyaruko Jul 26, 2024
cd21ad9
beta471
Hoshinonyaruko Aug 1, 2024
6039272
beta472
Hoshinonyaruko Aug 1, 2024
c45b450
beta473
Hoshinonyaruko Aug 1, 2024
f89d6c5
beta473
Hoshinonyaruko Aug 3, 2024
b54fdee
beta475
Hoshinonyaruko Aug 5, 2024
a30a697
beta476
Hoshinonyaruko Aug 8, 2024
ab805cc
beta478
Hoshinonyaruko Aug 8, 2024
6debefd
beta479
Hoshinonyaruko Aug 17, 2024
9cc7e5d
beta479
Hoshinonyaruko Aug 17, 2024
c0fe93c
beta480
Hoshinonyaruko Aug 18, 2024
91cf223
beta481
Hoshinonyaruko Aug 18, 2024
a3aa6c1
beta482
Hoshinonyaruko Aug 18, 2024
0917e56
beta483
Hoshinonyaruko Aug 19, 2024
dd1f774
beta484
Hoshinonyaruko Aug 19, 2024
1c87d61
beta485
Hoshinonyaruko Aug 20, 2024
aac474a
beta486
Hoshinonyaruko Aug 20, 2024
2604eb7
beta486
Hoshinonyaruko Aug 20, 2024
76377be
beta487
Hoshinonyaruko Aug 20, 2024
cb095ec
beta487
Hoshinonyaruko Aug 20, 2024
34c92ae
beta489
Hoshinonyaruko Aug 21, 2024
d6a1abb
Merge branch 'main' into beta489
Hoshinonyaruko Aug 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions Processor/ProcessC2CMessage.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,10 @@ func (p *Processors) ProcessC2CMessage(data *dto.WSC2CMessageData) error {

var messageText string
//当屏蔽错误通道时候=性能模式 不解析at 不解析图片
if !config.GetDisableErrorChan() {
GetDisableErrorChan := config.GetDisableErrorChan()

// 判断性能模式
if !GetDisableErrorChan {
//转换at
messageText = handlers.RevertTransformedText(data, "group_private", p.Api, p.Apiv2, 0, 0, config.GetWhiteEnable(5))
if messageText == "" {
Expand Down Expand Up @@ -436,8 +439,15 @@ func (p *Processors) ProcessC2CMessage(data *dto.WSC2CMessageData) error {

// Convert OnebotGroupMessage to map and send
groupMsgMap := structToMap(groupMsg)
//上报信息到onebotv11应用端(正反ws)
go p.BroadcastMessageToAll(groupMsgMap, p.Apiv2, data)

// 不使用性能模式
if !GetDisableErrorChan {
//上报信息到onebotv11应用端(正反ws)
go p.BroadcastMessageToAll(groupMsgMap, p.Apiv2, data)
} else {
// 性能模式
go p.BroadcastMessageToAllFAF(groupMsgMap, p.Apiv2, data)
}

//组合FriendData
userdata := structs.FriendData{
Expand Down
15 changes: 12 additions & 3 deletions Processor/ProcessGroupMessage.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,10 @@ func (p *Processors) ProcessGroupMessage(data *dto.WSGroupATMessageData) error {
}

var messageText string
GetDisableErrorChan := config.GetDisableErrorChan()

//当屏蔽错误通道时候=性能模式 不解析at 不解析图片
if !config.GetDisableErrorChan() {
if !GetDisableErrorChan {
// 转换at
messageText = handlers.RevertTransformedText(data, "group", p.Api, p.Apiv2, GroupID64, userid64, config.GetWhiteEnable(4))
if messageText == "" {
Expand Down Expand Up @@ -327,7 +329,14 @@ func (p *Processors) ProcessGroupMessage(data *dto.WSGroupATMessageData) error {
groupMsgMap = structToMap(groupMsgS)
}

//上报信息到onebotv11应用端(正反ws)
go p.BroadcastMessageToAll(groupMsgMap, p.Apiv2, data)
// 如果不是性能模式
if !GetDisableErrorChan {
//上报信息到onebotv11应用端(正反ws) 并等待返回
go p.BroadcastMessageToAll(groupMsgMap, p.Apiv2, data)
} else {
// FAF式
go p.BroadcastMessageToAllFAF(groupMsgMap, p.Apiv2, data)
}

return nil
}
20 changes: 20 additions & 0 deletions Processor/Processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,26 @@ func (p *Processors) SendMessageToAllClients(message map[string]interface{}) err
return result.ErrorOrNil()
}

// 方便快捷的发信息函数
func (p *Processors) BroadcastMessageToAllFAF(message map[string]interface{}, api openapi.MessageAPI, data interface{}) error {
// 并发发送到我们作为客户端的Wsclient
for _, client := range p.Wsclient {
go func(c callapi.WebSocketServerClienter) {
_ = c.SendMessage(message) // 忽略错误
}(client)
}

// 并发发送到我们作为服务器连接到我们的WsServerClients
for _, serverClient := range p.WsServerClients {
go func(sc callapi.WebSocketServerClienter) {
_ = sc.SendMessage(message) // 忽略错误
}(serverClient)
}

// 不再等待所有 goroutine 完成,直接返回
return nil
}

// 方便快捷的发信息函数
func (p *Processors) BroadcastMessageToAll(message map[string]interface{}, api openapi.MessageAPI, data interface{}) error {
var wg sync.WaitGroup
Expand Down
2 changes: 1 addition & 1 deletion wsclient/ws.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (client *WebSocketClient) SendMessage(message map[string]interface{}) error
return err
}

// 创建错误通道,用于接收写操作的结果
// 创建专用通道,用于接收写操作的结果
client.writeCh <- writeRequest{
messageType: websocket.TextMessage,
data: msgBytes,
Expand Down
Loading