diff --git a/tasks/cleargroupuser/cleargroupuser.go b/tasks/cleargroupuser/cleargroupuser.go index a199d4a7..98f3b709 100644 --- a/tasks/cleargroupuser/cleargroupuser.go +++ b/tasks/cleargroupuser/cleargroupuser.go @@ -3,6 +3,7 @@ package cleargroupuser import ( "fmt" "go-wechat/client" + "go-wechat/common/current" "go-wechat/model/entity" "go-wechat/service" "go-wechat/utils" @@ -15,7 +16,7 @@ import ( func ClearGroupUser() { groups, err := service.GetAllEnableClearGroup() if err != nil { - log.Printf("获取启用了聊天排行榜的群组失败, 错误信息: %v", err) + log.Printf("获取启用了末位淘汰的群组失败, 错误信息: %v", err) return } @@ -56,7 +57,9 @@ func ClearGroupUser() { // @param days 需要清理的未活跃的天数 // @return members func getNeedDeleteMembers(groupId string, days int) (members []entity.GroupUser) { - err := client.MySQL.Model(&entity.GroupUser{}).Where("group_id = ?", groupId). + err := client.MySQL.Model(&entity.GroupUser{}). + Where("group_id = ?", groupId). + Where("wxid != ?", current.GetRobotInfo().WxId). Where("is_member IS TRUE"). Where("DATEDIFF( NOW(), last_active ) >= ?", days). Order("last_active DESC"). diff --git a/tasks/summary/summary.go b/tasks/summary/summary.go index ca1727bb..adfa2abd 100644 --- a/tasks/summary/summary.go +++ b/tasks/summary/summary.go @@ -10,6 +10,7 @@ import ( "go-wechat/utils" "log" "strings" + "time" ) // AiSummary @@ -22,6 +23,9 @@ func AiSummary() { } for _, group := range groups { + // 记录开始时间 + var start = time.Now() + // 获取对话记录 var records []vo.TextMessageItem if records, err = service.GetTextMessagesById(group.Wxid); err != nil { @@ -86,5 +90,10 @@ func AiSummary() { replyMsg := fmt.Sprintf("#昨日消息总结\n又是一天过去了,让我们一起来看看昨儿群友们都聊了什么有趣的话题吧~\n\n%s", resp.Choices[0].Message.Content) //log.Printf("群[%s]对话记录总结成功,总结内容: %s", group.Wxid, replyMsg) utils.SendMessage(group.Wxid, "", replyMsg, 0) + + // 判断耗时是否达到15秒,不足就等待 + if used := time.Now().Sub(start); used < 15*time.Second { + time.Sleep(15*time.Second - used) + } } }