1
0
forked from lxh/go-wxhelper

新增被移除群聊通知

This commit is contained in:
李寻欢 2024-07-10 14:56:11 +08:00
parent 9b5152e294
commit 4d3bef7cf5
2 changed files with 21 additions and 0 deletions

View File

@ -6,6 +6,7 @@ import (
plugin "go-wechat/plugin"
"go-wechat/plugin/plugins"
"go-wechat/service"
"go-wechat/types"
)
// Plugin
@ -28,6 +29,10 @@ func Plugin() {
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 {

View File

@ -5,6 +5,7 @@ import (
"go-wechat/config"
"go-wechat/plugin"
"go-wechat/utils"
"strings"
)
// NotifyInvitationJoinGroup
@ -25,3 +26,18 @@ func NotifyInvitationJoinGroup(m *plugin.MessageContext) {
}
}
}
// NotifyRemoveFromChatroom
// @description: 被移除群聊通知到配置用户
// @param m
func NotifyRemoveFromChatroom(m *plugin.MessageContext) {
if strings.HasPrefix(m.Content, "你被\"") && strings.HasSuffix(m.Content, "\"移出群聊") {
// 如果是被移出群聊,推送到配置的用户
for _, user := range config.Conf.System.NewFriendNotify.ToUser {
if user != "" {
// 发送一条新消息
utils.SendMessage(user, "", m.Content, 0)
}
}
}
}