forked from lxh/go-wxhelper
🐛 修复清理不活跃成员功能的BUG
This commit is contained in:
parent
9c7e93660d
commit
8c2ab9376c
@ -82,7 +82,7 @@ func GetAllEnableNews() (records []entity.Friend, err error) {
|
|||||||
// @return records
|
// @return records
|
||||||
// @return err
|
// @return err
|
||||||
func GetAllEnableClearGroup() (records []entity.Friend, err error) {
|
func GetAllEnableClearGroup() (records []entity.Friend, err error) {
|
||||||
err = client.MySQL.Where("clear_members != 0").Where("is_ok IS TRUE").Find(&records).Error
|
err = client.MySQL.Where("clear_member > 0").Where("is_ok IS TRUE").Find(&records).Error
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ import (
|
|||||||
// ClearGroupUser
|
// ClearGroupUser
|
||||||
// @description: 清理群成员
|
// @description: 清理群成员
|
||||||
func ClearGroupUser() {
|
func ClearGroupUser() {
|
||||||
groups, err := service.GetAllEnableNews()
|
groups, err := service.GetAllEnableClearGroup()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("获取启用了聊天排行榜的群组失败, 错误信息: %v", err)
|
log.Printf("获取启用了聊天排行榜的群组失败, 错误信息: %v", err)
|
||||||
return
|
return
|
||||||
@ -42,9 +42,9 @@ func ClearGroupUser() {
|
|||||||
// 发送通知到群里
|
// 发送通知到群里
|
||||||
ms := make([]string, 0)
|
ms := make([]string, 0)
|
||||||
for k, v := range memberMap {
|
for k, v := range memberMap {
|
||||||
ms = append(ms, fmt.Sprintf("%s: %s", k, v))
|
ms = append(ms, fmt.Sprintf("昵称:%s\n最后活跃时间:%s", k, v))
|
||||||
}
|
}
|
||||||
msg := fmt.Sprintf("#清理群成员#\n\n很遗憾地通知各位,就在刚刚,有%d名群友引活跃度不够暂时离开了我们,希望还健在的群友引以为戒、保持活跃!\n\n活跃信息: \n%s",
|
msg := fmt.Sprintf("#清理群成员\n\n很遗憾地通知各位,就在刚刚,有%d名群友引活跃度不够暂时离开了我们,希望还健在的群友引以为戒、保持活跃!\n\n活跃信息: \n%s",
|
||||||
memberCount, strings.Join(ms, "\n"))
|
memberCount, strings.Join(ms, "\n"))
|
||||||
utils.SendMessage(group.Wxid, "", msg, 0)
|
utils.SendMessage(group.Wxid, "", msg, 0)
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@ func InitTasks() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 每天0点检查一次处理清理群成员
|
// 每天0点检查一次处理清理群成员
|
||||||
_, _ = s.Cron("0 0 * * *").Do(cleargroupuser.ClearGroupUser)
|
_, _ = s.Cron("12 0 * * *").Do(cleargroupuser.ClearGroupUser)
|
||||||
|
|
||||||
// 开启定时任务
|
// 开启定时任务
|
||||||
s.StartAsync()
|
s.StartAsync()
|
||||||
|
Loading…
Reference in New Issue
Block a user