model

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 19, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Source
	WeChatV3 = "wechatv3"
	WeChatV4 = "wechatv4"
)

Variables

This section is empty.

Functions

func ParseBytesExtra

func ParseBytesExtra(b []byte) (chatRoomSender string)

ParseBytesExtra 解析额外数据 按需解析

Types

type ChatRoom

type ChatRoom struct {
	Name  string         `json:"name"`
	Owner string         `json:"owner"`
	Users []ChatRoomUser `json:"users"`

	// Extra From Contact
	Remark   string `json:"remark"`
	NickName string `json:"nickName"`

	User2DisplayName map[string]string `json:"-"`
}

func (*ChatRoom) DisplayName

func (c *ChatRoom) DisplayName() string

type ChatRoomUser

type ChatRoomUser struct {
	UserName    string `json:"userName"`
	DisplayName string `json:"displayName"`
}

func ParseRoomData

func ParseRoomData(b []byte) (users []ChatRoomUser)

type ChatRoomV3

type ChatRoomV3 struct {
	ChatRoomName string `json:"ChatRoomName"`
	Reserved2    string `json:"Reserved2"` // Creator
	RoomData     []byte `json:"RoomData"`
}

CREATE TABLE ChatRoom( ChatRoomName TEXT PRIMARY KEY, UserNameList TEXT, DisplayNameList TEXT, ChatRoomFlag int Default 0, Owner INTEGER DEFAULT 0, IsShowName INTEGER DEFAULT 0, SelfDisplayName TEXT, Reserved1 INTEGER DEFAULT 0, Reserved2 TEXT, Reserved3 INTEGER DEFAULT 0, Reserved4 TEXT, Reserved5 INTEGER DEFAULT 0, Reserved6 TEXT, RoomData BLOB, Reserved7 INTEGER DEFAULT 0, Reserved8 TEXT )

func (*ChatRoomV3) Wrap

func (c *ChatRoomV3) Wrap() *ChatRoom

type ChatRoomV4

type ChatRoomV4 struct {
	ID        int    `json:"id"`
	UserName  string `json:"username"`
	Owner     string `json:"owner"`
	ExtBuffer []byte `json:"ext_buffer"`
}

CREATE TABLE chat_room( id INTEGER PRIMARY KEY, username TEXT, owner TEXT, ext_buffer BLOB )

func (*ChatRoomV4) Wrap

func (c *ChatRoomV4) Wrap() *ChatRoom

type Contact

type Contact struct {
	UserName string `json:"userName"`
	Alias    string `json:"alias"`
	Remark   string `json:"remark"`
	NickName string `json:"nickName"`
	IsFriend bool   `json:"isFriend"`
}

func (*Contact) DisplayName

func (c *Contact) DisplayName() string

type ContactV3

type ContactV3 struct {
	UserName  string `json:"UserName"`
	Alias     string `json:"Alias"`
	Remark    string `json:"Remark"`
	NickName  string `json:"NickName"`
	Reserved1 int    `json:"Reserved1"` // 1 自己好友或自己加入的群聊; 0 群聊成员(非好友)

}

CREATE TABLE Contact( UserName TEXT PRIMARY KEY , Alias TEXT, EncryptUserName TEXT, DelFlag INTEGER DEFAULT 0, Type INTEGER DEFAULT 0, VerifyFlag INTEGER DEFAULT 0, Reserved1 INTEGER DEFAULT 0, Reserved2 INTEGER DEFAULT 0, Reserved3 TEXT, Reserved4 TEXT, Remark TEXT, NickName TEXT, LabelIDList TEXT, DomainList TEXT, ChatRoomType int, PYInitial TEXT, QuanPin TEXT, RemarkPYInitial TEXT, RemarkQuanPin TEXT, BigHeadImgUrl TEXT, SmallHeadImgUrl TEXT, HeadImgMd5 TEXT, ChatRoomNotify INTEGER DEFAULT 0, Reserved5 INTEGER DEFAULT 0, Reserved6 TEXT, Reserved7 TEXT, ExtraBuf BLOB, Reserved8 INTEGER DEFAULT 0, Reserved9 INTEGER DEFAULT 0, Reserved10 TEXT, Reserved11 TEXT )

