From 369d0fa6a3f560efa9f46c75e2eb073af8eed2d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=AF=BB=E6=AC=A2?= Date: Sat, 27 Jul 2024 06:21:40 +0800 Subject: [PATCH 1/3] =?UTF-8?q?:art:=20=E4=BC=98=E5=8C=96=E7=BE=A4?= =?UTF-8?q?=E8=81=8A=E6=B6=88=E6=81=AF=E6=80=BB=E7=BB=93=E9=80=BB=E8=BE=91?= =?UTF-8?q?=EF=BC=8C=E9=99=90=E5=88=B6=E4=B8=80=E5=88=86=E9=92=9F=E5=8F=AA?= =?UTF-8?q?=E5=A4=84=E7=90=86=E5=9B=9B=E4=B8=AA=E7=BE=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tasks/summary/summary.go | 9 +++++++++ 1 file changed, 9 insertions(+) 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) + } } } From a50b5b3418d8e8930a3c9aed7a72bc28c347fcf4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=AF=BB=E6=AC=A2?= Date: Sun, 28 Jul 2024 00:56:05 +0800 Subject: [PATCH 2/3] =?UTF-8?q?:bug:=20=E4=BF=AE=E5=A4=8D=E6=B8=85?= =?UTF-8?q?=E7=90=86=E4=B8=8D=E6=B4=BB=E8=B7=83=E6=88=90=E5=91=98=E7=9A=84?= =?UTF-8?q?=E6=97=B6=E5=80=99=E4=BC=9A=E6=8A=8A=E6=9C=BA=E5=99=A8=E4=BA=BA?= =?UTF-8?q?=E6=B8=85=E7=90=86=E6=8E=89=E7=9A=84=20BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tasks/cleargroupuser/cleargroupuser.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tasks/cleargroupuser/cleargroupuser.go b/tasks/cleargroupuser/cleargroupuser.go index a199d4a7..306faeff 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 } @@ -59,6 +60,7 @@ func getNeedDeleteMembers(groupId string, days int) (members []entity.GroupUser) err := client.MySQL.Model(&entity.GroupUser{}).Where("group_id = ?", groupId). Where("is_member IS TRUE"). Where("DATEDIFF( NOW(), last_active ) >= ?", days). + Where("wxid != ?", current.GetRobotInfo().WxId). Order("last_active DESC"). Find(&members).Error if err != nil { From 80a010680c7408551a79e39db11e3118a08f8e30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=AF=BB=E6=AC=A2?= Date: Sun, 28 Jul 2024 00:58:30 +0800 Subject: [PATCH 3/3] =?UTF-8?q?:bug:=20=E4=BF=AE=E5=A4=8D=E6=B8=85?= =?UTF-8?q?=E7=90=86=E4=B8=8D=E6=B4=BB=E8=B7=83=E6=88=90=E5=91=98=E7=9A=84?= =?UTF-8?q?=E6=97=B6=E5=80=99=E4=BC=9A=E6=8A=8A=E6=9C=BA=E5=99=A8=E4=BA=BA?= =?UTF-8?q?=E6=B8=85=E7=90=86=E6=8E=89=E7=9A=84=20BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tasks/cleargroupuser/cleargroupuser.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tasks/cleargroupuser/cleargroupuser.go b/tasks/cleargroupuser/cleargroupuser.go index 306faeff..98f3b709 100644 --- a/tasks/cleargroupuser/cleargroupuser.go +++ b/tasks/cleargroupuser/cleargroupuser.go @@ -57,10 +57,11 @@ 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). - Where("wxid != ?", current.GetRobotInfo().WxId). Order("last_active DESC"). Find(&members).Error if err != nil {