Compare commits

...

7 Commits

Author SHA1 Message Date
李寻欢
905dab5ab8 Merge pull request '🐛 Fix a bug.' (#29) from hotfix into main
Reviewed-on: https://gitee.ltd/lxh/go-wxhelper/pulls/29
2024-03-12 08:37:32 +08:00
李寻欢
ddb0db0b6a 🐛 Fix a bug. 2024-03-12 08:37:05 +08:00
李寻欢
8bac050a02 Merge pull request 'hotfix' (#28) from hotfix into main
Reviewed-on: https://gitee.ltd/lxh/go-wxhelper/pulls/28
2024-03-11 14:56:45 +08:00
李寻欢
a548af9de2 🐛 修复活跃度不发送的BUG 2024-03-11 14:55:10 +08:00
李寻欢
64c3c9c78b 🎨 逻辑优化 2024-03-10 07:36:10 +08:00
李寻欢
0f7cf5515d Merge pull request '🐛 Fix a bug.' (#27) from hotfix into main
Reviewed-on: https://gitee.ltd/lxh/go-wxhelper/pulls/27
2024-03-08 07:45:51 +08:00
李寻欢
a2d84dea08 🐛 Fix a bug. 2024-03-08 07:45:05 +08:00
6 changed files with 24 additions and 22 deletions

View File

@@ -22,11 +22,6 @@ func parse(msg []byte) {
// 记录原始数据
m.Raw = string(msg)
// 如果不是自己的消息,直接返回
if m.ToUser == current.GetRobotInfo().WxId {
return
}
// 提取出群成员信息
// Sys类型的消息正文不包含微信 Id所以不需要处理
if m.IsGroup() && m.Type != types.MsgTypeSys {

View File

@@ -60,12 +60,15 @@ func dealMonth(gid string) {
// 查询群成员总数
var groupUsers int64
err = client.MySQL.Model(&entity.GroupUser{}).Where("group_id = ?", gid).Count(&groupUsers).Error
err = client.MySQL.Model(&entity.GroupUser{}).
Where("group_id = ?", gid).
Where("is_member IS TRUE").
Count(&groupUsers).Error
if err != nil {
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)
@@ -80,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🏵 活跃用户排行榜 🏵")

View File

@@ -59,12 +59,15 @@ func dealWeek(gid string) {
// 查询群成员总数
var groupUsers int64
err = client.MySQL.Model(&entity.GroupUser{}).Where("group_id = ?", gid).Count(&groupUsers).Error
err = client.MySQL.Model(&entity.GroupUser{}).
Where("group_id = ?", gid).
Where("is_member IS TRUE").
Count(&groupUsers).Error
if err != nil {
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)
@@ -79,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🏵 活跃用户排行榜 🏵")

View File

@@ -59,12 +59,15 @@ func dealYear(gid string) {
// 查询群成员总数
var groupUsers int64
err = client.MySQL.Model(&entity.GroupUser{}).Where("group_id = ?", gid).Count(&groupUsers).Error
err = client.MySQL.Model(&entity.GroupUser{}).
Where("group_id = ?", gid).
Where("is_member IS TRUE").
Count(&groupUsers).Error
if err != nil {
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)
@@ -87,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🏵 活跃用户排行榜 🏵")

View File

@@ -61,12 +61,15 @@ func dealYesterday(gid string) {
// 查询群成员总数
var groupUsers int64
err = client.MySQL.Model(&entity.GroupUser{}).Where("group_id = ?", gid).Count(&groupUsers).Error
err = client.MySQL.Model(&entity.GroupUser{}).
Where("group_id = ?", gid).
Where("is_member IS TRUE").
Count(&groupUsers).Error
if err != nil {
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)
@@ -81,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🏵 活跃用户排行榜 🏵")

View File

@@ -23,11 +23,6 @@ func parse(remoteAddr net.Addr, msg []byte) {
// 记录原始数据
m.Raw = string(msg)
// 如果不是自己的消息,直接返回
if m.ToUser == current.GetRobotInfo().WxId {
return
}
// 提取出群成员信息
// Sys类型的消息正文不包含微信 Id所以不需要处理
if m.IsGroup() && m.Type != types.MsgTypeSys {