Skip to content

Commit

Permalink
Beta480 (#485)
Browse files Browse the repository at this point in the history
* beta447

* beta448

* beta449

* beta450

* beta451

* beta452

* beta453

* beta454

* beta455

* btea455

* beta456

* beta457

* beta458

* beta460

* beta460

* beta461

* beta462

* beta463

* beta464

* beta465

* beta467

* beta468

* beta469

* beta470

* beta471

* beta472

* beta473

* beta473

* beta475

* beta476

* beta478

* beta479

* beta479

* beta480
  • Loading branch information
Hoshinonyaruko authored Aug 18, 2024
1 parent 6c88176 commit f0414dc
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 9 deletions.
13 changes: 13 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

28 changes: 23 additions & 5 deletions handlers/send_group_msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ""
Expand Down Expand Up @@ -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并发送每种信息
Expand Down Expand Up @@ -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 // 跳过这个项,继续下一个
}
Expand Down Expand Up @@ -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":
Expand Down
29 changes: 25 additions & 4 deletions handlers/send_group_msg_raw.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ""
Expand Down Expand Up @@ -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并发送每种信息
Expand Down Expand Up @@ -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 // 跳过这个项,继续下一个
}
Expand Down Expand Up @@ -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":
Expand Down
1 change: 1 addition & 0 deletions structs/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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修改
Expand Down
1 change: 1 addition & 0 deletions template/config_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit f0414dc

Please sign in to comment.