修复好友验证信息Shortpy字段类型声明错误
Signed-off-by: MiiW <mii.w@foxmail.com>
This commit is contained in:
parent
d2a2ffc119
commit
fda999473a
@ -518,7 +518,7 @@ type Card struct {
|
||||
// FriendAddMessage 好友添加消息信息内容
|
||||
type FriendAddMessage struct {
|
||||
XMLName xml.Name `xml:"msg"`
|
||||
Shortpy int `xml:"shortpy,attr"`
|
||||
Shortpy string `xml:"shortpy,attr"`
|
||||
ImageStatus int `xml:"imagestatus,attr"`
|
||||
Scene int `xml:"scene,attr"`
|
||||
PerCard int `xml:"percard,attr"`
|
||||
|
@ -3,6 +3,7 @@ package openwechat
|
||||
import (
|
||||
"fmt"
|
||||
"regexp"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func ExampleMessageType_output() {
|
||||
@ -43,3 +44,19 @@ func ExampleMessageType_output() {
|
||||
// 收到一条未知消息(type 6): MessageType(6)
|
||||
// 收到一条未知消息(type 51): MessageType(51)
|
||||
}
|
||||
|
||||
func TestMessage_FriendAddMessageContent(t *testing.T) {
|
||||
m := &Message{
|
||||
MsgType: 37,
|
||||
FromUserName: "fmessage",
|
||||
Content: "<msg fromusername=\"user1\" encryptusername=\"123123131@stranger\" fromnickname=\"nickname1\" content=\"test11111\" shortpy=\"MMHDNLXX\" imagestatus=\"3\" scene=\"3\" country=\"CN\" province=\"Zhejiang\" city=\"Hangzhou\" sign=\"Life is a struggle.\" percard=\"1\" sex=\"1\" alias=\"1111\" weibo=\"\" albumflag=\"0\" albumstyle=\"0\" albumbgimgid=\"\" snsflag=\"273\" snsbgimgid=\"http://shmmsns.qpic.cn/mbsFs/0\" snsbgobjectid=\"123123131\" mhash=\"1231231\" mfullhash=\"1231231\" bigheadimgurl=\"http://wx.qlogo.cn/mmhead/ver_1/1231231/0\" smallheadimgurl=\"http://wx.qlogo.cn/mmhead/ver_1/1231231/132\" ticket=\"1231231@stranger\" opcode=\"2\" googlecontact=\"\" qrticket=\"\" chatroomusername=\"123@chatroom\" sourceusername=\"\" sourcenickname=\"\" sharecardusername=\"\" sharecardnickname=\"\" cardversion=\"\" extflag=\"0\"><brandlist count=\"0\" ver=\"759291380\"></brandlist></msg>",
|
||||
}
|
||||
fm, err := m.FriendAddMessageContent()
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
if fm.Shortpy != "MMHDNLXX" {
|
||||
t.Error("unexpected shorty:", fm.Shortpy)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user