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

Beta481 #486

Merged
merged 36 commits into from
Aug 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 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
5da5b0a
Merge branch 'main' into beta481
Hoshinonyaruko Aug 18, 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
12 changes: 8 additions & 4 deletions botgo/websocket/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,10 +317,14 @@ func (c *Client) listenMessageAndHandle() {
c.readyHandler(payload)
continue
}
// 解析具体事件,并投递给业务注册的 handler
if err := event.ParseAndHandle(payload); err != nil {
log.Errorf("%s parseAndHandle failed, %v", c.session, err)
}

// 性能不够 报错也没用 就扬了
go event.ParseAndHandle(payload)

// // 解析具体事件,并投递给业务注册的 handler
// if err := event.ParseAndHandle(payload); err != nil {
// log.Errorf("%s parseAndHandle failed, %v", c.session, err)
// }
}
log.Infof("%s message queue is closed", c.session)
}
Expand Down
11 changes: 11 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2460,3 +2460,14 @@ func GetThreadsRetMsg() bool {
return instance.Settings.ThreadsRetMsg
}

// 获取NoRetMsg的值
func GetNoRetMsg() bool {
mu.RLock()
defer mu.RUnlock()

if instance == nil {
fmt.Println("Warning: instance is nil when trying to NoRetMsg value.")
return false
}
return instance.Settings.NoRetMsg
}
51 changes: 31 additions & 20 deletions handlers/send_group_msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -377,11 +377,13 @@ func HandleSendGroupMsg(client callapi.Client, api openapi.OpenAPI, apiv2 openap
postGroupMessageWithRetry(apiv2, message.Params.GroupID.(string), groupMessage)
}

if config.GetThreadsRetMsg() {
go SendResponse(client, err, &message, resp, api, apiv2)
} else {
// 发送成功回执
retmsg, _ = SendResponse(client, err, &message, resp, api, apiv2)
if !config.GetNoRetMsg() {
if config.GetThreadsRetMsg() {
go SendResponse(client, err, &message, resp, api, apiv2)
} else {
// 发送成功回执
retmsg, _ = SendResponse(client, err, &message, resp, api, apiv2)
}
}

delete(foundItems, imageType) // 从foundItems中删除已处理的图片项
Expand Down Expand Up @@ -435,11 +437,14 @@ func HandleSendGroupMsg(client callapi.Client, api openapi.OpenAPI, apiv2 openap
} else if err != nil && strings.Contains(err.Error(), "context deadline exceeded") {
postGroupMessageWithRetry(apiv2, message.Params.GroupID.(string), groupMessage)
}
//发送成功回执
if config.GetThreadsRetMsg() {
go SendResponse(client, err, &message, resp, api, apiv2)
} else {
retmsg, _ = SendResponse(client, err, &message, resp, api, apiv2)

if !config.GetNoRetMsg() {
//发送成功回执
if config.GetThreadsRetMsg() {
go SendResponse(client, err, &message, resp, api, apiv2)
} else {
retmsg, _ = SendResponse(client, err, &message, resp, api, apiv2)
}
}

}
Expand Down Expand Up @@ -510,11 +515,14 @@ func HandleSendGroupMsg(client callapi.Client, api openapi.OpenAPI, apiv2 openap
} else if err != nil && strings.Contains(err.Error(), "context deadline exceeded") {
postGroupMessageWithRetry(apiv2, message.Params.GroupID.(string), groupMessage)
}
//发送成功回执
if config.GetThreadsRetMsg() {
go SendResponse(client, err, &message, resp, api, apiv2)
} else {
retmsg, _ = SendResponse(client, err, &message, resp, api, apiv2)

if !config.GetNoRetMsg() {
//发送成功回执
if config.GetThreadsRetMsg() {
go SendResponse(client, err, &message, resp, api, apiv2)
} else {
retmsg, _ = SendResponse(client, err, &message, resp, api, apiv2)
}
}
}
continue // 跳过这个项,继续下一个
Expand Down Expand Up @@ -604,11 +612,14 @@ func HandleSendGroupMsg(client callapi.Client, api openapi.OpenAPI, apiv2 openap
postGroupMessageWithRetry(apiv2, message.Params.GroupID.(string), groupMessage)
}
}
//发送成功回执
if config.GetThreadsRetMsg() {
go SendResponse(client, err, &message, resp, api, apiv2)
} else {
retmsg, _ = SendResponse(client, err, &message, resp, api, apiv2)

if !config.GetNoRetMsg() {
//发送成功回执
if config.GetThreadsRetMsg() {
go SendResponse(client, err, &message, resp, api, apiv2)
} else {
retmsg, _ = SendResponse(client, err, &message, resp, api, apiv2)
}
}

}
Expand Down
52 changes: 32 additions & 20 deletions handlers/send_group_msg_raw.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,11 +297,14 @@ func HandleSendGroupMsgRaw(client callapi.Client, api openapi.OpenAPI, apiv2 ope
echo.PushGlobalStack(pair)
}

