From e1c2eb78aadce0a90a02443e653fd0e5ae1f03ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=AF=BB=E6=AC=A2?= Date: Thu, 11 Jul 2024 13:56:33 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E4=BC=98=E5=8C=96=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=A5=BD=E5=8F=8B=E6=88=96=E8=80=85=E7=BE=A4=E4=B9=8B?= =?UTF-8?q?=E5=90=8E=E7=9A=84=E5=93=8D=E5=BA=94=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- initialization/plugin.go | 4 ++++ plugin/plugins/systemmessgae.go | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 plugin/plugins/systemmessgae.go diff --git a/initialization/plugin.go b/initialization/plugin.go index 54cff930..3265f667 100644 --- a/initialization/plugin.go +++ b/initialization/plugin.go @@ -33,6 +33,10 @@ func Plugin() { dispatcher.RegisterHandler(func(m *dto.Message) bool { return m.Type == types.MsgTypeSys }, plugins.NotifyRemoveFromChatroom) + // 响应好友添加成功消息 + dispatcher.RegisterHandler(func(m *dto.Message) bool { + return m.Type == types.MsgTypeSys + }, plugins.ReplyNewFriend) // 私聊指令消息 dispatcher.RegisterHandler(func(m *dto.Message) bool { diff --git a/plugin/plugins/systemmessgae.go b/plugin/plugins/systemmessgae.go new file mode 100644 index 00000000..0f8d620e --- /dev/null +++ b/plugin/plugins/systemmessgae.go @@ -0,0 +1,18 @@ +package plugins + +import ( + "go-wechat/plugin" + "go-wechat/utils" + "strings" +) + +// ReplyNewFriend +// @description: 响应好友添加成功消息 +// @param m +func ReplyNewFriend(m *plugin.MessageContext) { + isNewFriend := strings.HasPrefix(m.Content, "你已添加了") && strings.HasSuffix(m.Content, ",现在可以开始聊天了。") + isNewChatroom := strings.Contains(m.Content, "\"邀请你加入了群聊,群聊参与人还有:") + if isNewFriend || isNewChatroom { + utils.SendMessage(m.FromUser, m.GroupUser, "AI正在初始化,请稍等几分钟,初始化完成之后我将主动告知您。", 0) + } +}