Merge pull request '🎨 优化被移除群聊通知
逻辑' (#72) from hotfix into main
All checks were successful
BuildImage / build-image (push) Successful in 1m22s
All checks were successful
BuildImage / build-image (push) Successful in 1m22s
Reviewed-on: #72
This commit is contained in:
commit
23ca86e75c
@ -4,6 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"go-wechat/config"
|
"go-wechat/config"
|
||||||
"go-wechat/plugin"
|
"go-wechat/plugin"
|
||||||
|
"go-wechat/service"
|
||||||
"go-wechat/utils"
|
"go-wechat/utils"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
@ -31,12 +32,20 @@ func NotifyInvitationJoinGroup(m *plugin.MessageContext) {
|
|||||||
// @description: 被移除群聊通知到配置用户
|
// @description: 被移除群聊通知到配置用户
|
||||||
// @param m
|
// @param m
|
||||||
func NotifyRemoveFromChatroom(m *plugin.MessageContext) {
|
func NotifyRemoveFromChatroom(m *plugin.MessageContext) {
|
||||||
if strings.HasPrefix(m.Content, "你被\"") && strings.HasSuffix(m.Content, "\"移出群聊") {
|
|
||||||
// 如果是被移出群聊,推送到配置的用户
|
// 如果是被移出群聊,推送到配置的用户
|
||||||
|
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 {
|
for _, user := range config.Conf.System.NewFriendNotify.ToUser {
|
||||||
if user != "" {
|
if user != "" {
|
||||||
// 发送一条新消息
|
// 发送一条新消息
|
||||||
utils.SendMessage(user, "", m.Content, 0)
|
utils.SendMessage(user, "", msg, 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,16 @@ func GetAllFriend() (friends, groups []vo.FriendItem, err error) {
|
|||||||
return
|
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
|
// GetAllEnableAI
|
||||||
// @description: 取出所有启用了AI的好友或群组
|
// @description: 取出所有启用了AI的好友或群组
|
||||||
// @return []entity.Friend
|
// @return []entity.Friend
|
||||||
|
Loading…
Reference in New Issue
Block a user