From 1d41fc5a6b40b244feee8466e700a56b83f33cf1 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 16:32:18 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E4=BC=98=E5=8C=96`=E8=A2=AB=E7=A7=BB?= =?UTF-8?q?=E9=99=A4=E7=BE=A4=E8=81=8A=E9=80=9A=E7=9F=A5`=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin/plugins/notify2configuser.go | 13 +++++++++++-- service/friend.go | 10 ++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/plugin/plugins/notify2configuser.go b/plugin/plugins/notify2configuser.go index 7700601..dc8f9d4 100644 --- a/plugin/plugins/notify2configuser.go +++ b/plugin/plugins/notify2configuser.go @@ -4,6 +4,7 @@ import ( "fmt" "go-wechat/config" "go-wechat/plugin" + "go-wechat/service" "go-wechat/utils" "strings" ) @@ -31,12 +32,20 @@ func NotifyInvitationJoinGroup(m *plugin.MessageContext) { // @description: 被移除群聊通知到配置用户 // @param m func NotifyRemoveFromChatroom(m *plugin.MessageContext) { + // 如果是被移出群聊,推送到配置的用户 if strings.HasPrefix(m.Content, "你被\"") && strings.HasSuffix(m.Content, "\"移出群聊") { - // 如果是被移出群聊,推送到配置的用户 + // 取出群名称 + groupName, err := service.GetFriendInfoById(m.FromUser) + if err != nil { + return + } + // 组装消息 + msg := fmt.Sprintf("#移除群聊提醒\n\n群Id: %s\n群名称: %s\n事件: %s", m.FromUser, groupName, m.Content) + for _, user := range config.Conf.System.NewFriendNotify.ToUser { if user != "" { // 发送一条新消息 - utils.SendMessage(user, "", m.Content, 0) + utils.SendMessage(user, "", msg, 0) } } } diff --git a/service/friend.go b/service/friend.go index 95be7af..d10cbed 100644 --- a/service/friend.go +++ b/service/friend.go @@ -37,6 +37,16 @@ func GetAllFriend() (friends, groups []vo.FriendItem, err error) { 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 // @description: 取出所有启用了AI的好友或群组 // @return []entity.Friend