func (*ContactV3) Wrap

func (c *ContactV3) Wrap() *Contact

type ContactV4

type ContactV4 struct {
	UserName  string `json:"username"`
	Alias     string `json:"alias"`
	Remark    string `json:"remark"`
	NickName  string `json:"nick_name"`
	LocalType int    `json:"local_type"` // 2 群聊; 3 群聊成员(非好友); 5,6 企业微信;

}

CREATE TABLE contact( id INTEGER PRIMARY KEY, username TEXT, local_type INTEGER, alias TEXT, encrypt_username TEXT, flag INTEGER, delete_flag INTEGER, verify_flag INTEGER, remark TEXT, remark_quan_pin TEXT, remark_pin_yin_initial TEXT, nick_name TEXT, pin_yin_initial TEXT, quan_pin TEXT, big_head_url TEXT, small_head_url TEXT, head_img_md5 TEXT, chat_room_notify INTEGER, is_in_chat_room INTEGER, description TEXT, extra_buffer BLOB, chat_room_type INTEGER )

func (*ContactV4) Wrap

func (c *ContactV4) Wrap() *Contact

type Message

type Message struct {
	Sequence        int64     `json:"sequence"`        // 消息序号,10位时间戳 + 3位序号
	CreateTime      time.Time `json:"createTime"`      // 消息创建时间,10位时间戳
	TalkerID        int       `json:"talkerID"`        // 聊天对象,Name2ID 表序号,索引值
	Talker          string    `json:"talker"`          // 聊天对象,微信 ID or 群 ID
	IsSender        int       `json:"isSender"`        // 是否为发送消息,0 接收消息,1 发送消息
	Type            int       `json:"type"`            // 消息类型
	SubType         int       `json:"subType"`         // 消息子类型
	Content         string    `json:"content"`         // 消息内容,文字聊天内容 或 XML
	CompressContent []byte    `json:"compressContent"` // 非文字聊天内容,如图片、语音、视频等
	IsChatRoom      bool      `json:"isChatRoom"`      // 是否为群聊消息
	ChatRoomSender  string    `json:"chatRoomSender"`  // 群聊消息发送人

	// Fill Info
	// 从联系人等信息中填充
	DisplayName  string `json:"-"` // 显示名称
	CharRoomName string `json:"-"` // 群聊名称

	Version string `json:"-"` // 消息版本,内部判断
}

func (*Message) PlainText

func (m *Message) PlainText(showChatRoom bool) string

type MessageV3

type MessageV3 struct {
	Sequence        int64  `json:"Sequence"`        // 消息序号,10位时间戳 + 3位序号
	CreateTime      int64  `json:"CreateTime"`      // 消息创建时间,10位时间戳
	TalkerID        int    `json:"TalkerId"`        // 聊天对象,Name2ID 表序号,索引值
	StrTalker       string `json:"StrTalker"`       // 聊天对象,微信 ID or 群 ID
	IsSender        int    `json:"IsSender"`        // 是否为发送消息,0 接收消息,1 发送消息
	Type            int    `json:"Type"`            // 消息类型
	SubType         int    `json:"SubType"`         // 消息子类型
	StrContent      string `json:"StrContent"`      // 消息内容,文字聊天内容 或 XML
	CompressContent []byte `json:"CompressContent"` // 非文字聊天内容,如图片、语音、视频等
	BytesExtra      []byte `json:"BytesExtra"`      // protobuf 额外数据,记录群聊发送人等信息

}

CREATE TABLE MSG ( localId INTEGER PRIMARY KEY AUTOINCREMENT, TalkerId INT DEFAULT 0, MsgSvrID INT, Type INT, SubType INT, IsSender INT, CreateTime INT, Sequence INT DEFAULT 0, StatusEx INT DEFAULT 0, FlagEx INT, Status INT, MsgServerSeq INT, MsgSequence INT, StrTalker TEXT, StrContent TEXT, DisplayContent TEXT, Reserved0 INT DEFAULT 0, Reserved1 INT DEFAULT 0, Reserved2 INT DEFAULT 0, Reserved3 INT DEFAULT 0, Reserved4 TEXT, Reserved5 TEXT, Reserved6 TEXT, CompressContent BLOB, BytesExtra BLOB, BytesTrans BLOB )

