From 42ea1237ff7d9abcc35f469fc531fa5a35d2583c Mon Sep 17 00:00:00 2001 From: eatMoreApple <15055461510@163.com> Date: Sun, 25 Apr 2021 14:36:40 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0xml=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bot_test.go | 14 ++++++++++++++ message.go | 12 +++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/bot_test.go b/bot_test.go index 8149a81..4c59871 100644 --- a/bot_test.go +++ b/bot_test.go @@ -33,6 +33,20 @@ func TestBotLogin(t *testing.T) { 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) { self, err := getSelf() if err != nil { diff --git a/message.go b/message.go index 512a472..8f84749 100644 --- a/message.go +++ b/message.go @@ -260,7 +260,7 @@ func (m *Message) init(bot *Bot) { // if !m.IsFriendAdd() { // 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 VerifyFlag int } + +type Article struct { +} + +func xmlFormString(text string) string { + lt := strings.ReplaceAll(text, "<", "<") + gt := strings.ReplaceAll(lt, ">", ">") + br := strings.ReplaceAll(gt, "
", "\n") + return strings.ReplaceAll(br, "&amp;", "&") +}