// 发送成功回执
if config.GetThreadsRetMsg() {
go SendResponse(client, err, &message, resp, api, apiv2)
} else {
retmsg, _ = SendResponse(client, err, &message, resp, api, apiv2)
if !config.GetNoRetMsg() {
// 发送成功回执
if config.GetThreadsRetMsg() {
go SendResponse(client, err, &message, resp, api, apiv2)
} else {
retmsg, _ = SendResponse(client, err, &message, resp, api, apiv2)
}

}

delete(foundItems, imageType) // 从foundItems中删除已处理的图片项
Expand Down Expand Up @@ -334,11 +337,14 @@ func HandleSendGroupMsgRaw(client callapi.Client, api openapi.OpenAPI, apiv2 ope
pair.GroupMessage = groupMessage
echo.PushGlobalStack(pair)
}
//发送成功回执
if config.GetThreadsRetMsg() {
go SendResponse(client, err, &message, resp, api, apiv2)
} else {
retmsg, _ = SendResponse(client, err, &message, resp, api, apiv2)

if !config.GetNoRetMsg() {
//发送成功回执
if config.GetThreadsRetMsg() {
go SendResponse(client, err, &message, resp, api, apiv2)
} else {
retmsg, _ = SendResponse(client, err, &message, resp, api, apiv2)
}
}

}
Expand Down Expand Up @@ -375,12 +381,15 @@ func HandleSendGroupMsgRaw(client callapi.Client, api openapi.OpenAPI, apiv2 ope
pair.GroupMessage = groupMessage
echo.PushGlobalStack(pair)
}
//发送成功回执
if config.GetThreadsRetMsg() {
go SendResponse(client, err, &message, resp, api, apiv2)
} else {

if !config.GetNoRetMsg() {
//发送成功回执
retmsg, _ = SendResponse(client, err, &message, resp, api, apiv2)
if config.GetThreadsRetMsg() {
go SendResponse(client, err, &message, resp, api, apiv2)
} else {
//发送成功回执
retmsg, _ = SendResponse(client, err, &message, resp, api, apiv2)
}
}

}
Expand Down Expand Up @@ -441,12 +450,15 @@ func HandleSendGroupMsgRaw(client callapi.Client, api openapi.OpenAPI, apiv2 ope
echo.PushGlobalStack(pair)
}
}
//发送成功回执
if config.GetThreadsRetMsg() {
go SendResponse(client, err, &message, resp, api, apiv2)
} else {

if !config.GetNoRetMsg() {
//发送成功回执
retmsg, _ = SendResponse(client, err, &message, resp, api, apiv2)
if config.GetThreadsRetMsg() {
go SendResponse(client, err, &message, resp, api, apiv2)
} else {
//发送成功回执
retmsg, _ = SendResponse(client, err, &message, resp, api, apiv2)
}
}

}
Expand Down
34 changes: 23 additions & 11 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,9 @@ func ATMessageEventHandler() event.ATMessageEventHandler {
data.Author.Username = acnode.CheckWordIN(data.Author.Username)
}
}
return p.ProcessGuildATMessage(data)

go p.ProcessGuildATMessage(data)
return nil
}
}

Expand Down Expand Up @@ -701,7 +703,8 @@ func DirectMessageHandler() event.DirectMessageEventHandler {
data.Author.Username = acnode.CheckWordIN(data.Author.Username)
}
}
return p.ProcessChannelDirectMessage(data)
go p.ProcessChannelDirectMessage(data)
return nil
}
}

Expand All @@ -715,23 +718,26 @@ func CreateMessageHandler() event.MessageEventHandler {
data.Author.Username = acnode.CheckWordIN(data.Author.Username)
}
}
return p.ProcessGuildNormalMessage(data)
go p.ProcessGuildNormalMessage(data)
return nil
}
}