func (*MessageV3) Wrap

func (m *MessageV3) Wrap() *Message

type MessageV4

type MessageV4 struct {
	SortSeq        int64  `json:"sort_seq"`         // 消息序号,10位时间戳 + 3位序号
	LocalType      int    `json:"local_type"`       // 消息类型
	RealSenderID   int    `json:"real_sender_id"`   // 发送人 ID,对应 Name2Id 表序号
	CreateTime     int64  `json:"create_time"`      // 消息创建时间,10位时间戳
	MessageContent []byte `json:"message_content"`  // 消息内容,文字聊天内容 或 zstd 压缩内容
	PackedInfoData []byte `json:"packed_info_data"` // 额外数据,类似 proto,格式与 v3 有差异
	Status         int    `json:"status"`           // 消息状态,2 是已发送,4 是已接收,可以用于判断 IsSender(猜测)

}

CREATE TABLE Msg_xxxxxxxxxxxx( local_id INTEGER PRIMARY KEY AUTOINCREMENT, server_id INTEGER, local_type INTEGER, sort_seq INTEGER, real_sender_id INTEGER, create_time INTEGER, status INTEGER, upload_status INTEGER, download_status INTEGER, server_seq INTEGER, origin_source INTEGER, source TEXT, message_content TEXT, compress_content TEXT, packed_info_data BLOB, WCDB_CT_message_content INTEGER DEFAULT NULL, WCDB_CT_source INTEGER DEFAULT NULL )

func (*MessageV4) Wrap

func (m *MessageV4) Wrap(id2Name map[int]string, isChatRoom bool) *Message

type Session

type Session struct {
	UserName string    `json:"userName"`
	NOrder   int       `json:"nOrder"`
	NickName string    `json:"nickName"`
	Content  string    `json:"content"`
	NTime    time.Time `json:"nTime"`
}

func (*Session) PlainText

func (s *Session) PlainText(limit int) string

type SessionV3

type SessionV3 struct {
	StrUsrName  string `json:"strUsrName"`
	NOrder      int    `json:"nOrder"`
	StrNickName string `json:"strNickName"`
	StrContent  string `json:"strContent"`
	NTime       int64  `json:"nTime"`
}

CREATE TABLE Session( strUsrName TEXT PRIMARY KEY, nOrder INT DEFAULT 0, nUnReadCount INTEGER DEFAULT 0, parentRef TEXT, Reserved0 INTEGER DEFAULT 0, Reserved1 TEXT, strNickName TEXT, nStatus INTEGER, nIsSend INTEGER, strContent TEXT, nMsgType INTEGER, nMsgLocalID INTEGER, nMsgStatus INTEGER, nTime INTEGER, editContent TEXT, othersAtMe INT, Reserved2 INTEGER DEFAULT 0, Reserved3 TEXT, Reserved4 INTEGER DEFAULT 0, Reserved5 TEXT, bytesXml BLOB )

func (*SessionV3) Wrap

func (s *SessionV3) Wrap() *Session

type SessionV4

type SessionV4 struct {
	Username              string `json:"username"`
	Summary               string `json:"summary"`
	LastTimestamp         int    `json:"last_timestamp"`
	LastMsgSender         string `json:"last_msg_sender"`
	LastSenderDisplayName string `json:"last_sender_display_name"`
}

注意,v4 session 是独立数据库文件 CREATE TABLE SessionTable( username TEXT PRIMARY KEY, type INTEGER, unread_count INTEGER, unread_first_msg_srv_id INTEGER, is_hidden INTEGER, summary TEXT, draft TEXT, status INTEGER, last_timestamp INTEGER, sort_timestamp INTEGER, last_clear_unread_timestamp INTEGER, last_msg_locald_id INTEGER, last_msg_type INTEGER, last_msg_sub_type INTEGER, last_msg_sender TEXT, last_sender_display_name TEXT, last_msg_ext_type INTEGER )

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL