Compare commits

..

No commits in common. "0c2010c348e4814642394b9456a13c05271e7fc6" and "f796e7b3a8ae147d2e4d4efbb2986c8799fb1a9d" have entirely different histories.

2 changed files with 2 additions and 34 deletions

View File

@ -26,13 +26,13 @@ func Plugin() {
// 私聊指令消息
dispatcher.RegisterHandler(func(m *model.Message) bool {
// 私聊消息 或 群聊艾特机器人并且以/开头的消息
return (m.IsPrivateText() || (m.IsAt() && !m.IsAtAll() && m.CleanContentStartWith("/"))) && service.CheckIsEnableCommand(m.FromUser)
return (m.IsPrivateText() || (m.IsAt() && m.CleanContentStartWith("/"))) && service.CheckIsEnableCommand(m.FromUser)
}, plugins.Command)
// AI消息插件
dispatcher.RegisterHandler(func(m *model.Message) bool {
// 群内@或者私聊文字消息
return m.IsAt() && !m.IsAtAll() || m.IsPrivateText()
return m.IsAt() || m.IsPrivateText()
}, plugins.AI)
// 欢迎新成员

View File

@ -2,7 +2,6 @@ package model
import (
"encoding/xml"
"github.com/duke-git/lancet/v2/slice"
"go-wechat/types"
"regexp"
"strings"
@ -32,21 +31,6 @@ type systemMsgDataXml struct {
Type string `xml:"type,attr"`
}
// atMsgDataXml
// @description: 微信@消息的xml结构
type atMsgDataXml struct {
XMLName xml.Name `xml:"msgsource"`
Text string `xml:",chardata"`
AtUserList string `xml:"atuserlist"`
Silence string `xml:"silence"`
MemberCount string `xml:"membercount"`
Signature string `xml:"signature"`
TmpNode struct {
Text string `xml:",chardata"`
PublisherID string `xml:"publisher-id"`
} `xml:"tmp_node"`
}
// sysMsg
// @description: 消息主体
type sysMsg struct{}
@ -108,22 +92,6 @@ func (m Message) IsAt() bool {
return strings.HasSuffix(m.DisplayFullContent, "在群聊中@了你")
}
// IsAtAll
// @description: 是否是At所有人的消息
// @receiver m
// @return bool
func (m Message) IsAtAll() bool {
// 解析raw里面的xml
var d atMsgDataXml
if err := xml.Unmarshal([]byte(m.Raw), &d); err != nil {
return false
}
// 转换@用户列表为数组
atUserList := strings.Split(d.AtUserList, ",")
// 判断是否包含@所有人
return slice.Contain(atUserList, "notify@all")
}
// IsPrivateText
// @description: 是否是私聊消息
// @receiver m