Files
chatlog/internal/model/message_darwinv3.go
Sarv b4378a63a3 adjust message handing (#22)
* adjust message handing

* mcp required args
2025-04-09 00:02:55 +08:00

58 lines
1.2 KiB
Go

package model
import (
"strings"
"time"
)
// CREATE TABLE Chat_md5(talker)(
// mesLocalID INTEGER PRIMARY KEY AUTOINCREMENT,
// mesSvrID INTEGER,msgCreateTime INTEGER,
// msgContent TEXT,msgStatus INTEGER,
// msgImgStatus INTEGER,
// messageType INTEGER,
// mesDes INTEGER,
// msgSource TEXT,
// IntRes1 INTEGER,
// IntRes2 INTEGER,
// StrRes1 TEXT,
// StrRes2 TEXT,
// msgVoiceText TEXT,
// msgSeq INTEGER,
// CompressContent BLOB,
// ConBlob BLOB
// )
type MessageDarwinV3 struct {
MsgCreateTime int64 `json:"msgCreateTime"`
MsgContent string `json:"msgContent"`
MessageType int64 `json:"messageType"`
MesDes int `json:"mesDes"` // 0: 发送, 1: 接收
}
func (m *MessageDarwinV3) Wrap(talker string) *Message {
_m := &Message{
Time: time.Unix(m.MsgCreateTime, 0),
Type: m.MessageType,
Talker: talker,
IsChatRoom: strings.HasSuffix(talker, "@chatroom"),
IsSelf: m.MesDes == 0,
Version: WeChatDarwinV3,
}
content := m.MsgContent
if _m.IsChatRoom {
split := strings.SplitN(content, ":\n", 2)
if len(split) == 2 {
_m.Sender = split[0]
content = split[1]
}
} else if !_m.IsSelf {
_m.Sender = talker
}
_m.ParseMediaInfo(content)
return _m
}