Compare commits

...

3 Commits

Author SHA1 Message Date
fb9a51720e Merge pull request 'hotfix' (#92) from hotfix into main
All checks were successful
BuildImage / build-image (push) Successful in 1m34s
Reviewed-on: #92
2024-07-28 00:59:16 +08:00
80a010680c 🐛 修复清理不活跃成员的时候会把机器人清理掉的 BUG 2024-07-28 00:58:30 +08:00
a50b5b3418 🐛 修复清理不活跃成员的时候会把机器人清理掉的 BUG 2024-07-28 00:56:05 +08:00

View File

@ -3,6 +3,7 @@ package cleargroupuser
import ( import (
"fmt" "fmt"
"go-wechat/client" "go-wechat/client"
"go-wechat/common/current"
"go-wechat/model/entity" "go-wechat/model/entity"
"go-wechat/service" "go-wechat/service"
"go-wechat/utils" "go-wechat/utils"
@ -15,7 +16,7 @@ import (
func ClearGroupUser() { func ClearGroupUser() {
groups, err := service.GetAllEnableClearGroup() groups, err := service.GetAllEnableClearGroup()
if err != nil { if err != nil {
log.Printf("获取启用了聊天排行榜的群组失败, 错误信息: %v", err) log.Printf("获取启用了末位淘汰的群组失败, 错误信息: %v", err)
return return
} }
@ -56,7 +57,9 @@ func ClearGroupUser() {
// @param days 需要清理的未活跃的天数 // @param days 需要清理的未活跃的天数
// @return members // @return members
func getNeedDeleteMembers(groupId string, days int) (members []entity.GroupUser) { 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("is_member IS TRUE").
Where("DATEDIFF( NOW(), last_active ) >= ?", days). Where("DATEDIFF( NOW(), last_active ) >= ?", days).
Order("last_active DESC"). Order("last_active DESC").