Compare commits

...

22 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
李寻欢
5b187ff026 Merge pull request '🎨 优化新增加好友或者群之后的响应逻辑' (#74) from hotfix into main
Reviewed-on: https://gitee.ltd/lxh/go-wxhelper/pulls/74
2024-07-11 13:56:57 +08:00
李寻欢
e1c2eb78aa 🎨 优化新增加好友或者群之后的响应逻辑 2024-07-11 13:56:33 +08:00
李寻欢
3bc33f1d64 Merge pull request '🎨 优化被移除群聊通知逻辑' (#73) from hotfix into main
Reviewed-on: https://gitee.ltd/lxh/go-wxhelper/pulls/73
2024-07-11 09:14:18 +08:00
李寻欢
bc5adf26d9 🎨 优化被移除群聊通知逻辑 2024-07-11 09:13:54 +08:00
李寻欢
23ca86e75c Merge pull request '🎨 优化被移除群聊通知逻辑' (#72) from hotfix into main
Reviewed-on: https://gitee.ltd/lxh/go-wxhelper/pulls/72
2024-07-10 16:32:39 +08:00
李寻欢
1d41fc5a6b 🎨 优化被移除群聊通知逻辑 2024-07-10 16:32:18 +08:00
李寻欢
bcdf0a45d2 Merge pull request ' 新增被移除群聊通知' (#71) from hotfix into main
Reviewed-on: https://gitee.ltd/lxh/go-wxhelper/pulls/71
2024-07-10 14:56:49 +08:00
李寻欢
4d3bef7cf5 新增被移除群聊通知 2024-07-10 14:56:11 +08:00
李寻欢
205e34f67e Merge pull request '🎨 逻辑优化' (#70) from hotfix into main
Reviewed-on: https://gitee.ltd/lxh/go-wxhelper/pulls/70
2024-07-09 08:38:51 +08:00
李寻欢
9b5152e294 🎨 逻辑优化 2024-07-09 08:38:16 +08:00
李寻欢
c0f8169588 Merge pull request '🐛 修复加群通知不提醒的BUG' (#69) from hotfix into main
Reviewed-on: https://gitee.ltd/lxh/go-wxhelper/pulls/69
2024-07-08 10:58:22 +08:00
李寻欢
2e5632c203 🐛 修复加群通知不提醒的BUG 2024-07-08 10:57:52 +08:00
13 changed files with 314 additions and 186 deletions

View File

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

View File

@@ -25,6 +25,19 @@ func GetGroupUsers(ctx *gin.Context) {
ctx.String(http.StatusInternalServerError, "查询失败: %s", err.Error()) ctx.String(http.StatusInternalServerError, "查询失败: %s", err.Error())
return 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

@@ -6,6 +6,7 @@ import (
plugin "go-wechat/plugin" plugin "go-wechat/plugin"
"go-wechat/plugin/plugins" "go-wechat/plugin/plugins"
"go-wechat/service" "go-wechat/service"
"go-wechat/types"
) )
// Plugin // Plugin
@@ -23,6 +24,20 @@ func Plugin() {
return true return true
}, plugins.SaveToDb) }, plugins.SaveToDb)
// 通知邀请入群消息到配置用户
dispatcher.RegisterHandler(func(m *dto.Message) bool {
flag, _ := m.IsInvitationJoinGroup()
return flag
}, plugins.NotifyInvitationJoinGroup)
// 被移除群聊通知到配置用户
dispatcher.RegisterHandler(func(m *dto.Message) bool {
return m.Type == types.MsgTypeSys
}, plugins.NotifyRemoveFromChatroom)
// 响应好友添加成功消息
dispatcher.RegisterHandler(func(m *dto.Message) bool {
return m.Type == types.MsgTypeSys
}, plugins.ReplyNewFriend)
// 私聊指令消息 // 私聊指令消息
dispatcher.RegisterHandler(func(m *dto.Message) bool { dispatcher.RegisterHandler(func(m *dto.Message) bool {
// 私聊消息 或 群聊艾特机器人并且以/开头的消息 // 私聊消息 或 群聊艾特机器人并且以/开头的消息

View File

@@ -209,7 +209,9 @@ func (m Message) IsInvitationJoinGroup() (flag bool, str string) {
if err := xml.Unmarshal([]byte(m.Content), &md); err != nil { if err := xml.Unmarshal([]byte(m.Content), &md); err != nil {
return return
} }
return md.AppMsg.Type == "5" && strings.Contains(md.AppMsg.Content, "邀请你加入群聊"), md.AppMsg.Des flag = md.AppMsg.Type == "5" && md.AppMsg.Title == "邀请你加入群聊"
str = strings.ReplaceAll(md.AppMsg.Des, ",进入可查看详情。", "")
return
} }
return return
} }

View File

@@ -3,10 +3,8 @@ package mq
import ( import (
"encoding/json" "encoding/json"
"go-wechat/common/current" "go-wechat/common/current"
"go-wechat/config"
"go-wechat/model/dto" "go-wechat/model/dto"
"go-wechat/types" "go-wechat/types"
"go-wechat/utils"
"log" "log"
"strings" "strings"
) )
@@ -39,16 +37,6 @@ func parse(msg []byte) {
} }
log.Printf("收到新微信消息\n消息来源: %s\n群成员: %s\n消息类型: %v\n消息内容: %s", m.FromUser, m.GroupUser, m.Type, m.Content) log.Printf("收到新微信消息\n消息来源: %s\n群成员: %s\n消息类型: %v\n消息内容: %s", m.FromUser, m.GroupUser, m.Type, m.Content)
// 如果是邀请进群,推送到配置的用户
if flag, dec := m.IsInvitationJoinGroup(); flag {
for _, user := range config.Conf.System.NewFriendNotify.ToUser {
if user != "" {
// 发送一条新消息
utils.SendMessage(user, "", dec, 0)
}
}
}
// 插件不为空,开始执行 // 插件不为空,开始执行
if p := current.GetRobotMessageHandler(); p != nil { if p := current.GetRobotMessageHandler(); p != nil {
p(&m) p(&m)

View File

@@ -0,0 +1,55 @@
package plugins
import (
"fmt"
"go-wechat/config"
"go-wechat/plugin"
"go-wechat/service"
"go-wechat/utils"
"strings"
)
// NotifyInvitationJoinGroup
// @description: 通知邀请入群消息到配置用户
// @param m
func NotifyInvitationJoinGroup(m *plugin.MessageContext) {
// 先回复一条固定句子
utils.SendMessage(m.FromUser, m.GroupUser, "您的邀请消息已收到啦,正在通知我的主人来同意请求。在我加群之后将会进行初始化操作,直到收到我主动发送的消息就是初始化完成咯,在那之前请耐心等待喔~", 0)
// 如果是邀请进群,推送到配置的用户
if flag, dec := m.IsInvitationJoinGroup(); flag {
for _, user := range config.Conf.System.NewFriendNotify.ToUser {
if user != "" {
// 发送一条新消息
dec = fmt.Sprintf("#邀请入群提醒\n\n%s", dec)
utils.SendMessage(user, "", dec, 0)
}
}
}
}
// NotifyRemoveFromChatroom
// @description: 被移除群聊通知到配置用户
// @param m
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 {
return
}
// 组装消息
msg := fmt.Sprintf("#移除群聊提醒\n\n群Id: %s\n群名称: %s\n事件: %s", m.FromUser, groupInfo.Nickname, m.Content)
for _, user := range config.Conf.System.NewFriendNotify.ToUser {
if user != "" {
// 发送一条新消息
utils.SendMessage(user, "", msg, 0)
}
}
}
}

View File

@@ -0,0 +1,18 @@
package plugins
import (
"go-wechat/plugin"
"go-wechat/utils"
"strings"
)
// ReplyNewFriend
// @description: 响应好友添加成功消息
// @param m
func ReplyNewFriend(m *plugin.MessageContext) {
isNewFriend := strings.HasPrefix(m.Content, "你已添加了") && strings.HasSuffix(m.Content, ",现在可以开始聊天了。")
isNewChatroom := strings.Contains(m.Content, "\"邀请你加入了群聊,群聊参与人还有:")
if isNewFriend || isNewChatroom {
utils.SendMessage(m.FromUser, m.GroupUser, "AI正在初始化请稍等几分钟初始化完成之后我将主动告知您。", 0)
}
}

View File

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

View File

@@ -37,6 +37,16 @@ func GetAllFriend() (friends, groups []vo.FriendItem, err error) {
return return
} }
// GetFriendInfoById
// @description: 通过wxId获取好友信息
// @param wxId
// @return ent
// @return err
func GetFriendInfoById(wxId string) (ent entity.Friend, err error) {
err = client.MySQL.Where("wxid = ?", wxId).First(&ent).Error
return
}
// GetAllEnableAI // GetAllEnableAI
// @description: 取出所有启用了AI的好友或群组 // @description: 取出所有启用了AI的好友或群组
// @return []entity.Friend // @return []entity.Friend

View File

@@ -3,10 +3,8 @@ package tcpserver
import ( import (
"encoding/json" "encoding/json"
"go-wechat/common/current" "go-wechat/common/current"
"go-wechat/config"
"go-wechat/model/dto" "go-wechat/model/dto"
"go-wechat/types" "go-wechat/types"
"go-wechat/utils"
"log" "log"
"net" "net"
"strings" "strings"
@@ -40,16 +38,6 @@ func parse(remoteAddr net.Addr, msg []byte) {
} }
log.Printf("%s\n消息来源: %s\n群成员: %s\n消息类型: %v\n消息内容: %s", remoteAddr, m.FromUser, m.GroupUser, m.Type, m.Content) log.Printf("%s\n消息来源: %s\n群成员: %s\n消息类型: %v\n消息内容: %s", remoteAddr, m.FromUser, m.GroupUser, m.Type, m.Content)
// 如果是邀请进群,推送到配置的用户
if flag, dec := m.IsInvitationJoinGroup(); flag {
for _, user := range config.Conf.System.NewFriendNotify.ToUser {
if user != "" {
// 发送一条新消息
utils.SendMessage(user, "", dec, 0)
}
}
}
// 插件不为空,开始执行 // 插件不为空,开始执行
if p := current.GetRobotMessageHandler(); p != nil { if p := current.GetRobotMessageHandler(); p != nil {
p(&m) p(&m)

View File

@@ -158,3 +158,33 @@ func DeleteGroupMember(chatRoomId, memberIds string, retryCount int, isSure bool
DeleteGroupMember(chatRoomId, memberIds, 5, true) 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"> <dialog id="groupUserModal" class="modal">
<div class="modal-box w-11/12 max-w-7xl"> <div class="modal-box w-11/12 max-w-7xl">
<h3 class="font-bold text-lg" id="groupUserModalName">我是群名称</h3> <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> <div class="divider divider-warning">成员列表</div>
<table class="table table-zebra"> <table class="table table-zebra">
<thead> <thead>

View File

@@ -2,82 +2,82 @@ console.log("打开首页")
// 改变AI开启状态 // 改变AI开启状态
function changeAiEnableStatus(wxId) { function changeAiEnableStatus(wxId) {
// console.log("修改AI开启状态: ", wxId) // console.log("修改AI开启状态: ", wxId)
axios({ axios({
method: 'put', method: 'put',
url: '/api/ai/status', url: '/api/ai/status',
data: { data: {
wxId: wxId wxId: wxId
} }
}).then(function (response) { }).then(function (response) {
console.log(`返回结果: ${JSON.stringify(response)}`); console.log(`返回结果: ${JSON.stringify(response)}`);
alert(`${response.data}`) alert(`${response.data}`)
}).catch(function (error) { }).catch(function (error) {
console.log(`错误信息: ${error}`); console.log(`错误信息: ${error}`);
alert("修改失败") alert("修改失败")
}).finally(function () { }).finally(function () {
window.location.reload(); window.location.reload();
}) })
} }
// 修改水群排行榜状态 // 修改水群排行榜状态
function changeGroupRankEnableStatus(wxId) { function changeGroupRankEnableStatus(wxId) {
// console.log("修改水群排行榜开启状态: ", wxId) // console.log("修改水群排行榜开启状态: ", wxId)
axios({ axios({
method: 'put', method: 'put',
url: '/api/grouprank/status', url: '/api/grouprank/status',
data: { data: {
wxId: wxId wxId: wxId
} }
}).then(function (response) { }).then(function (response) {
console.log(`返回结果: ${JSON.stringify(response)}`); console.log(`返回结果: ${JSON.stringify(response)}`);
alert(`${response.data}`) alert(`${response.data}`)
}).catch(function (error) { }).catch(function (error) {
console.log(`错误信息: ${error}`); console.log(`错误信息: ${error}`);
alert("修改失败") alert("修改失败")
}).finally(function () { }).finally(function () {
window.location.reload(); window.location.reload();
}) })
} }
// 修改水群排行榜状态 // 修改水群排行榜状态
function changeSummaryEnableStatus(wxId) { function changeSummaryEnableStatus(wxId) {
// console.log("修改聊天记录总结开启状态: ", wxId) // console.log("修改聊天记录总结开启状态: ", wxId)
axios({ axios({
method: 'put', method: 'put',
url: '/api/summary/status', url: '/api/summary/status',
data: { data: {
wxId: wxId wxId: wxId
} }
}).then(function (response) { }).then(function (response) {
console.log(`返回结果: ${JSON.stringify(response)}`); console.log(`返回结果: ${JSON.stringify(response)}`);
alert(`${response.data}`) alert(`${response.data}`)
}).catch(function (error) { }).catch(function (error) {
console.log(`错误信息: ${error}`); console.log(`错误信息: ${error}`);
alert("修改失败") alert("修改失败")
}).finally(function () { }).finally(function () {
window.location.reload(); window.location.reload();
}) })
} }
// 修改欢迎语开启状态 // 修改欢迎语开启状态
function changeWelcomeEnableStatus(wxId) { function changeWelcomeEnableStatus(wxId) {
axios({ axios({
method: 'put', method: 'put',
url: '/api/welcome/status', url: '/api/welcome/status',
data: { data: {
wxId: wxId wxId: wxId
} }
}).then(function (response) { }).then(function (response) {
console.log(`返回结果: ${JSON.stringify(response)}`); console.log(`返回结果: ${JSON.stringify(response)}`);
alert(`${response.data}`) alert(`${response.data}`)
}).catch(function (error) { }).catch(function (error) {
console.log(`错误信息: ${error}`); console.log(`错误信息: ${error}`);
alert("修改失败") alert("修改失败")
}).finally(function () { }).finally(function () {
window.location.reload(); window.location.reload();
}) })
} }
// 修改用户新闻开启状态 // 修改用户新闻开启状态
@@ -101,117 +101,123 @@ function changeUserNewsStatus(wxId) {
// 修改指令权限启用状态 // 修改指令权限启用状态
function changeCommandEnableStatus(wxId) { function changeCommandEnableStatus(wxId) {
axios({ axios({
method: 'put', method: 'put',
url: '/api/command/status', url: '/api/command/status',
data: { data: {
wxId: wxId wxId: wxId
} }
}).then(function (response) { }).then(function (response) {
console.log(`返回结果: ${JSON.stringify(response)}`); console.log(`返回结果: ${JSON.stringify(response)}`);
alert(`${response.data}`) alert(`${response.data}`)
}).catch(function (error) { }).catch(function (error) {
console.log(`错误信息: ${error}`); console.log(`错误信息: ${error}`);
alert("修改失败") alert("修改失败")
}).finally(function () { }).finally(function () {
window.location.reload(); window.location.reload();
}) })
} }
// 修改群成员是否参与排行榜状态 // 修改群成员是否参与排行榜状态
function changeUserGroupRankSkipStatus(groupId, userId) { function changeUserGroupRankSkipStatus(groupId, userId) {
console.log("修改水群排行榜开启状态: ", groupId, userId) console.log("修改水群排行榜开启状态: ", groupId, userId)
axios({ axios({
method: 'put', method: 'put',
url: '/api/grouprank/skip', url: '/api/grouprank/skip',
data: { data: {
wxId: groupId, wxId: groupId,
userId: userId userId: userId
} }
}).then(function (response) { }).then(function (response) {
console.log(`返回结果: ${JSON.stringify(response)}`); console.log(`返回结果: ${JSON.stringify(response)}`);
alert(`${response.data}`) alert(`${response.data}`)
}).catch(function (error) { }).catch(function (error) {
console.log(`错误信息: ${error}`); console.log(`错误信息: ${error}`);
alert("修改失败") alert("修改失败")
}).finally(function () { }).finally(function () {
window.location.reload(); window.location.reload();
}) })
} }
// 获取群成员列表 // 获取群成员列表
function getGroupUsers(groupId, groupName) { function getGroupUsers(groupId, groupName) {
// 获取表格的tbody部分以便稍后向其中添加行 // 获取表格的tbody部分以便稍后向其中添加行
var tbody = document.getElementById("groupUsers"); var tbody = document.getElementById("groupUsers");
tbody.innerHTML = "" tbody.innerHTML = ""
// 打开模态框 // 打开模态框
const modal = document.getElementById("groupUserModal"); const modal = document.getElementById("groupUserModal");
modal.showModal() modal.showModal()
// 设置群名称 // 设置群名称
const groupNameTag = document.getElementById("groupUserModalName"); const groupNameTag = document.getElementById("groupUserModalName");
groupNameTag.innerHTML = '<span class="loading loading-dots loading-lg"></span>' groupNameTag.innerHTML = '<span class="loading loading-dots loading-lg"></span>'
// 显示加载框 // 显示加载框
// const loading = document.getElementById("groupUserDataLoading"); // const loading = document.getElementById("groupUserDataLoading");
// loading.style.display = "block" // loading.style.display = "block"
axios.get('/api/group/users', { axios.get('/api/group/users', {
params: { params: {
groupId: groupId groupId: groupId
} }
}).then(function (response) { }).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;
groupUsers.forEach((groupUser, i) => {
console.log(groupUser)
const { wxid, nickname, isMember, isAdmin, joinTime, lastActive, leaveTime, skipChatRank } = groupUser;
let row = tbody.insertRow(i); // 设置成员总数
// Insert data into cells const groupUserCountTag = document.getElementById("groupUserCount");
row.insertCell(0).innerHTML = wxid; groupUserCountTag.innerHTML = `健在成员: ${groupUserCount}`
row.insertCell(1).innerHTML = nickname;
row.insertCell(2).innerHTML = `<span class="inline-flex items-center rounded-md px-2 py-1 text-xs font-medium ring-1 ring-inset ${isMember ? 'bg-green-50 text-green-700 ring-green-600/20' : 'bg-red-50 text-red-700 ring-red-600/20'}">${isMember ? '是' : '否'}</span>`; // 循环渲染数据
row.insertCell(3).innerHTML = `<span class="inline-flex items-center rounded-md px-2 py-1 text-xs font-medium ring-1 ring-inset ${isAdmin ? 'bg-green-50 text-green-700 ring-green-600/20' : 'bg-red-50 text-red-700 ring-red-600/20'}">${isAdmin ? '是' : '否'}</span>`; groupUsers.forEach((groupUser, i) => {
row.insertCell(4).innerHTML = joinTime; // console.log(groupUser)
row.insertCell(5).innerHTML = lastActive; const {wxid, nickname, isMember, isAdmin, joinTime, lastActive, leaveTime, skipChatRank} = groupUser;
row.insertCell(6).innerHTML = leaveTime;
// row.insertCell(7).innerHTML = `<input type="checkbox" class="toggle toggle-error" ${skipChatRank ? 'checked' : ''} onclick="changeUserGroupRankSkipStatus('${groupId}', '${wxid}')" />`; let row = tbody.insertRow(i);
row.insertCell(7).innerHTML = `<span class="inline-flex items-center rounded-md px-2 py-1 text-xs font-medium ring-1 ring-inset ${skipChatRank ? 'bg-green-50 text-green-700 ring-green-600/20' : 'bg-red-50 text-red-700 ring-red-600/20'}">${skipChatRank ? '是' : '否'}</span>`; // Insert data into cells
}); row.insertCell(0).innerHTML = wxid;
}).catch(function (error) { row.insertCell(1).innerHTML = nickname;
console.log(`错误信息: ${error}`); row.insertCell(2).innerHTML = `<span class="inline-flex items-center rounded-md px-2 py-1 text-xs font-medium ring-1 ring-inset ${isMember ? 'bg-green-50 text-green-700 ring-green-600/20' : 'bg-red-50 text-red-700 ring-red-600/20'}">${isMember ? '是' : '否'}</span>`;
}).finally(function () { row.insertCell(3).innerHTML = `<span class="inline-flex items-center rounded-md px-2 py-1 text-xs font-medium ring-1 ring-inset ${isAdmin ? 'bg-green-50 text-green-700 ring-green-600/20' : 'bg-red-50 text-red-700 ring-red-600/20'}">${isAdmin ? '是' : '否'}</span>`;
// 隐藏加载框 row.insertCell(4).innerHTML = joinTime;
// loading.style.display = "none" row.insertCell(5).innerHTML = lastActive;
groupNameTag.innerHTML = groupName row.insertCell(6).innerHTML = leaveTime;
}) // row.insertCell(7).innerHTML = `<input type="checkbox" class="toggle toggle-error" ${skipChatRank ? 'checked' : ''} onclick="changeUserGroupRankSkipStatus('${groupId}', '${wxid}')" />`;
row.insertCell(7).innerHTML = `<span class="inline-flex items-center rounded-md px-2 py-1 text-xs font-medium ring-1 ring-inset ${skipChatRank ? 'bg-green-50 text-green-700 ring-green-600/20' : 'bg-red-50 text-red-700 ring-red-600/20'}">${skipChatRank ? '是' : '否'}</span>`;
});
}).catch(function (error) {
console.log(`错误信息: ${error}`);
}).finally(function () {
// 隐藏加载框
// loading.style.display = "none"
groupNameTag.innerHTML = groupName
})
} }
// AI模型变动 // AI模型变动
function aiModelChange(event, wxid) { function aiModelChange(event, wxid) {
// 取出变动后的值 // 取出变动后的值
const modelStr = event.target.value; const modelStr = event.target.value;
console.log("AI模型变动: ", wxid, modelStr) console.log("AI模型变动: ", wxid, modelStr)
axios({ axios({
method: 'post', method: 'post',
url: '/api/ai/model', url: '/api/ai/model',
data: { data: {
wxid: wxid, wxid: wxid,
model: modelStr model: modelStr
} }
}).then(function (response) { }).then(function (response) {
console.log(`返回结果: ${JSON.stringify(response)}`); console.log(`返回结果: ${JSON.stringify(response)}`);
alert(`${response.data}`) alert(`${response.data}`)
}).catch(function (error) { }).catch(function (error) {
console.log(`错误信息: ${error}`); console.log(`错误信息: ${error}`);
alert("修改失败") alert("修改失败")
}).finally(function () { }).finally(function () {
window.location.reload(); window.location.reload();
}) })
} }
// AI角色变动 // AI角色变动