添加xml格式化

This commit is contained in:
eatMoreApple 2021-04-25 14:36:40 +08:00
parent 67cff85503
commit 42ea1237ff
2 changed files with 25 additions and 1 deletions

View File

@ -33,6 +33,20 @@ func TestBotLogin(t *testing.T) {
t.Log(self.NickName) t.Log(self.NickName)
} }
func TestMessage(t *testing.T) {
bot := defaultBot()
bot.MessageHandler = func(msg *Message) {
if msg.IsMedia() {
fmt.Println(msg.Content)
}
}
if err := bot.Login(); err != nil {
t.Error(err)
return
}
bot.Block()
}
func TestFriend(t *testing.T) { func TestFriend(t *testing.T) {
self, err := getSelf() self, err := getSelf()
if err != nil { if err != nil {

View File

@ -260,7 +260,7 @@ func (m *Message) init(bot *Bot) {
// if !m.IsFriendAdd() { // if !m.IsFriendAdd() {
// return fmt.Errorf("the excepted message type is 37, but got %d", m.MsgType) // return fmt.Errorf("the excepted message type is 37, but got %d", m.MsgType)
// } // }
// m.ClientManager.Client.WebWxVerifyUser(m.ClientManager.storage, m.RecommendInfo, "") // return m.Bot.Caller.Client.WebWxVerifyUser(m.Bot.storage, m.RecommendInfo, "")
//} //}
// 发送消息的结构体 // 发送消息的结构体
@ -314,3 +314,13 @@ type RecommendInfo struct {
UserName string UserName string
VerifyFlag int VerifyFlag int
} }
type Article struct {
}
func xmlFormString(text string) string {
lt := strings.ReplaceAll(text, "&lt;", "<")
gt := strings.ReplaceAll(lt, "&gt;", ">")
br := strings.ReplaceAll(gt, "<br/>", "\n")
return strings.ReplaceAll(br, "&amp;amp;", "&")
}