adjust message handing
This commit is contained in:
@@ -27,48 +27,31 @@ type MessageDarwinV3 struct {
|
||||
MsgContent string `json:"msgContent"`
|
||||
MessageType int64 `json:"messageType"`
|
||||
MesDes int `json:"mesDes"` // 0: 发送, 1: 接收
|
||||
|
||||
// MesLocalID int64 `json:"mesLocalID"`
|
||||
// MesSvrID int64 `json:"mesSvrID"`
|
||||
// MesStatus int `json:"mesStatus"`
|
||||
// MesImgStatus int `json:"mesImgStatus"`
|
||||
// MsgSource string `json:"msgSource"`
|
||||
// IntRes1 int `json:"IntRes1"`
|
||||
// IntRes2 int `json:"IntRes2"`
|
||||
// StrRes1 string `json:"StrRes1"`
|
||||
// StrRes2 string `json:"StrRes2"`
|
||||
// MesVoiceText string `json:"mesVoiceText"`
|
||||
// MesSeq int `json:"mesSeq"`
|
||||
// CompressContent []byte `json:"CompressContent"`
|
||||
// ConBlob []byte `json:"ConBlob"`
|
||||
}
|
||||
|
||||
func (m *MessageDarwinV3) Wrap(talker string) *Message {
|
||||
|
||||
_m := &Message{
|
||||
CreateTime: time.Unix(m.MsgCreateTime, 0),
|
||||
Time: time.Unix(m.MsgCreateTime, 0),
|
||||
Type: m.MessageType,
|
||||
IsSender: (m.MesDes + 1) % 2,
|
||||
Talker: talker,
|
||||
IsChatRoom: strings.HasSuffix(talker, "@chatroom"),
|
||||
IsSelf: m.MesDes == 0,
|
||||
Version: WeChatDarwinV3,
|
||||
}
|
||||
|
||||
_m.IsChatRoom = strings.HasSuffix(talker, "@chatroom")
|
||||
|
||||
_m.Content = m.MsgContent
|
||||
content := m.MsgContent
|
||||
if _m.IsChatRoom {
|
||||
split := strings.SplitN(m.MsgContent, ":\n", 2)
|
||||
split := strings.SplitN(content, ":\n", 2)
|
||||
if len(split) == 2 {
|
||||
_m.ChatRoomSender = split[0]
|
||||
_m.Content = split[1]
|
||||
_m.Sender = split[0]
|
||||
content = split[1]
|
||||
}
|
||||
} else if !_m.IsSelf {
|
||||
_m.Sender = talker
|
||||
}
|
||||
|
||||
if _m.Type != 1 {
|
||||
mediaMessage, err := NewMediaMessage(_m.Type, _m.Content)
|
||||
if err == nil {
|
||||
_m.MediaMessage = mediaMessage
|
||||
}
|
||||
}
|
||||
_m.ParseMediaInfo(content)
|
||||
|
||||
return _m
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user