diff --git a/config/config.go b/config/config.go index 35b7fcda..e1f395fa 100644 --- a/config/config.go +++ b/config/config.go @@ -2447,3 +2447,16 @@ func GetLogSuffixPerMins() int { } return instance.Settings.LogSuffixPerMins } + +// 获取ThreadsRetMsg的值 +func GetThreadsRetMsg() bool { + mu.RLock() + defer mu.RUnlock() + + if instance == nil { + fmt.Println("Warning: instance is nil when trying to ThreadsRetMsg value.") + return false + } + return instance.Settings.ThreadsRetMsg +} + diff --git a/handlers/send_group_msg.go b/handlers/send_group_msg.go index 696ff3a6..62398698 100644 --- a/handlers/send_group_msg.go +++ b/handlers/send_group_msg.go @@ -377,8 +377,12 @@ func HandleSendGroupMsg(client callapi.Client, api openapi.OpenAPI, apiv2 openap postGroupMessageWithRetry(apiv2, message.Params.GroupID.(string), groupMessage) } - // 发送成功回执 - 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) + } delete(foundItems, imageType) // 从foundItems中删除已处理的图片项 messageText = "" @@ -432,7 +436,12 @@ func HandleSendGroupMsg(client callapi.Client, api openapi.OpenAPI, apiv2 openap postGroupMessageWithRetry(apiv2, message.Params.GroupID.(string), groupMessage) } //发送成功回执 - 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) + } + } var resp *dto.GroupMessageResponse // 遍历foundItems并发送每种信息 @@ -502,7 +511,11 @@ func HandleSendGroupMsg(client callapi.Client, api openapi.OpenAPI, apiv2 openap postGroupMessageWithRetry(apiv2, message.Params.GroupID.(string), groupMessage) } //发送成功回执 - 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) + } } continue // 跳过这个项,继续下一个 } @@ -592,7 +605,12 @@ func HandleSendGroupMsg(client callapi.Client, api openapi.OpenAPI, apiv2 openap } } //发送成功回执 - 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) + } + } } case "guild": diff --git a/handlers/send_group_msg_raw.go b/handlers/send_group_msg_raw.go index 601e0038..72d97f66 100644 --- a/handlers/send_group_msg_raw.go +++ b/handlers/send_group_msg_raw.go @@ -298,7 +298,11 @@ func HandleSendGroupMsgRaw(client callapi.Client, api openapi.OpenAPI, apiv2 ope } // 发送成功回执 - 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) + } delete(foundItems, imageType) // 从foundItems中删除已处理的图片项 messageText = "" @@ -331,7 +335,12 @@ func HandleSendGroupMsgRaw(client callapi.Client, api openapi.OpenAPI, apiv2 ope echo.PushGlobalStack(pair) } //发送成功回执 - 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) + } + } var resp *dto.GroupMessageResponse // 遍历foundItems并发送每种信息 @@ -367,7 +376,13 @@ func HandleSendGroupMsgRaw(client callapi.Client, api openapi.OpenAPI, apiv2 ope echo.PushGlobalStack(pair) } //发送成功回执 - 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) + } + } continue // 跳过这个项,继续下一个 } @@ -427,7 +442,13 @@ func HandleSendGroupMsgRaw(client callapi.Client, api openapi.OpenAPI, apiv2 ope } } //发送成功回执 - 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) + } + } } case "guild": diff --git a/structs/structs.go b/structs/structs.go index c89dfa04..24272df2 100644 --- a/structs/structs.go +++ b/structs/structs.go @@ -108,6 +108,7 @@ type Settings struct { SaveError bool `yaml:"save_error"` DowntimeMessage string `yaml:"downtime_message"` MemoryMsgid bool `yaml:"memory_msgid"` + ThreadsRetMsg bool `yaml:"threads_ret_msg"` //增长营销类 SelfIntroduce []string `yaml:"self_introduce"` //api修改 diff --git a/template/config_template.go b/template/config_template.go index e8711214..0d6113cd 100644 --- a/template/config_template.go +++ b/template/config_template.go @@ -140,6 +140,7 @@ settings: save_error : false #将保存保存在log文件夹,方便开发者定位发送错误. downtime_message : "我正在维护中~请不要担心,维护结束就回来~维护时间:(1小时)" memory_msgid : false #当你的机器人单日信息量超过100万,就需要高性能SSD或者开启这个选项了.部分依赖msgid的功能可能会受影响(如delete_msg) + threads_ret_msg : false #异步,并发发送回执信息 仅ws可用. #增长营销类(推荐gensokyo-broadcast项目) self_introduce : ["",""] #自我介绍,可设置多个随机发送,当不为空时,机器人被邀入群会发送自定义自我介绍 需手动添加新textintent - "GroupAddRobotEventHandler" - "GroupDelRobotEventHandler"