2024-07-08 10:57:52 +08:00
|
|
|
package plugins
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"go-wechat/config"
|
|
|
|
"go-wechat/plugin"
|
2024-07-10 16:32:18 +08:00
|
|
|
"go-wechat/service"
|
2024-07-08 10:57:52 +08:00
|
|
|
"go-wechat/utils"
|
2024-07-10 14:56:11 +08:00
|
|
|
"strings"
|
2024-07-08 10:57:52 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
// NotifyInvitationJoinGroup
|
|
|
|
// @description: 通知邀请入群消息到配置用户
|
|
|
|
// @param m
|
|
|
|
func NotifyInvitationJoinGroup(m *plugin.MessageContext) {
|
2024-07-09 08:38:16 +08:00
|
|
|
// 先回复一条固定句子
|
|
|
|
utils.SendMessage(m.FromUser, m.GroupUser, "您的邀请消息已收到啦,正在通知我的主人来同意请求。在我加群之后将会进行初始化操作,直到收到我主动发送的消息就是初始化完成咯,在那之前请耐心等待喔~", 0)
|
|
|
|
|
2024-07-08 10:57:52 +08:00
|
|
|
// 如果是邀请进群,推送到配置的用户
|
|
|
|
if flag, dec := m.IsInvitationJoinGroup(); flag {
|
|
|
|
for _, user := range config.Conf.System.NewFriendNotify.ToUser {
|
|
|
|
if user != "" {
|
|
|
|
// 发送一条新消息
|
|
|
|
dec = fmt.Sprintf("#邀请入群提醒\n\n%s", dec)
|
|
|
|
utils.SendMessage(user, "", dec, 0)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2024-07-10 14:56:11 +08:00
|
|
|
|
|
|
|
// NotifyRemoveFromChatroom
|
|
|
|
// @description: 被移除群聊通知到配置用户
|
|
|
|
// @param m
|
|
|
|
func NotifyRemoveFromChatroom(m *plugin.MessageContext) {
|
2024-07-10 16:32:18 +08:00
|
|
|
// 如果是被移出群聊,推送到配置的用户
|
2024-07-10 14:56:11 +08:00
|
|
|
if strings.HasPrefix(m.Content, "你被\"") && strings.HasSuffix(m.Content, "\"移出群聊") {
|
2024-07-12 10:03:45 +08:00
|
|
|
// 调用一下退出群聊接口,防止被移出后还能从好友列表接口拉到相关信息
|
|
|
|
utils.QuitChatroom(m.FromUser, 0)
|
|
|
|
|
2024-07-10 16:32:18 +08:00
|
|
|
// 取出群名称
|
2024-07-11 09:13:54 +08:00
|
|
|
groupInfo, err := service.GetFriendInfoById(m.FromUser)
|
2024-07-10 16:32:18 +08:00
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
// 组装消息
|
2024-07-11 09:13:54 +08:00
|
|
|
msg := fmt.Sprintf("#移除群聊提醒\n\n群Id: %s\n群名称: %s\n事件: %s", m.FromUser, groupInfo.Nickname, m.Content)
|
2024-07-10 16:32:18 +08:00
|
|
|
|
2024-07-10 14:56:11 +08:00
|
|
|
for _, user := range config.Conf.System.NewFriendNotify.ToUser {
|
|
|
|
if user != "" {
|
|
|
|
// 发送一条新消息
|
2024-07-10 16:32:18 +08:00
|
|
|
utils.SendMessage(user, "", msg, 0)
|
2024-07-10 14:56:11 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|