Compare commits

...

2 Commits

Author SHA1 Message Date
5b187ff026 Merge pull request '🎨 优化新增加好友或者群之后的响应逻辑' (#74) from hotfix into main
All checks were successful
BuildImage / build-image (push) Successful in 1m22s
Reviewed-on: #74
2024-07-11 13:56:57 +08:00
e1c2eb78aa 🎨 优化新增加好友或者群之后的响应逻辑 2024-07-11 13:56:33 +08:00
2 changed files with 22 additions and 0 deletions

View File

@ -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 {

View File

@ -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)
}
}