Compare commits
No commits in common. "a08966d454576dca2bf74d4f7a799d4a654b575b" and "6df5816867e55d14b318eef95f8d07698aa26c1e" have entirely different histories.
a08966d454
...
6df5816867
@ -34,9 +34,6 @@ 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 {
|
||||
|
@ -158,33 +158,3 @@ 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())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user