Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a08966d454 | ||
|
|
24ddb1befe | ||
|
|
bb58b5090b | ||
|
|
6df5816867 | ||
|
|
e58c683b37 | ||
|
|
534fc904a2 | ||
|
|
e8bca43992 |
@@ -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
|
||||||
|
|||||||
@@ -34,6 +34,9 @@ func NotifyInvitationJoinGroup(m *plugin.MessageContext) {
|
|||||||
func NotifyRemoveFromChatroom(m *plugin.MessageContext) {
|
func NotifyRemoveFromChatroom(m *plugin.MessageContext) {
|
||||||
// 如果是被移出群聊,推送到配置的用户
|
// 如果是被移出群聊,推送到配置的用户
|
||||||
if strings.HasPrefix(m.Content, "你被\"") && strings.HasSuffix(m.Content, "\"移出群聊") {
|
if strings.HasPrefix(m.Content, "你被\"") && strings.HasSuffix(m.Content, "\"移出群聊") {
|
||||||
|
// 调用一下退出群聊接口,防止被移出后还能从好友列表接口拉到相关信息
|
||||||
|
utils.QuitChatroom(m.FromUser, 0)
|
||||||
|
|
||||||
// 取出群名称
|
// 取出群名称
|
||||||
groupInfo, err := service.GetFriendInfoById(m.FromUser)
|
groupInfo, err := service.GetFriendInfoById(m.FromUser)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -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) // 修改是否开启指令状态
|
||||||
|
|||||||
@@ -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())
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user