From a548af9de2be7f030c693710648625150105b07b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=AF=BB=E6=AC=A2?= Date: Mon, 11 Mar 2024 14:55:10 +0800 Subject: [PATCH 1/5] =?UTF-8?q?:bug:=20=E4=BF=AE=E5=A4=8D=E6=B4=BB?= =?UTF-8?q?=E8=B7=83=E5=BA=A6=E4=B8=8D=E5=8F=91=E9=80=81=E7=9A=84BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tasks/watergroup/month.go | 2 +- tasks/watergroup/week.go | 2 +- tasks/watergroup/year.go | 2 +- tasks/watergroup/yesterday.go | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tasks/watergroup/month.go b/tasks/watergroup/month.go index bcd99d1..e0c8e75 100644 --- a/tasks/watergroup/month.go +++ b/tasks/watergroup/month.go @@ -68,7 +68,7 @@ func dealMonth(gid string) { log.Printf("查询群成员总数失败, 错误信息: %v", err) } // 计算活跃度 - showActivity := err != nil && groupUsers > 0 + showActivity := err == nil && groupUsers > 0 activity := "0.00" if groupUsers > 0 { activity = fmt.Sprintf("%.2f", (float64(len(records))/float64(groupUsers))*100) diff --git a/tasks/watergroup/week.go b/tasks/watergroup/week.go index 6598ca2..43c315a 100644 --- a/tasks/watergroup/week.go +++ b/tasks/watergroup/week.go @@ -67,7 +67,7 @@ func dealWeek(gid string) { log.Printf("查询群成员总数失败, 错误信息: %v", err) } // 计算活跃度 - showActivity := err != nil && groupUsers > 0 + showActivity := err == nil && groupUsers > 0 activity := "0.00" if groupUsers > 0 { activity = fmt.Sprintf("%.2f", (float64(len(records))/float64(groupUsers))*100) diff --git a/tasks/watergroup/year.go b/tasks/watergroup/year.go index 3d07bcf..20b8a36 100644 --- a/tasks/watergroup/year.go +++ b/tasks/watergroup/year.go @@ -67,7 +67,7 @@ func dealYear(gid string) { log.Printf("查询群成员总数失败, 错误信息: %v", err) } // 计算活跃度 - showActivity := err != nil && groupUsers > 0 + showActivity := err == nil && groupUsers > 0 activity := "0.00" if groupUsers > 0 { activity = fmt.Sprintf("%.2f", (float64(len(records))/float64(groupUsers))*100) diff --git a/tasks/watergroup/yesterday.go b/tasks/watergroup/yesterday.go index 697f721..ab01626 100644 --- a/tasks/watergroup/yesterday.go +++ b/tasks/watergroup/yesterday.go @@ -69,7 +69,7 @@ func dealYesterday(gid string) { log.Printf("查询群成员总数失败, 错误信息: %v", err) } // 计算活跃度 - showActivity := err != nil && groupUsers > 0 + showActivity := err == nil && groupUsers > 0 activity := "0.00" if groupUsers > 0 { activity = fmt.Sprintf("%.2f", (float64(len(records))/float64(groupUsers))*100) From ddb0db0b6a2832b764b0556d29a5a81431050d6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=AF=BB=E6=AC=A2?= Date: Tue, 12 Mar 2024 08:37:05 +0800 Subject: [PATCH 2/5] :bug: Fix a bug. --- tasks/watergroup/month.go | 2 +- tasks/watergroup/week.go | 2 +- tasks/watergroup/year.go | 2 +- tasks/watergroup/yesterday.go | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tasks/watergroup/month.go b/tasks/watergroup/month.go index e0c8e75..54175e1 100644 --- a/tasks/watergroup/month.go +++ b/tasks/watergroup/month.go @@ -83,7 +83,7 @@ func dealMonth(gid string) { notifyMsgs = append(notifyMsgs, " ") notifyMsgs = append(notifyMsgs, fmt.Sprintf("🗣️ %s本群 %d 位朋友共产生 %d 条发言", monthStr, len(records), msgCount)) if showActivity { - notifyMsgs = append(notifyMsgs, fmt.Sprintf("🎭 活跃度: %s%", activity)) + notifyMsgs = append(notifyMsgs, fmt.Sprintf("🎭 活跃度: %s%%", activity)) } notifyMsgs = append(notifyMsgs, "\n🏵 活跃用户排行榜 🏵") diff --git a/tasks/watergroup/week.go b/tasks/watergroup/week.go index 43c315a..8cc5856 100644 --- a/tasks/watergroup/week.go +++ b/tasks/watergroup/week.go @@ -82,7 +82,7 @@ func dealWeek(gid string) { notifyMsgs = append(notifyMsgs, " ") notifyMsgs = append(notifyMsgs, fmt.Sprintf("🗣️ 上周本群 %d 位朋友共产生 %d 条发言", len(records), msgCount)) if showActivity { - notifyMsgs = append(notifyMsgs, fmt.Sprintf("🎭 活跃度: %s%", activity)) + notifyMsgs = append(notifyMsgs, fmt.Sprintf("🎭 活跃度: %s%%", activity)) } notifyMsgs = append(notifyMsgs, "\n🏵 活跃用户排行榜 🏵") diff --git a/tasks/watergroup/year.go b/tasks/watergroup/year.go index 20b8a36..1c9f236 100644 --- a/tasks/watergroup/year.go +++ b/tasks/watergroup/year.go @@ -90,7 +90,7 @@ func dealYear(gid string) { notifyMsgs = append(notifyMsgs, " ") notifyMsgs = append(notifyMsgs, fmt.Sprintf("🗣️ 去年本群 %d 位朋友共产生 %d 条发言", len(records), msgCount)) if showActivity { - notifyMsgs = append(notifyMsgs, fmt.Sprintf("🎭 活跃度: %s%", activity)) + notifyMsgs = append(notifyMsgs, fmt.Sprintf("🎭 活跃度: %s%%", activity)) } notifyMsgs = append(notifyMsgs, "\n🏵 活跃用户排行榜 🏵") diff --git a/tasks/watergroup/yesterday.go b/tasks/watergroup/yesterday.go index ab01626..b52d4fc 100644 --- a/tasks/watergroup/yesterday.go +++ b/tasks/watergroup/yesterday.go @@ -84,7 +84,7 @@ func dealYesterday(gid string) { notifyMsgs = append(notifyMsgs, " ") notifyMsgs = append(notifyMsgs, fmt.Sprintf("🗣️ 昨日本群 %d 位朋友共产生 %d 条发言", len(records), msgCount)) if showActivity { - notifyMsgs = append(notifyMsgs, fmt.Sprintf("🎭 活跃度: %s%", activity)) + notifyMsgs = append(notifyMsgs, fmt.Sprintf("🎭 活跃度: %s%%", activity)) } notifyMsgs = append(notifyMsgs, "\n🏵 活跃用户排行榜 🏵") From c0c810d02eda9d6560f75e8130abbd0a3c97d4f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=AF=BB=E6=AC=A2?= Date: Wed, 13 Mar 2024 10:01:52 +0800 Subject: [PATCH 3/5] =?UTF-8?q?:sparkles:=20=E7=BE=A4=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E6=96=B0=E5=A2=9E=E6=B4=BB=E8=B7=83=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E4=BA=BA=E5=9D=87=E6=B6=88=E6=81=AF=E6=9D=A1=E6=95=B0?= =?UTF-8?q?=E5=92=8C=E4=B8=AD=E4=BD=8D=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tasks/watergroup/month.go | 13 ++++++++++--- tasks/watergroup/week.go | 13 ++++++++++--- tasks/watergroup/year.go | 13 ++++++++++--- tasks/watergroup/yesterday.go | 13 ++++++++++--- 4 files changed, 40 insertions(+), 12 deletions(-) diff --git a/tasks/watergroup/month.go b/tasks/watergroup/month.go index 54175e1..b8ff4a0 100644 --- a/tasks/watergroup/month.go +++ b/tasks/watergroup/month.go @@ -74,16 +74,23 @@ func dealMonth(gid string) { activity = fmt.Sprintf("%.2f", (float64(len(records))/float64(groupUsers))*100) } - // 计算消息总数 + // 计算消息总数、中位数 var msgCount int64 - for _, v := range records { + var medianCount int64 + for idx, v := range records { msgCount += v.Count + if idx == len(records)/2 { + medianCount = v.Count + } } + // 计算活跃用户人均消息条数 + avgMsgCount := int(float64(msgCount) / float64(len(records))) + // 组装消息总数推送信息 notifyMsgs = append(notifyMsgs, " ") notifyMsgs = append(notifyMsgs, fmt.Sprintf("🗣️ %s本群 %d 位朋友共产生 %d 条发言", monthStr, len(records), msgCount)) if showActivity { - notifyMsgs = append(notifyMsgs, fmt.Sprintf("🎭 活跃度: %s%%", activity)) + notifyMsgs = append(notifyMsgs, fmt.Sprintf("🎭 活跃度: %s%%,人均消息条数: %d,中位数: %d", activity, avgMsgCount, medianCount)) } notifyMsgs = append(notifyMsgs, "\n🏵 活跃用户排行榜 🏵") diff --git a/tasks/watergroup/week.go b/tasks/watergroup/week.go index 8cc5856..f2daa61 100644 --- a/tasks/watergroup/week.go +++ b/tasks/watergroup/week.go @@ -73,16 +73,23 @@ func dealWeek(gid string) { activity = fmt.Sprintf("%.2f", (float64(len(records))/float64(groupUsers))*100) } - // 计算消息总数 + // 计算消息总数、中位数 var msgCount int64 - for _, v := range records { + var medianCount int64 + for idx, v := range records { msgCount += v.Count + if idx == len(records)/2 { + medianCount = v.Count + } } + // 计算活跃用户人均消息条数 + avgMsgCount := int(float64(msgCount) / float64(len(records))) + // 组装消息总数推送信息 notifyMsgs = append(notifyMsgs, " ") notifyMsgs = append(notifyMsgs, fmt.Sprintf("🗣️ 上周本群 %d 位朋友共产生 %d 条发言", len(records), msgCount)) if showActivity { - notifyMsgs = append(notifyMsgs, fmt.Sprintf("🎭 活跃度: %s%%", activity)) + notifyMsgs = append(notifyMsgs, fmt.Sprintf("🎭 活跃度: %s%%,人均消息条数: %d,中位数: %d", activity, avgMsgCount, medianCount)) } notifyMsgs = append(notifyMsgs, "\n🏵 活跃用户排行榜 🏵") diff --git a/tasks/watergroup/year.go b/tasks/watergroup/year.go index 1c9f236..d3c94b0 100644 --- a/tasks/watergroup/year.go +++ b/tasks/watergroup/year.go @@ -73,11 +73,18 @@ func dealYear(gid string) { activity = fmt.Sprintf("%.2f", (float64(len(records))/float64(groupUsers))*100) } - // 计算消息总数 + // 计算消息总数、中位数 var msgCount int64 - for _, v := range records { + var medianCount int64 + for idx, v := range records { msgCount += v.Count + if idx == len(records)/2 { + medianCount = v.Count + } } + // 计算活跃用户人均消息条数 + avgMsgCount := int(float64(msgCount) / float64(len(records))) + // 组装消息总数推送信息 notifyMsgs = append(notifyMsgs, " ") notifyMsgs = append(notifyMsgs, "亲爱的群友们,新年已经悄悄来临,让我们一起迎接这充满希望和美好的时刻。在这个特殊的日子里,我要向你们致以最真挚的祝福。") @@ -90,7 +97,7 @@ func dealYear(gid string) { notifyMsgs = append(notifyMsgs, " ") notifyMsgs = append(notifyMsgs, fmt.Sprintf("🗣️ 去年本群 %d 位朋友共产生 %d 条发言", len(records), msgCount)) if showActivity { - notifyMsgs = append(notifyMsgs, fmt.Sprintf("🎭 活跃度: %s%%", activity)) + notifyMsgs = append(notifyMsgs, fmt.Sprintf("🎭 活跃度: %s%%,人均消息条数: %d,中位数: %d", activity, avgMsgCount, medianCount)) } notifyMsgs = append(notifyMsgs, "\n🏵 活跃用户排行榜 🏵") diff --git a/tasks/watergroup/yesterday.go b/tasks/watergroup/yesterday.go index b52d4fc..184a1e1 100644 --- a/tasks/watergroup/yesterday.go +++ b/tasks/watergroup/yesterday.go @@ -75,16 +75,23 @@ func dealYesterday(gid string) { activity = fmt.Sprintf("%.2f", (float64(len(records))/float64(groupUsers))*100) } - // 计算消息总数 + // 计算消息总数、中位数 var msgCount int64 - for _, v := range records { + var medianCount int64 + for idx, v := range records { msgCount += v.Count + if idx == len(records)/2 { + medianCount = v.Count + } } + // 计算活跃用户人均消息条数 + avgMsgCount := int(float64(msgCount) / float64(len(records))) + // 组装消息总数推送信息 notifyMsgs = append(notifyMsgs, " ") notifyMsgs = append(notifyMsgs, fmt.Sprintf("🗣️ 昨日本群 %d 位朋友共产生 %d 条发言", len(records), msgCount)) if showActivity { - notifyMsgs = append(notifyMsgs, fmt.Sprintf("🎭 活跃度: %s%%", activity)) + notifyMsgs = append(notifyMsgs, fmt.Sprintf("🎭 活跃度: %s%%,人均消息条数: %d,中位数: %d", activity, avgMsgCount, medianCount)) } notifyMsgs = append(notifyMsgs, "\n🏵 活跃用户排行榜 🏵") From 8ddc40cc0153760ecaeebe950d593034ef377308 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=AF=BB=E6=AC=A2?= Date: Wed, 13 Mar 2024 10:02:40 +0800 Subject: [PATCH 4/5] =?UTF-8?q?:sparkles:=20=E7=BE=A4=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E6=96=B0=E5=A2=9E=E6=B4=BB=E8=B7=83=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E4=BA=BA=E5=9D=87=E6=B6=88=E6=81=AF=E6=9D=A1=E6=95=B0?= =?UTF-8?q?=E5=92=8C=E4=B8=AD=E4=BD=8D=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tasks/watergroup/month.go | 2 +- tasks/watergroup/week.go | 2 +- tasks/watergroup/year.go | 2 +- tasks/watergroup/yesterday.go | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tasks/watergroup/month.go b/tasks/watergroup/month.go index b8ff4a0..971df23 100644 --- a/tasks/watergroup/month.go +++ b/tasks/watergroup/month.go @@ -79,7 +79,7 @@ func dealMonth(gid string) { var medianCount int64 for idx, v := range records { msgCount += v.Count - if idx == len(records)/2 { + if idx == (len(records)/2)-1 { medianCount = v.Count } } diff --git a/tasks/watergroup/week.go b/tasks/watergroup/week.go index f2daa61..b8df0c9 100644 --- a/tasks/watergroup/week.go +++ b/tasks/watergroup/week.go @@ -78,7 +78,7 @@ func dealWeek(gid string) { var medianCount int64 for idx, v := range records { msgCount += v.Count - if idx == len(records)/2 { + if idx == (len(records)/2)-1 { medianCount = v.Count } } diff --git a/tasks/watergroup/year.go b/tasks/watergroup/year.go index d3c94b0..aba255a 100644 --- a/tasks/watergroup/year.go +++ b/tasks/watergroup/year.go @@ -78,7 +78,7 @@ func dealYear(gid string) { var medianCount int64 for idx, v := range records { msgCount += v.Count - if idx == len(records)/2 { + if idx == (len(records)/2)-1 { medianCount = v.Count } } diff --git a/tasks/watergroup/yesterday.go b/tasks/watergroup/yesterday.go index 184a1e1..b932756 100644 --- a/tasks/watergroup/yesterday.go +++ b/tasks/watergroup/yesterday.go @@ -80,7 +80,7 @@ func dealYesterday(gid string) { var medianCount int64 for idx, v := range records { msgCount += v.Count - if idx == len(records)/2 { + if idx == (len(records)/2)-1 { medianCount = v.Count } } From d21089ab696c3611093ba20d30d9177464f8c844 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=AF=BB=E6=AC=A2?= Date: Wed, 13 Mar 2024 10:32:20 +0800 Subject: [PATCH 5/5] =?UTF-8?q?:sparkles:=20=E7=BE=A4=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E6=96=B0=E5=A2=9E=E5=89=8D=E5=8D=81=E5=90=8D?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E6=95=B0=E5=8D=A0=E6=AF=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tasks/watergroup/month.go | 15 +++++++++++---- tasks/watergroup/week.go | 15 +++++++++++---- tasks/watergroup/year.go | 15 +++++++++++---- tasks/watergroup/yesterday.go | 15 +++++++++++---- 4 files changed, 44 insertions(+), 16 deletions(-) diff --git a/tasks/watergroup/month.go b/tasks/watergroup/month.go index 971df23..f3b8c81 100644 --- a/tasks/watergroup/month.go +++ b/tasks/watergroup/month.go @@ -74,14 +74,16 @@ func dealMonth(gid string) { activity = fmt.Sprintf("%.2f", (float64(len(records))/float64(groupUsers))*100) } - // 计算消息总数、中位数 - var msgCount int64 - var medianCount int64 + // 计算消息总数、中位数、前十位消息总数 + var msgCount, medianCount, topTenCount int64 for idx, v := range records { msgCount += v.Count if idx == (len(records)/2)-1 { medianCount = v.Count } + if len(records) > 10 && idx < 10 { + topTenCount += v.Count + } } // 计算活跃用户人均消息条数 avgMsgCount := int(float64(msgCount) / float64(len(records))) @@ -90,7 +92,12 @@ func dealMonth(gid string) { notifyMsgs = append(notifyMsgs, " ") notifyMsgs = append(notifyMsgs, fmt.Sprintf("🗣️ %s本群 %d 位朋友共产生 %d 条发言", monthStr, len(records), msgCount)) if showActivity { - notifyMsgs = append(notifyMsgs, fmt.Sprintf("🎭 活跃度: %s%%,人均消息条数: %d,中位数: %d", activity, avgMsgCount, medianCount)) + m := fmt.Sprintf("🎭 活跃度: %s%%,人均消息条数: %d,中位数: %d", activity, avgMsgCount, medianCount) + // 计算前十占比 + if topTenCount > 0 { + m += fmt.Sprintf(",前十名占比: %.2f%%", float64(topTenCount)/float64(msgCount)*100) + } + notifyMsgs = append(notifyMsgs, m) } notifyMsgs = append(notifyMsgs, "\n🏵 活跃用户排行榜 🏵") diff --git a/tasks/watergroup/week.go b/tasks/watergroup/week.go index b8df0c9..b4902c0 100644 --- a/tasks/watergroup/week.go +++ b/tasks/watergroup/week.go @@ -73,14 +73,16 @@ func dealWeek(gid string) { activity = fmt.Sprintf("%.2f", (float64(len(records))/float64(groupUsers))*100) } - // 计算消息总数、中位数 - var msgCount int64 - var medianCount int64 + // 计算消息总数、中位数、前十位消息总数 + var msgCount, medianCount, topTenCount int64 for idx, v := range records { msgCount += v.Count if idx == (len(records)/2)-1 { medianCount = v.Count } + if len(records) > 10 && idx < 10 { + topTenCount += v.Count + } } // 计算活跃用户人均消息条数 avgMsgCount := int(float64(msgCount) / float64(len(records))) @@ -89,7 +91,12 @@ func dealWeek(gid string) { notifyMsgs = append(notifyMsgs, " ") notifyMsgs = append(notifyMsgs, fmt.Sprintf("🗣️ 上周本群 %d 位朋友共产生 %d 条发言", len(records), msgCount)) if showActivity { - notifyMsgs = append(notifyMsgs, fmt.Sprintf("🎭 活跃度: %s%%,人均消息条数: %d,中位数: %d", activity, avgMsgCount, medianCount)) + m := fmt.Sprintf("🎭 活跃度: %s%%,人均消息条数: %d,中位数: %d", activity, avgMsgCount, medianCount) + // 计算前十占比 + if topTenCount > 0 { + m += fmt.Sprintf(",前十名占比: %.2f%%", float64(topTenCount)/float64(msgCount)*100) + } + notifyMsgs = append(notifyMsgs, m) } notifyMsgs = append(notifyMsgs, "\n🏵 活跃用户排行榜 🏵") diff --git a/tasks/watergroup/year.go b/tasks/watergroup/year.go index aba255a..8ea50ba 100644 --- a/tasks/watergroup/year.go +++ b/tasks/watergroup/year.go @@ -73,14 +73,16 @@ func dealYear(gid string) { activity = fmt.Sprintf("%.2f", (float64(len(records))/float64(groupUsers))*100) } - // 计算消息总数、中位数 - var msgCount int64 - var medianCount int64 + // 计算消息总数、中位数、前十位消息总数 + var msgCount, medianCount, topTenCount int64 for idx, v := range records { msgCount += v.Count if idx == (len(records)/2)-1 { medianCount = v.Count } + if len(records) > 10 && idx < 10 { + topTenCount += v.Count + } } // 计算活跃用户人均消息条数 avgMsgCount := int(float64(msgCount) / float64(len(records))) @@ -97,7 +99,12 @@ func dealYear(gid string) { notifyMsgs = append(notifyMsgs, " ") notifyMsgs = append(notifyMsgs, fmt.Sprintf("🗣️ 去年本群 %d 位朋友共产生 %d 条发言", len(records), msgCount)) if showActivity { - notifyMsgs = append(notifyMsgs, fmt.Sprintf("🎭 活跃度: %s%%,人均消息条数: %d,中位数: %d", activity, avgMsgCount, medianCount)) + m := fmt.Sprintf("🎭 活跃度: %s%%,人均消息条数: %d,中位数: %d", activity, avgMsgCount, medianCount) + // 计算前十占比 + if topTenCount > 0 { + m += fmt.Sprintf(",前十名占比: %.2f%%", float64(topTenCount)/float64(msgCount)*100) + } + notifyMsgs = append(notifyMsgs, m) } notifyMsgs = append(notifyMsgs, "\n🏵 活跃用户排行榜 🏵") diff --git a/tasks/watergroup/yesterday.go b/tasks/watergroup/yesterday.go index b932756..e6b3863 100644 --- a/tasks/watergroup/yesterday.go +++ b/tasks/watergroup/yesterday.go @@ -75,14 +75,16 @@ func dealYesterday(gid string) { activity = fmt.Sprintf("%.2f", (float64(len(records))/float64(groupUsers))*100) } - // 计算消息总数、中位数 - var msgCount int64 - var medianCount int64 + // 计算消息总数、中位数、前十位消息总数 + var msgCount, medianCount, topTenCount int64 for idx, v := range records { msgCount += v.Count if idx == (len(records)/2)-1 { medianCount = v.Count } + if len(records) > 10 && idx < 10 { + topTenCount += v.Count + } } // 计算活跃用户人均消息条数 avgMsgCount := int(float64(msgCount) / float64(len(records))) @@ -91,7 +93,12 @@ func dealYesterday(gid string) { notifyMsgs = append(notifyMsgs, " ") notifyMsgs = append(notifyMsgs, fmt.Sprintf("🗣️ 昨日本群 %d 位朋友共产生 %d 条发言", len(records), msgCount)) if showActivity { - notifyMsgs = append(notifyMsgs, fmt.Sprintf("🎭 活跃度: %s%%,人均消息条数: %d,中位数: %d", activity, avgMsgCount, medianCount)) + m := fmt.Sprintf("🎭 活跃度: %s%%,人均消息条数: %d,中位数: %d", activity, avgMsgCount, medianCount) + // 计算前十占比 + if topTenCount > 0 { + m += fmt.Sprintf(",前十名占比: %.2f%%", float64(topTenCount)/float64(msgCount)*100) + } + notifyMsgs = append(notifyMsgs, m) } notifyMsgs = append(notifyMsgs, "\n🏵 活跃用户排行榜 🏵")