1
0
forked from lxh/go-wxhelper

Merge remote-tracking branch 'origin/hotfix' into hotfix

This commit is contained in:
李寻欢 2024-03-22 23:07:00 +08:00
commit d589a9615e
4 changed files with 76 additions and 20 deletions

View File

@ -68,22 +68,36 @@ 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)
}
// 计算消息总数
var msgCount int64
for _, v := range records {
// 计算消息总数、中位数、前十位消息总数
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)))
// 组装消息总数推送信息
notifyMsgs = append(notifyMsgs, " ")
notifyMsgs = append(notifyMsgs, fmt.Sprintf("🗣️ %s本群 %d 位朋友共产生 %d 条发言", monthStr, len(records), msgCount))
if showActivity {
notifyMsgs = append(notifyMsgs, fmt.Sprintf("🎭 活跃度: %s%", activity))
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🏵 活跃用户排行榜 🏵")

View File

@ -67,22 +67,36 @@ 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)
}
// 计算消息总数
var msgCount int64
for _, v := range records {
// 计算消息总数、中位数、前十位消息总数
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)))
// 组装消息总数推送信息
notifyMsgs = append(notifyMsgs, " ")
notifyMsgs = append(notifyMsgs, fmt.Sprintf("🗣️ 上周本群 %d 位朋友共产生 %d 条发言", len(records), msgCount))
if showActivity {
notifyMsgs = append(notifyMsgs, fmt.Sprintf("🎭 活跃度: %s%", activity))
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🏵 活跃用户排行榜 🏵")

View File

@ -67,17 +67,26 @@ 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)
}
// 计算消息总数
var msgCount int64
for _, v := range records {
// 计算消息总数、中位数、前十位消息总数
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)))
// 组装消息总数推送信息
notifyMsgs = append(notifyMsgs, " ")
notifyMsgs = append(notifyMsgs, "亲爱的群友们,新年已经悄悄来临,让我们一起迎接这充满希望和美好的时刻。在这个特殊的日子里,我要向你们致以最真挚的祝福。")
@ -90,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%", activity))
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🏵 活跃用户排行榜 🏵")

View File

@ -69,22 +69,36 @@ 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)
}
// 计算消息总数
var msgCount int64
for _, v := range records {
// 计算消息总数、中位数、前十位消息总数
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)))
// 组装消息总数推送信息
notifyMsgs = append(notifyMsgs, " ")
notifyMsgs = append(notifyMsgs, fmt.Sprintf("🗣️ 昨日本群 %d 位朋友共产生 %d 条发言", len(records), msgCount))
if showActivity {
notifyMsgs = append(notifyMsgs, fmt.Sprintf("🎭 活跃度: %s%", activity))
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🏵 活跃用户排行榜 🏵")