From de278f25e9c91a0887cfc3293f17abf3269e33ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=AF=BB=E6=AC=A2?= Date: Sat, 22 Jun 2024 08:49:28 +0800 Subject: [PATCH] :bug: Fix a bug. --- tasks/cleargroupuser/cleargroupuser.go | 2 +- utils/send.go | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/tasks/cleargroupuser/cleargroupuser.go b/tasks/cleargroupuser/cleargroupuser.go index a4155334..ea59ea2c 100644 --- a/tasks/cleargroupuser/cleargroupuser.go +++ b/tasks/cleargroupuser/cleargroupuser.go @@ -38,7 +38,7 @@ func ClearGroupUser() { memberMap[member.Nickname] = member.LastActive.Format("2006-01-02 15:04:05") } // 调用接口 - utils.DeleteGroupMember(group.Wxid, strings.Join(deleteIds, ","), 0) + utils.DeleteGroupMember(group.Wxid, strings.Join(deleteIds, ","), 0, false) // 发送通知到群里 ms := make([]string, 0) for k, v := range memberMap { diff --git a/utils/send.go b/utils/send.go index 5fe16bd9..01bf18ca 100644 --- a/utils/send.go +++ b/utils/send.go @@ -126,7 +126,9 @@ func SendEmotion(toId, emotionHash string, retryCount int) { // @description: 删除群成员 // @param chatRoomId 群Id // @param memberIds 成员id,用','分隔 -func DeleteGroupMember(chatRoomId, memberIds string, retryCount int) { +// @param retryCount 重试次数 +// @param isSure 是否确认删除 +func DeleteGroupMember(chatRoomId, memberIds string, retryCount int, isSure bool) { if retryCount > 5 { log.Printf("重试五次失败,停止发送") return @@ -148,9 +150,11 @@ func DeleteGroupMember(chatRoomId, memberIds string, retryCount int) { log.Printf("删除群成员失败: %s", err.Error()) // 休眠五秒后重新发送 time.Sleep(5 * time.Second) - DeleteGroupMember(chatRoomId, memberIds, retryCount+1) + DeleteGroupMember(chatRoomId, memberIds, retryCount+1, isSure) } - log.Printf("删除群成员结果: %s", resp.String()) + log.Printf("[%s]删除群成员结果: %s", chatRoomId, resp.String()) // 这个逼接口要调用两次,第一次调用成功,第二次调用才会真正删除 - DeleteGroupMember(chatRoomId, memberIds, 5) + if !isSure { + DeleteGroupMember(chatRoomId, memberIds, 5, true) + } }