From 4d3bef7cf5d198b110d098f93f47a0ea972114ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=AF=BB=E6=AC=A2?= Date: Wed, 10 Jul 2024 14:56:11 +0800 Subject: [PATCH] =?UTF-8?q?:sparkles:=20=E6=96=B0=E5=A2=9E`=E8=A2=AB?= =?UTF-8?q?=E7=A7=BB=E9=99=A4=E7=BE=A4=E8=81=8A=E9=80=9A=E7=9F=A5`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- initialization/plugin.go | 5 +++++ plugin/plugins/notify2configuser.go | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/initialization/plugin.go b/initialization/plugin.go index 9ddbd350..54cff930 100644 --- a/initialization/plugin.go +++ b/initialization/plugin.go @@ -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 { diff --git a/plugin/plugins/notify2configuser.go b/plugin/plugins/notify2configuser.go index bf2e41d3..77006017 100644 --- a/plugin/plugins/notify2configuser.go +++ b/plugin/plugins/notify2configuser.go @@ -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) + } + } + } +}