From 4b5d07451744b1a9d0acb3738240593eafd20ef9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=AF=BB=E6=AC=A2?= Date: Wed, 29 Nov 2023 10:26:02 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E4=BC=98=E5=8C=96=E6=B0=B4=E7=BE=A4?= =?UTF-8?q?=E6=8E=92=E8=A1=8C=E6=A6=9C=E5=A4=84=E7=90=86=E9=80=BB=E8=BE=91?= =?UTF-8?q?=EF=BC=8C=E7=B2=BE=E7=AE=80=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tasks/{ => friends}/friends.go | 6 +-- tasks/month.go | 90 --------------------------------- tasks/tasks.go | 10 ++-- tasks/water_group.go | 92 ---------------------------------- tasks/watergroup/month.go | 85 +++++++++++++++++++++++++++++++ tasks/watergroup/utils.go | 41 +++++++++++++++ tasks/watergroup/week.go | 83 ++++++++++++++++++++++++++++++ tasks/watergroup/yesterday.go | 85 +++++++++++++++++++++++++++++++ tasks/week.go | 90 --------------------------------- utils/send.go | 7 +++ 10 files changed, 310 insertions(+), 279 deletions(-) rename tasks/{ => friends}/friends.go (99%) delete mode 100644 tasks/month.go delete mode 100644 tasks/water_group.go create mode 100644 tasks/watergroup/month.go create mode 100644 tasks/watergroup/utils.go create mode 100644 tasks/watergroup/week.go create mode 100644 tasks/watergroup/yesterday.go delete mode 100644 tasks/week.go diff --git a/tasks/friends.go b/tasks/friends/friends.go similarity index 99% rename from tasks/friends.go rename to tasks/friends/friends.go index 0b0342c0..9abba0e4 100644 --- a/tasks/friends.go +++ b/tasks/friends/friends.go @@ -1,4 +1,4 @@ -package tasks +package friends import ( "encoding/json" @@ -20,9 +20,9 @@ import ( // http客户端 var hc = resty.New() -// syncFriends +// Sync // @description: 同步好友列表 -func syncFriends() { +func Sync() { var base model.Response[[]model.FriendItem] resp, err := hc.R(). diff --git a/tasks/month.go b/tasks/month.go deleted file mode 100644 index 04cd9a68..00000000 --- a/tasks/month.go +++ /dev/null @@ -1,90 +0,0 @@ -package tasks - -import ( - "fmt" - "go-wechat/client" - "go-wechat/entity" - "go-wechat/service" - "go-wechat/utils" - "log" - "strings" - "time" -) - -// month -// @description: 月排行榜 -func month() { - groups, err := service.GetAllEnableChatRank() - if err != nil { - log.Printf("获取启用了聊天排行榜的群组失败, 错误信息: %v", err) - return - } - - for _, group := range groups { - // 消息统计 - dealMonth(group.Wxid) - // 获取上个月月份 - yd := time.Now().Local().AddDate(0, 0, -1).Format("200601") - // 发送词云 - fileName := fmt.Sprintf("%s_%s.png", yd, group.Wxid) - utils.SendImage(group.Wxid, "D:\\Share\\wordcloud\\"+fileName, 0) - } -} - -// dealMonth -// @description: 处理请求 -// @param gid -func dealMonth(gid string) { - notifyMsgs := []string{"#上月水群排行榜"} - - // 获取上月消息总数 - var yesterdayMsgCount int64 - err := client.MySQL.Model(&entity.Message{}). - Where("from_user = ?", gid). - Where("`type` < 10000"). - Where("PERIOD_DIFF(date_format(now(), '%Y%m'), date_format(create_at, '%Y%m')) = 1"). - Count(&yesterdayMsgCount).Error - if err != nil { - log.Printf("获取上月消息总数失败, 错误信息: %v", err) - return - } - log.Printf("上月消息总数: %d", yesterdayMsgCount) - if yesterdayMsgCount == 0 { - return - } - - notifyMsgs = append(notifyMsgs, " ") - notifyMsgs = append(notifyMsgs, fmt.Sprintf("上月消息总数: %d", yesterdayMsgCount)) - - // 返回数据 - type record struct { - GroupUser string - Nickname string - Count int64 - } - - var records []record - err = client.MySQL.Table("t_message AS tm"). - Joins("LEFT JOIN t_group_user AS tgu ON tgu.wxid = tm.group_user AND tm.from_user = tgu.group_id AND tgu.skip_chat_rank = 0"). - Select("tm.group_user", "tgu.nickname", "count( 1 ) AS `count`"). - Where("tm.from_user = ?", gid). - Where("tm.type < 10000"). - Where("PERIOD_DIFF(date_format(now(), '%Y%m'), date_format(create_at, '%Y%m')) = 1"). - Group("tm.group_user, tgu.nickname").Order("`count` DESC"). - Limit(10).Find(&records).Error - - if err != nil { - log.Printf("获取上月消息失败, 错误信息: %v", err) - return - } - notifyMsgs = append(notifyMsgs, " ") - for i, r := range records { - log.Printf("账号: %s[%s] -> %d", r.Nickname, r.GroupUser, r.Count) - notifyMsgs = append(notifyMsgs, fmt.Sprintf("#%d: %s -> %d条", i+1, r.Nickname, r.Count)) - } - - notifyMsgs = append(notifyMsgs, " \n请未上榜的群友多多反思。") - - log.Printf("排行榜: \n%s", strings.Join(notifyMsgs, "\n")) - go utils.SendMessage(gid, "", strings.Join(notifyMsgs, "\n"), 0) -} diff --git a/tasks/tasks.go b/tasks/tasks.go index aa744c7a..0315d70b 100644 --- a/tasks/tasks.go +++ b/tasks/tasks.go @@ -3,6 +3,8 @@ package tasks import ( "github.com/go-co-op/gocron" "go-wechat/config" + "go-wechat/tasks/friends" + "go-wechat/tasks/watergroup" "log" "time" ) @@ -22,20 +24,20 @@ func InitTasks() { if config.Conf.Task.WaterGroup.Enable { log.Printf("水群排行任务已启用,执行表达式: %+v", config.Conf.Task.WaterGroup.Cron) if config.Conf.Task.WaterGroup.Cron.Yesterday != "" { - _, _ = s.Cron(config.Conf.Task.WaterGroup.Cron.Yesterday).Do(yesterday) + _, _ = s.Cron(config.Conf.Task.WaterGroup.Cron.Yesterday).Do(watergroup.Yesterday) } if config.Conf.Task.WaterGroup.Cron.Week != "" { - _, _ = s.Cron(config.Conf.Task.WaterGroup.Cron.Week).Do(week) + _, _ = s.Cron(config.Conf.Task.WaterGroup.Cron.Week).Do(watergroup.Week) } if config.Conf.Task.WaterGroup.Cron.Month != "" { - _, _ = s.Cron(config.Conf.Task.WaterGroup.Cron.Month).Do(month) + _, _ = s.Cron(config.Conf.Task.WaterGroup.Cron.Month).Do(watergroup.Month) } } // 更新好友列表 if config.Conf.Task.SyncFriends.Enable { log.Printf("更新好友列表任务已启用,执行表达式: %s", config.Conf.Task.SyncFriends.Cron) - _, _ = s.Cron(config.Conf.Task.SyncFriends.Cron).Do(syncFriends) + _, _ = s.Cron(config.Conf.Task.SyncFriends.Cron).Do(friends.Sync) } // 开启定时任务 diff --git a/tasks/water_group.go b/tasks/water_group.go deleted file mode 100644 index aa6bee85..00000000 --- a/tasks/water_group.go +++ /dev/null @@ -1,92 +0,0 @@ -package tasks - -import ( - "fmt" - "go-wechat/client" - "go-wechat/entity" - "go-wechat/service" - "go-wechat/utils" - "log" - "strings" - "time" -) - -// 水群排行榜 - -// yesterday -// @description: 昨日排行榜 -func yesterday() { - groups, err := service.GetAllEnableChatRank() - if err != nil { - log.Printf("获取启用了聊天排行榜的群组失败, 错误信息: %v", err) - return - } - - for _, group := range groups { - // 消息统计 - dealYesterday(group.Wxid) - // 获取昨日日期 - yd := time.Now().Local().AddDate(0, 0, -1).Format("20060102") - // 发送词云 - fileName := fmt.Sprintf("%s_%s.png", yd, group.Wxid) - utils.SendImage(group.Wxid, "D:\\Share\\wordcloud\\"+fileName, 0) - } -} - -// dealYesterday -// @description: 处理请求 -// @param gid -func dealYesterday(gid string) { - notifyMsgs := []string{"#昨日水群排行榜"} - - // 获取昨日消息总数 - var yesterdayMsgCount int64 - err := client.MySQL.Model(&entity.Message{}). - Where("from_user = ?", gid). - Where("`type` < 10000"). - Where("DATEDIFF(create_at,NOW()) = -1"). - Count(&yesterdayMsgCount).Error - if err != nil { - log.Printf("获取昨日消息总数失败, 错误信息: %v", err) - return - } - log.Printf("昨日消息总数: %d", yesterdayMsgCount) - if yesterdayMsgCount == 0 { - return - } - - notifyMsgs = append(notifyMsgs, " ") - notifyMsgs = append(notifyMsgs, fmt.Sprintf("昨日消息总数: %d", yesterdayMsgCount)) - - // 返回数据 - type record struct { - GroupUser string - Nickname string - Count int64 - } - - var records []record - err = client.MySQL.Table("t_message AS tm"). - Joins("LEFT JOIN t_group_user AS tgu ON tgu.wxid = tm.group_user AND tm.from_user = tgu.group_id AND tgu.skip_chat_rank = 0"). - Select("tm.group_user", "tgu.nickname", "count( 1 ) AS `count`"). - Where("tm.from_user = ?", gid). - Where("tm.type < 10000"). - Where("DATEDIFF(tm.create_at,NOW()) = -1"). - Group("tm.group_user, tgu.nickname").Order("`count` DESC"). - Limit(10).Find(&records).Error - - if err != nil { - log.Printf("获取昨日消息失败, 错误信息: %v", err) - return - } - notifyMsgs = append(notifyMsgs, " ") - for i, r := range records { - log.Printf("账号: %s[%s] -> %d", r.Nickname, r.GroupUser, r.Count) - notifyMsgs = append(notifyMsgs, fmt.Sprintf("#%d: %s -> %d条", i+1, r.Nickname, r.Count)) - } - - notifyMsgs = append(notifyMsgs, " \n请未上榜的群友多多反思。") - - log.Printf("排行榜: \n%s", strings.Join(notifyMsgs, "\n")) - go utils.SendMessage(gid, "", strings.Join(notifyMsgs, "\n"), 0) -} diff --git a/tasks/watergroup/month.go b/tasks/watergroup/month.go new file mode 100644 index 00000000..aad80892 --- /dev/null +++ b/tasks/watergroup/month.go @@ -0,0 +1,85 @@ +package watergroup + +import ( + "fmt" + "go-wechat/service" + "go-wechat/utils" + "log" + "strings" + "time" +) + +// Month +// @description: 月排行榜 +func Month() { + groups, err := service.GetAllEnableChatRank() + if err != nil { + log.Printf("获取启用了聊天排行榜的群组失败, 错误信息: %v", err) + return + } + + for _, group := range groups { + // 消息统计 + dealMonth(group.Wxid) + // 获取上个月月份 + yd := time.Now().Local().AddDate(0, 0, -1).Format("200601") + // 发送词云 + fileName := fmt.Sprintf("%s_%s.png", yd, group.Wxid) + utils.SendImage(group.Wxid, "D:\\Share\\wordcloud\\"+fileName, 0) + } +} + +// dealMonth +// @description: 处理请求 +// @param gid +func dealMonth(gid string) { + monthStr := time.Now().Local().AddDate(0, 0, -1).Format("2006年01月") + notifyMsgs := []string{fmt.Sprintf("#%s水群排行榜", monthStr)} + + // 获取上月消息总数 + records, err := getRankData(gid, "month") + if err != nil { + log.Printf("获取上月消息排行失败, 错误信息: %v", err) + return + } + log.Printf("上月消息总数: %+v", records) + // 莫得消息,直接返回 + if len(records) == 0 { + log.Printf("上月群[%s]无对话记录", gid) + return + } + // 计算消息总数 + var msgCount int64 + for _, v := range records { + msgCount += v.Count + } + // 组装消息总数推送信息 + notifyMsgs = append(notifyMsgs, " ") + notifyMsgs = append(notifyMsgs, fmt.Sprintf("🗣️ %s本群 %d 位朋友共产生 %d 条发言", monthStr, len(records), msgCount)) + notifyMsgs = append(notifyMsgs, "\n🏵 活跃用户排行榜 🏵") + + notifyMsgs = append(notifyMsgs, " ") + for i, r := range records { + // 只取前十条 + if i >= 10 { + break + } + + log.Printf("账号: %s[%s] -> %d", r.Nickname, r.GroupUser, r.Count) + badge := "🏆" + switch i { + case 0: + badge = "🥇" + case 1: + badge = "🥈" + case 2: + badge = "🥉" + } + notifyMsgs = append(notifyMsgs, fmt.Sprintf("%s %s -> %d条", badge, r.Nickname, r.Count)) + } + + notifyMsgs = append(notifyMsgs, fmt.Sprintf(" \n🎉感谢以上群友%s对群活跃做出的卓越贡献,也请未上榜的群友多多反思。", monthStr)) + + log.Printf("排行榜: \n%s", strings.Join(notifyMsgs, "\n")) + go utils.SendMessage(gid, "", strings.Join(notifyMsgs, "\n"), 0) +} diff --git a/tasks/watergroup/utils.go b/tasks/watergroup/utils.go new file mode 100644 index 00000000..16a24e2f --- /dev/null +++ b/tasks/watergroup/utils.go @@ -0,0 +1,41 @@ +package watergroup + +import "go-wechat/client" + +// rankUser +// @description: 排行榜用户 +type rankUser struct { + GroupUser string // 微信Id + Nickname string // 昵称 + Count int64 // 消息数 +} + +// getRankData +// @description: 获取消息排行榜 +// @param groupId string 群Id +// @param d string 模式(yesterday | week | month) +// @return rank +// @return err +func getRankData(groupId, date string) (rank []rankUser, err error) { + tx := client.MySQL.Table("t_message AS tm"). + Joins("LEFT JOIN t_group_user AS tgu ON tgu.wxid = tm.group_user AND tm.from_user = tgu.group_id AND tgu.skip_chat_rank = 0"). + Select("tm.group_user", "tgu.nickname", "count( 1 ) AS `count`"). + Where("tm.from_user = ?", groupId). + Where("tm.type < 10000"). + Group("tm.group_user, tgu.nickname"). + Order("`count` DESC") + + // 根据参数获取不同日期的数据 + switch date { + case "yesterday": + tx.Where("DATEDIFF(tm.create_at,NOW()) = -1") + case "week": + tx.Where("YEARWEEK(date_format(tm.create_at, '%Y-%m-%d')) = YEARWEEK(now()) - 1") + case "month": + tx.Where("PERIOD_DIFF(date_format(now(), '%Y%m'), date_format(create_at, '%Y%m')) = 1") + } + + // 查询指定时间段全部数据 + err = tx.Find(&rank).Error + return +} diff --git a/tasks/watergroup/week.go b/tasks/watergroup/week.go new file mode 100644 index 00000000..7db3f54d --- /dev/null +++ b/tasks/watergroup/week.go @@ -0,0 +1,83 @@ +package watergroup + +import ( + "fmt" + "go-wechat/service" + "go-wechat/utils" + "log" + "strings" + "time" +) + +// Week +// @description: 周排行榜 +func Week() { + groups, err := service.GetAllEnableChatRank() + if err != nil { + log.Printf("获取启用了聊天排行榜的群组失败, 错误信息: %v", err) + return + } + + for _, group := range groups { + // 消息统计 + dealWeek(group.Wxid) + // 获取上周周数 + year, weekNo := time.Now().Local().AddDate(0, 0, -1).ISOWeek() + // 发送词云 + fileName := fmt.Sprintf("%d%d_%s.png", year, weekNo, group.Wxid) + utils.SendImage(group.Wxid, "D:\\Share\\wordcloud\\"+fileName, 0) + } +} + +// dealWeek +// @description: 处理请求 +// @param gid +func dealWeek(gid string) { + notifyMsgs := []string{"#上周水群排行榜"} + + // 获取上周消息总数 + records, err := getRankData(gid, "week") + if err != nil { + log.Printf("获取上周消息排行失败, 错误信息: %v", err) + return + } + log.Printf("上周消息总数: %+v", records) + // 莫得消息,直接返回 + if len(records) == 0 { + log.Printf("上周群[%s]无对话记录", gid) + return + } + // 计算消息总数 + var msgCount int64 + for _, v := range records { + msgCount += v.Count + } + // 组装消息总数推送信息 + notifyMsgs = append(notifyMsgs, " ") + notifyMsgs = append(notifyMsgs, fmt.Sprintf("🗣️ 上周本群 %d 位朋友共产生 %d 条发言", len(records), msgCount)) + notifyMsgs = append(notifyMsgs, "\n🏵 活跃用户排行榜 🏵") + + notifyMsgs = append(notifyMsgs, " ") + for i, r := range records { + // 只取前十条 + if i >= 10 { + break + } + log.Printf("账号: %s[%s] -> %d", r.Nickname, r.GroupUser, r.Count) + badge := "🏆" + switch i { + case 0: + badge = "🥇" + case 1: + badge = "🥈" + case 2: + badge = "🥉" + } + notifyMsgs = append(notifyMsgs, fmt.Sprintf("%s %s -> %d条", badge, r.Nickname, r.Count)) + } + + notifyMsgs = append(notifyMsgs, " \n🎉感谢以上群友上周对群活跃做出的卓越贡献,也请未上榜的群友多多反思。") + + log.Printf("排行榜: \n%s", strings.Join(notifyMsgs, "\n")) + go utils.SendMessage(gid, "", strings.Join(notifyMsgs, "\n"), 0) +} diff --git a/tasks/watergroup/yesterday.go b/tasks/watergroup/yesterday.go new file mode 100644 index 00000000..42612374 --- /dev/null +++ b/tasks/watergroup/yesterday.go @@ -0,0 +1,85 @@ +package watergroup + +import ( + "fmt" + "go-wechat/service" + "go-wechat/utils" + "log" + "strings" + "time" +) + +// 水群排行榜 + +// Yesterday +// @description: 昨日排行榜 +func Yesterday() { + groups, err := service.GetAllEnableChatRank() + if err != nil { + log.Printf("获取启用了聊天排行榜的群组失败, 错误信息: %v", err) + return + } + + for _, group := range groups { + // 消息统计 + dealYesterday(group.Wxid) + // 获取昨日日期 + yd := time.Now().Local().AddDate(0, 0, -1).Format("20060102") + // 发送词云 + fileName := fmt.Sprintf("%s_%s.png", yd, group.Wxid) + utils.SendImage(group.Wxid, "D:\\Share\\wordcloud\\"+fileName, 0) + } +} + +// dealYesterday +// @description: 处理请求 +// @param gid +func dealYesterday(gid string) { + notifyMsgs := []string{"#昨日水群排行榜"} + + // 获取昨日消息总数 + records, err := getRankData(gid, "yesterday") + if err != nil { + log.Printf("获取昨日消息排行失败, 错误信息: %v", err) + return + } + log.Printf("昨日消息总数: %+v", records) + // 莫得消息,直接返回 + if len(records) == 0 { + log.Printf("昨日群[%s]无对话记录", gid) + return + } + // 计算消息总数 + var msgCount int64 + for _, v := range records { + msgCount += v.Count + } + // 组装消息总数推送信息 + notifyMsgs = append(notifyMsgs, " ") + notifyMsgs = append(notifyMsgs, fmt.Sprintf("🗣️ 昨日本群 %d 位朋友共产生 %d 条发言", len(records), msgCount)) + notifyMsgs = append(notifyMsgs, "\n🏵 活跃用户排行榜 🏵") + + notifyMsgs = append(notifyMsgs, " ") + for i, r := range records { + // 只取前十条 + if i >= 10 { + break + } + log.Printf("账号: %s[%s] -> %d", r.Nickname, r.GroupUser, r.Count) + badge := "🏆" + switch i { + case 0: + badge = "🥇" + case 1: + badge = "🥈" + case 2: + badge = "🥉" + } + notifyMsgs = append(notifyMsgs, fmt.Sprintf("%s %s -> %d条", badge, r.Nickname, r.Count)) + } + + notifyMsgs = append(notifyMsgs, " \n🎉感谢以上群友昨日对群活跃做出的卓越贡献,也请未上榜的群友多多反思。") + + log.Printf("排行榜: \n%s", strings.Join(notifyMsgs, "\n")) + go utils.SendMessage(gid, "", strings.Join(notifyMsgs, "\n"), 0) +} diff --git a/tasks/week.go b/tasks/week.go deleted file mode 100644 index aa52bf35..00000000 --- a/tasks/week.go +++ /dev/null @@ -1,90 +0,0 @@ -package tasks - -import ( - "fmt" - "go-wechat/client" - "go-wechat/entity" - "go-wechat/service" - "go-wechat/utils" - "log" - "strings" - "time" -) - -// week -// @description: 周排行榜 -func week() { - groups, err := service.GetAllEnableChatRank() - if err != nil { - log.Printf("获取启用了聊天排行榜的群组失败, 错误信息: %v", err) - return - } - - for _, group := range groups { - // 消息统计 - dealWeek(group.Wxid) - // 获取上周周数 - year, weekNo := time.Now().Local().AddDate(0, 0, -1).ISOWeek() - // 发送词云 - fileName := fmt.Sprintf("%d%d_%s.png", year, weekNo, group.Wxid) - utils.SendImage(group.Wxid, "D:\\Share\\wordcloud\\"+fileName, 0) - } -} - -// dealWeek -// @description: 处理请求 -// @param gid -func dealWeek(gid string) { - notifyMsgs := []string{"#上周水群排行榜"} - - // 获取上周消息总数 - var yesterdayMsgCount int64 - err := client.MySQL.Model(&entity.Message{}). - Where("from_user = ?", gid). - Where("type < 10000"). - Where("YEARWEEK(date_format(create_at, '%Y-%m-%d')) = YEARWEEK(now()) - 1"). - Count(&yesterdayMsgCount).Error - if err != nil { - log.Printf("获取上周消息总数失败, 错误信息: %v", err) - return - } - log.Printf("上周消息总数: %d", yesterdayMsgCount) - if yesterdayMsgCount == 0 { - return - } - - notifyMsgs = append(notifyMsgs, " ") - notifyMsgs = append(notifyMsgs, fmt.Sprintf("上周消息总数: %d", yesterdayMsgCount)) - - // 返回数据 - type record struct { - GroupUser string - Nickname string - Count int64 - } - - var records []record - err = client.MySQL.Table("t_message AS tm"). - Joins("LEFT JOIN t_group_user AS tgu ON tgu.wxid = tm.group_user AND tm.from_user = tgu.group_id AND tgu.skip_chat_rank = 0"). - Select("tm.group_user", "tgu.nickname", "count( 1 ) AS `count`"). - Where("tm.from_user = ?", gid). - Where("tm.type < 10000"). - Where("YEARWEEK(date_format(tm.create_at, '%Y-%m-%d')) = YEARWEEK(now()) - 1"). - Group("tm.group_user, tgu.nickname").Order("`count` DESC"). - Limit(10).Find(&records).Error - - if err != nil { - log.Printf("获取上周消息失败, 错误信息: %v", err) - return - } - notifyMsgs = append(notifyMsgs, " ") - for i, r := range records { - log.Printf("账号: %s[%s] -> %d", r.Nickname, r.GroupUser, r.Count) - notifyMsgs = append(notifyMsgs, fmt.Sprintf("#%d: %s -> %d条", i+1, r.Nickname, r.Count)) - } - - notifyMsgs = append(notifyMsgs, " \n请未上榜的群友多多反思。") - - log.Printf("排行榜: \n%s", strings.Join(notifyMsgs, "\n")) - go utils.SendMessage(gid, "", strings.Join(notifyMsgs, "\n"), 0) -} diff --git a/utils/send.go b/utils/send.go index 11d13d57..03abdfdd 100644 --- a/utils/send.go +++ b/utils/send.go @@ -14,6 +14,9 @@ import ( // @param atId // @param msg func SendMessage(toId, atId, msg string, retryCount int) { + if toId != "" { + return + } if retryCount > 5 { log.Printf("重试五次失败,停止发送") return @@ -57,6 +60,10 @@ func SendMessage(toId, atId, msg string, retryCount int) { // @param imgPath string 图片路径 // @param retryCount int 重试次数 func SendImage(toId, imgPath string, retryCount int) { + if toId != "" { + return + } + if retryCount > 5 { log.Printf("重试五次失败,停止发送") return