Compare commits
23 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a414a98a51 | ||
|
|
d21089ab69 | ||
|
|
a274f085f8 | ||
|
|
8ddc40cc01 | ||
|
|
c0c810d02e | ||
|
|
905dab5ab8 | ||
|
|
ddb0db0b6a | ||
|
|
8bac050a02 | ||
|
|
a548af9de2 | ||
|
|
64c3c9c78b | ||
|
|
0f7cf5515d | ||
|
|
a2d84dea08 | ||
|
|
d3f8a59390 | ||
|
|
165fefdb48 | ||
|
|
22474efc57 | ||
|
|
797821e2ed | ||
|
|
79cbeb6ea5 | ||
|
|
49705a03a8 | ||
|
|
40e97608d3 | ||
|
|
fe7bc02c08 | ||
|
|
bb2c4e919e | ||
|
|
0ea189fb82 | ||
|
|
778db8e349 |
@@ -88,7 +88,13 @@ func (m Message) IsRevokeMsg() bool {
|
|||||||
// @receiver m
|
// @receiver m
|
||||||
// @return bool
|
// @return bool
|
||||||
func (m Message) IsNewUserJoin() bool {
|
func (m Message) IsNewUserJoin() bool {
|
||||||
sysFlag := m.Type == types.MsgTypeSys && strings.Contains(m.Content, "\"邀请\"") && strings.Contains(m.Content, "\"加入了群聊")
|
if m.Type != types.MsgTypeSys {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
isInvitation := strings.Contains(m.Content, "\"邀请\"") && strings.Contains(m.Content, "\"加入了群聊")
|
||||||
|
isScanQrCode := strings.Contains(m.Content, "通过扫描") && strings.Contains(m.Content, "加入群聊")
|
||||||
|
sysFlag := isInvitation || isScanQrCode
|
||||||
if sysFlag {
|
if sysFlag {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@@ -97,7 +103,7 @@ func (m Message) IsNewUserJoin() bool {
|
|||||||
if err := xml.Unmarshal([]byte(m.Content), &d); err != nil {
|
if err := xml.Unmarshal([]byte(m.Content), &d); err != nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return m.Type == types.MsgTypeSys && d.Type == "delchatroommember"
|
return d.Type == "delchatroommember"
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsAt
|
// IsAt
|
||||||
|
|||||||
13
readme.md
13
readme.md
@@ -48,7 +48,7 @@ version: '3.9'
|
|||||||
|
|
||||||
services:
|
services:
|
||||||
wechat:
|
wechat:
|
||||||
image: lxh01/wxhelper-docker:3.9.5.81-v11
|
image: lxh01/wxhelper-docker:3.9.5.81-v11-novnc # 如果不用noVNC网页,就删掉后面的-novnc
|
||||||
container_name: gw-wechat
|
container_name: gw-wechat
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
environment:
|
environment:
|
||||||
@@ -56,8 +56,9 @@ services:
|
|||||||
volumes:
|
volumes:
|
||||||
- ./data/wechat:/home/app/.wine/drive_c/users/app/Documents/WeChat\ Files
|
- ./data/wechat:/home/app/.wine/drive_c/users/app/Documents/WeChat\ Files
|
||||||
ports:
|
ports:
|
||||||
- "19087:8080"
|
- "19086:5900" # vnc端口
|
||||||
- "19088:19088"
|
- "19087:8080" # noVNC端口
|
||||||
|
- "19088:19088" # 微信HOOK端口
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ["CMD", "curl", "-f", "http://localhost:19088/api/checkLogin"]
|
test: ["CMD", "curl", "-f", "http://localhost:19088/api/checkLogin"]
|
||||||
interval: 60s
|
interval: 60s
|
||||||
@@ -100,4 +101,8 @@ services:
|
|||||||
# 以下命令选个能用的就行
|
# 以下命令选个能用的就行
|
||||||
docker-compose up -d # 老版本
|
docker-compose up -d # 老版本
|
||||||
docker compose up -d # 新版本
|
docker compose up -d # 新版本
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## 注意事项
|
||||||
|
1. 宿主机必须是`debian`系,因为`wine`的玄学`BUG`,其他系统可能会出现各种问题
|
||||||
|
2. 登录微信可以用`vnc viewer`连接`5900`端口或者访问`noVNC`端口的`vnc_lite.html`页面进行扫码登录
|
||||||
@@ -2,7 +2,9 @@ package watergroup
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"go-wechat/client"
|
||||||
"go-wechat/config"
|
"go-wechat/config"
|
||||||
|
"go-wechat/entity"
|
||||||
"go-wechat/service"
|
"go-wechat/service"
|
||||||
"go-wechat/utils"
|
"go-wechat/utils"
|
||||||
"log"
|
"log"
|
||||||
@@ -55,14 +57,48 @@ func dealMonth(gid string) {
|
|||||||
log.Printf("上月群[%s]无对话记录", gid)
|
log.Printf("上月群[%s]无对话记录", gid)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 计算消息总数
|
|
||||||
var msgCount int64
|
// 查询群成员总数
|
||||||
for _, v := range records {
|
var groupUsers int64
|
||||||
msgCount += v.Count
|
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
|
||||||
|
activity := "0.00"
|
||||||
|
if groupUsers > 0 {
|
||||||
|
activity = fmt.Sprintf("%.2f", (float64(len(records))/float64(groupUsers))*100)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 计算消息总数、中位数、前十位消息总数
|
||||||
|
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, " ")
|
||||||
notifyMsgs = append(notifyMsgs, fmt.Sprintf("🗣️ %s本群 %d 位朋友共产生 %d 条发言", monthStr, len(records), msgCount))
|
notifyMsgs = append(notifyMsgs, fmt.Sprintf("🗣️ %s本群 %d 位朋友共产生 %d 条发言", monthStr, len(records), msgCount))
|
||||||
|
if showActivity {
|
||||||
|
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🏵 活跃用户排行榜 🏵")
|
notifyMsgs = append(notifyMsgs, "\n🏵 活跃用户排行榜 🏵")
|
||||||
|
|
||||||
notifyMsgs = append(notifyMsgs, " ")
|
notifyMsgs = append(notifyMsgs, " ")
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ type rankUser struct {
|
|||||||
// @return err
|
// @return err
|
||||||
func getRankData(groupId, date string) (rank []rankUser, err error) {
|
func getRankData(groupId, date string) (rank []rankUser, err error) {
|
||||||
tx := client.MySQL.Table("t_message AS tm").
|
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").
|
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 AND is_member = 1").
|
||||||
Select("tm.group_user", "tgu.nickname", "count( 1 ) AS `count`").
|
Select("tm.group_user", "tgu.nickname", "count( 1 ) AS `count`").
|
||||||
Where("tm.from_user = ?", groupId).
|
Where("tm.from_user = ?", groupId).
|
||||||
Where("tm.type < 10000").
|
Where("tm.type < 10000").
|
||||||
|
|||||||
@@ -2,7 +2,9 @@ package watergroup
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"go-wechat/client"
|
||||||
"go-wechat/config"
|
"go-wechat/config"
|
||||||
|
"go-wechat/entity"
|
||||||
"go-wechat/service"
|
"go-wechat/service"
|
||||||
"go-wechat/utils"
|
"go-wechat/utils"
|
||||||
"log"
|
"log"
|
||||||
@@ -54,14 +56,48 @@ func dealWeek(gid string) {
|
|||||||
log.Printf("上周群[%s]无对话记录", gid)
|
log.Printf("上周群[%s]无对话记录", gid)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 计算消息总数
|
|
||||||
var msgCount int64
|
// 查询群成员总数
|
||||||
for _, v := range records {
|
var groupUsers int64
|
||||||
msgCount += v.Count
|
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
|
||||||
|
activity := "0.00"
|
||||||
|
if groupUsers > 0 {
|
||||||
|
activity = fmt.Sprintf("%.2f", (float64(len(records))/float64(groupUsers))*100)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 计算消息总数、中位数、前十位消息总数
|
||||||
|
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, " ")
|
||||||
notifyMsgs = append(notifyMsgs, fmt.Sprintf("🗣️ 上周本群 %d 位朋友共产生 %d 条发言", len(records), msgCount))
|
notifyMsgs = append(notifyMsgs, fmt.Sprintf("🗣️ 上周本群 %d 位朋友共产生 %d 条发言", len(records), msgCount))
|
||||||
|
if showActivity {
|
||||||
|
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🏵 活跃用户排行榜 🏵")
|
notifyMsgs = append(notifyMsgs, "\n🏵 活跃用户排行榜 🏵")
|
||||||
|
|
||||||
notifyMsgs = append(notifyMsgs, " ")
|
notifyMsgs = append(notifyMsgs, " ")
|
||||||
|
|||||||
@@ -2,7 +2,9 @@ package watergroup
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"go-wechat/client"
|
||||||
"go-wechat/config"
|
"go-wechat/config"
|
||||||
|
"go-wechat/entity"
|
||||||
"go-wechat/service"
|
"go-wechat/service"
|
||||||
"go-wechat/utils"
|
"go-wechat/utils"
|
||||||
"log"
|
"log"
|
||||||
@@ -54,11 +56,37 @@ func dealYear(gid string) {
|
|||||||
log.Printf("去年本群[%s]无对话记录", gid)
|
log.Printf("去年本群[%s]无对话记录", gid)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 计算消息总数
|
|
||||||
var msgCount int64
|
// 查询群成员总数
|
||||||
for _, v := range records {
|
var groupUsers int64
|
||||||
msgCount += v.Count
|
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
|
||||||
|
activity := "0.00"
|
||||||
|
if groupUsers > 0 {
|
||||||
|
activity = fmt.Sprintf("%.2f", (float64(len(records))/float64(groupUsers))*100)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 计算消息总数、中位数、前十位消息总数
|
||||||
|
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, " ")
|
||||||
notifyMsgs = append(notifyMsgs, "亲爱的群友们,新年已经悄悄来临,让我们一起迎接这充满希望和美好的时刻。在这个特殊的日子里,我要向你们致以最真挚的祝福。")
|
notifyMsgs = append(notifyMsgs, "亲爱的群友们,新年已经悄悄来临,让我们一起迎接这充满希望和美好的时刻。在这个特殊的日子里,我要向你们致以最真挚的祝福。")
|
||||||
@@ -70,6 +98,14 @@ func dealYear(gid string) {
|
|||||||
notifyMsgs = append(notifyMsgs, fmt.Sprintf("祝福你们新年快乐!让我们一起迎接%d年的到来!", time.Now().Local().Year()))
|
notifyMsgs = append(notifyMsgs, fmt.Sprintf("祝福你们新年快乐!让我们一起迎接%d年的到来!", time.Now().Local().Year()))
|
||||||
notifyMsgs = append(notifyMsgs, " ")
|
notifyMsgs = append(notifyMsgs, " ")
|
||||||
notifyMsgs = append(notifyMsgs, fmt.Sprintf("🗣️ 去年本群 %d 位朋友共产生 %d 条发言", len(records), msgCount))
|
notifyMsgs = append(notifyMsgs, fmt.Sprintf("🗣️ 去年本群 %d 位朋友共产生 %d 条发言", len(records), msgCount))
|
||||||
|
if showActivity {
|
||||||
|
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🏵 活跃用户排行榜 🏵")
|
notifyMsgs = append(notifyMsgs, "\n🏵 活跃用户排行榜 🏵")
|
||||||
|
|
||||||
notifyMsgs = append(notifyMsgs, " ")
|
notifyMsgs = append(notifyMsgs, " ")
|
||||||
|
|||||||
@@ -2,7 +2,9 @@ package watergroup
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"go-wechat/client"
|
||||||
"go-wechat/config"
|
"go-wechat/config"
|
||||||
|
"go-wechat/entity"
|
||||||
"go-wechat/service"
|
"go-wechat/service"
|
||||||
"go-wechat/utils"
|
"go-wechat/utils"
|
||||||
"log"
|
"log"
|
||||||
@@ -56,14 +58,48 @@ func dealYesterday(gid string) {
|
|||||||
log.Printf("昨日群[%s]无对话记录", gid)
|
log.Printf("昨日群[%s]无对话记录", gid)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 计算消息总数
|
|
||||||
var msgCount int64
|
// 查询群成员总数
|
||||||
for _, v := range records {
|
var groupUsers int64
|
||||||
msgCount += v.Count
|
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
|
||||||
|
activity := "0.00"
|
||||||
|
if groupUsers > 0 {
|
||||||
|
activity = fmt.Sprintf("%.2f", (float64(len(records))/float64(groupUsers))*100)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 计算消息总数、中位数、前十位消息总数
|
||||||
|
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, " ")
|
||||||
notifyMsgs = append(notifyMsgs, fmt.Sprintf("🗣️ 昨日本群 %d 位朋友共产生 %d 条发言", len(records), msgCount))
|
notifyMsgs = append(notifyMsgs, fmt.Sprintf("🗣️ 昨日本群 %d 位朋友共产生 %d 条发言", len(records), msgCount))
|
||||||
|
if showActivity {
|
||||||
|
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🏵 活跃用户排行榜 🏵")
|
notifyMsgs = append(notifyMsgs, "\n🏵 活跃用户排行榜 🏵")
|
||||||
|
|
||||||
notifyMsgs = append(notifyMsgs, " ")
|
notifyMsgs = append(notifyMsgs, " ")
|
||||||
|
|||||||
Reference in New Issue
Block a user