Compare commits

...

10 Commits

Author SHA1 Message Date
李寻欢
a08966d454 Merge pull request 'hotfix' (#78) from hotfix into main
Reviewed-on: https://gitee.ltd/lxh/go-wxhelper/pulls/78
2024-07-12 10:04:23 +08:00
李寻欢
24ddb1befe Merge remote-tracking branch 'origin/hotfix' into hotfix 2024-07-12 10:03:51 +08:00
李寻欢
bb58b5090b 🎨 优化被移除群聊之后的处理逻辑 2024-07-12 10:03:45 +08:00
李寻欢
6df5816867 Merge pull request '🐛 Fix a bug.' (#77) from hotfix into main
Reviewed-on: https://gitee.ltd/lxh/go-wxhelper/pulls/77
2024-07-11 19:37:42 +08:00
李寻欢
e58c683b37 🐛 Fix a bug. 2024-07-11 19:37:27 +08:00
李寻欢
534fc904a2 Merge pull request '🐛 Fix a bug.' (#76) from hotfix into main
Reviewed-on: https://gitee.ltd/lxh/go-wxhelper/pulls/76
2024-07-11 19:32:47 +08:00
李寻欢
e8bca43992 🐛 Fix a bug. 2024-07-11 19:32:21 +08:00
李寻欢
f8f2d384f4 Merge pull request 'hotfix' (#75) from hotfix into main
Reviewed-on: https://gitee.ltd/lxh/go-wxhelper/pulls/75
2024-07-11 15:47:53 +08:00
李寻欢
28f08085ee 🎨 优化群成员显示效果 2024-07-11 15:47:35 +08:00
李寻欢
d802cbd6ca 🎨 优化群成员显示效果 2024-07-11 15:46:49 +08:00
7 changed files with 216 additions and 161 deletions

View File

@@ -20,7 +20,7 @@ type changeStatusParam struct {
// @description: 修改使用的AI模型用的参数集
type changeUseAiModelParam struct {
WxId string `json:"wxid" binding:"required"` // 群Id或微信Id
Model string `json:"dto"` // 模型代码
Model string `json:"model"` // 模型代码
}
// autoClearMembers

View File

@@ -25,6 +25,19 @@ func GetGroupUsers(ctx *gin.Context) {
ctx.String(http.StatusInternalServerError, "查询失败: %s", err.Error())
return
}
result := map[string]any{
"records": records,
}
// 循环数据,统计健在成员
var isOkCount int
for _, record := range records {
if record.IsMember {
isOkCount++
}
}
result["isOkCount"] = isOkCount
// 暂时先就这样写着,跑通了再改
ctx.JSON(http.StatusOK, records)
ctx.JSON(http.StatusOK, result)
}

View File

@@ -34,6 +34,9 @@ func NotifyInvitationJoinGroup(m *plugin.MessageContext) {
func NotifyRemoveFromChatroom(m *plugin.MessageContext) {
// 如果是被移出群聊,推送到配置的用户
if strings.HasPrefix(m.Content, "你被\"") && strings.HasSuffix(m.Content, "\"移出群聊") {
// 调用一下退出群聊接口,防止被移出后还能从好友列表接口拉到相关信息
utils.QuitChatroom(m.FromUser, 0)
// 取出群名称
groupInfo, err := service.GetFriendInfoById(m.FromUser)
if err != nil {

View File

@@ -24,7 +24,7 @@ func Init(g *gin.Engine) {
// 接口
api := g.Group("/api")
api.PUT("/ai/status", app.ChangeEnableAiStatus) // 修改是否开启AI状态
api.POST("/ai/dto", app.ChangeUseAiModel) // 修改使用的AI模型
api.POST("/ai/model", app.ChangeUseAiModel) // 修改使用的AI模型
api.POST("/ai/assistant", app.ChangeUseAiAssistant) // 修改使用的AI助手
api.PUT("/welcome/status", app.ChangeEnableWelcomeStatus) // 修改是否开启迎新状态
api.PUT("/command/status", app.ChangeEnableCommandStatus) // 修改是否开启指令状态

View File

@@ -158,3 +158,33 @@ func DeleteGroupMember(chatRoomId, memberIds string, retryCount int, isSure bool
DeleteGroupMember(chatRoomId, memberIds, 5, true)
}
}
// QuitChatroom
// @description: 退出群聊
// @param chatRoomId string 群Id
// @param retryCount int 重试次数
func QuitChatroom(chatRoomId string, retryCount int) {
if retryCount > 5 {
log.Printf("重试五次失败,停止发送")
return
}
// 组装参数
param := map[string]any{
"chatRoomId": chatRoomId, // 群Id
}
pbs, _ := json.Marshal(param)
res := resty.New()
resp, err := res.R().
SetHeader("Content-Type", "application/json;chartset=utf-8").
SetBody(string(pbs)).
Post(config.Conf.Wechat.GetURL("/api/quitChatRoom"))
if err != nil {
log.Printf("退群失败: %s", err.Error())
// 休眠五秒后重新发送
time.Sleep(5 * time.Second)
QuitChatroom(chatRoomId, retryCount+1)
}
log.Printf("退群结果: %s", resp.String())
}

View File

@@ -1,6 +1,9 @@
<dialog id="groupUserModal" class="modal">
<div class="modal-box w-11/12 max-w-7xl">
<div class="flex">
<h3 class="font-bold text-lg" id="groupUserModalName">我是群名称</h3>
<h3 class="font-bold text-lg ml-5" id="groupUserCount">(健在成员100人)</h3>
</div>
<div class="divider divider-warning">成员列表</div>
<table class="table table-zebra">
<thead>

View File

@@ -162,13 +162,19 @@ function getGroupUsers(groupId, groupName) {
groupId: groupId
}
}).then(function (response) {
// console.log(`返回结果: ${JSON.stringify(response)}`);
// console.log(`返回结果: ${JSON.stringify(response.data)}`);
// 渲染群成员列表
const groupUsers = response.data
const groupUsers = response.data.records;
const groupUserCount = response.data.isOkCount;
// 设置成员总数
const groupUserCountTag = document.getElementById("groupUserCount");
groupUserCountTag.innerHTML = `健在成员: ${groupUserCount}`
// 循环渲染数据
groupUsers.forEach((groupUser, i) => {
console.log(groupUser)
const { wxid, nickname, isMember, isAdmin, joinTime, lastActive, leaveTime, skipChatRank } = groupUser;
// console.log(groupUser)
const {wxid, nickname, isMember, isAdmin, joinTime, lastActive, leaveTime, skipChatRank} = groupUser;
let row = tbody.insertRow(i);
// Insert data into cells