// InteractionHandler 处理内联交互事件
func InteractionHandler() event.InteractionEventHandler {
return func(event *dto.WSPayload, data *dto.WSInteractionData) error {
mylog.Printf("收到按钮回调:%v", data)
return p.ProcessInlineSearch(data)
go p.ProcessInlineSearch(data)
return nil
}
}

// ThreadEventHandler 处理帖子事件
func ThreadEventHandler() event.ThreadEventHandler {
return func(event *dto.WSPayload, data *dto.WSThreadData) error {
mylog.Printf("收到帖子事件:%v", data)
return p.ProcessThreadMessage(data)
go p.ProcessThreadMessage(data)
return nil
}
}

Expand All @@ -745,7 +751,8 @@ func GroupATMessageEventHandler() event.GroupATMessageEventHandler {
data.Author.Username = acnode.CheckWordIN(data.Author.Username)
}
}
return p.ProcessGroupMessage(data)
go p.ProcessGroupMessage(data)
return nil
}
}

Expand All @@ -759,35 +766,40 @@ func C2CMessageEventHandler() event.C2CMessageEventHandler {
data.Author.Username = acnode.CheckWordIN(data.Author.Username)
}
}
return p.ProcessC2CMessage(data)
go p.ProcessC2CMessage(data)
return nil
}
}

// GroupAddRobotEventHandler 实现处理 群机器人新增 事件的回调
func GroupAddRobotEventHandler() event.GroupAddRobotEventHandler {
return func(event *dto.WSPayload, data *dto.GroupAddBotEvent) error {
return p.ProcessGroupAddBot(data)
go p.ProcessGroupAddBot(data)
return nil
}
}

// GroupDelRobotEventHandler 实现处理 群机器人删除 事件的回调
func GroupDelRobotEventHandler() event.GroupDelRobotEventHandler {
return func(event *dto.WSPayload, data *dto.GroupAddBotEvent) error {
return p.ProcessGroupDelBot(data)
go p.ProcessGroupDelBot(data)
return nil
}
}

// GroupMsgRejectHandler 实现处理 群请求关闭机器人主动推送 事件的回调
func GroupMsgRejectHandler() event.GroupMsgRejectHandler {
return func(event *dto.WSPayload, data *dto.GroupMsgRejectEvent) error {
return p.ProcessGroupMsgReject(data)
go p.ProcessGroupMsgReject(data)
return nil
}
}

// GroupMsgReceiveHandler 实现处理 群请求开启机器人主动推送 事件的回调
func GroupMsgReceiveHandler() event.GroupMsgReceiveHandler {
return func(event *dto.WSPayload, data *dto.GroupMsgReceiveEvent) error {
return p.ProcessGroupMsgRecive(data)
go p.ProcessGroupMsgRecive(data)
return nil
}
}

Expand Down
1 change: 1 addition & 0 deletions structs/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ type Settings struct {
DowntimeMessage string `yaml:"downtime_message"`
MemoryMsgid bool `yaml:"memory_msgid"`
ThreadsRetMsg bool `yaml:"threads_ret_msg"`
NoRetMsg bool `yaml:"no_ret_msg"`
//增长营销类
SelfIntroduce []string `yaml:"self_introduce"`
//api修改
Expand Down
1 change: 1 addition & 0 deletions template/config_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ settings:
downtime_message : "我正在维护中~请不要担心,维护结束就回来~维护时间:(1小时)"
memory_msgid : false #当你的机器人单日信息量超过100万,就需要高性能SSD或者开启这个选项了.部分依赖msgid的功能可能会受影响(如delete_msg)
threads_ret_msg : false #异步,并发发送回执信息 仅ws可用.
no_ret_msg : false #当你的信息量达到1000万/天的时候,并且你的业务不需要获取回调信息,此时直接屏蔽是最好的选择,可以提升50%收发性能. 需应用端适配!!!

#增长营销类(推荐gensokyo-broadcast项目)
self_introduce : ["",""] #自我介绍,可设置多个随机发送,当不为空时,机器人被邀入群会发送自定义自我介绍 需手动添加新textintent - "GroupAddRobotEventHandler" - "GroupDelRobotEventHandler"
Expand Down
Loading