model

package
v0.0.0-...-b00be9e Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WeChatV3       = "wechatv3"
	WeChatV4       = "wechatv4"
	WeChatDarwinV3 = "wechatdarwinv3"
)
View Source
const (
	// MessageTypeText 文本
	MessageTypeText = 1

	// MessageTypeImage 图片
	MessageTypeImage = 3

	// MessageTypeVoice 语音
	MessageTypeVoice = 34

	// MessageTypeCard 名片
	MessageTypeCard = 42

	// MessageTypeVideo 视频
	MessageTypeVideo = 43

	// MessageTypeAnimation 动画表情
	MessageTypeAnimation = 47

	// MessageTypeLocation 位置
	MessageTypeLocation = 48

	// MessageTypeShare 分享
	MessageTypeShare = 49

	// MessageTypeVOIP 语音通话
	MessageTypeVOIP = 50

	// MessageTypeSystem 系统
	MessageTypeSystem = 10000
)
View Source
const (
	// MessageSubTypeText 文本
	MessageSubTypeText = 1

	// MessageSubTypeLink 链接分享
	MessageSubTypeLink = 4

	// MessageSubTypeLink2 链接分享
	MessageSubTypeLink2 = 5

	// MessageSubTypeFile 文件
	MessageSubTypeFile = 6

	// MessageSubTypeGIF 动图
	MessageSubTypeGIF = 8

	// MessageSubTypeMergeForward 合并转发
	MessageSubTypeMergeForward = 19

	// MessageSubTypeNote 笔记
	MessageSubTypeNote = 24

	// MessageSubTypeMiniProgram 小程序
	MessageSubTypeMiniProgram = 33

	// MessageSubTypeMiniProgram2 小程序
	MessageSubTypeMiniProgram2 = 36

	// MessageSubTypeChannel 视频号
	MessageSubTypeChannel = 51

	// MessageSubTypeQuote 引用
	MessageSubTypeQuote = 57

	// MessageSubTypePat 拍一拍
	MessageSubTypePat = 62

	// MessageSubTypeChannelLive 视频号直播
	MessageSubTypeChannelLive = 63

	// MessageSubTypeChatRoomNotice 群公告
	MessageSubTypeChatRoomNotice = 87

	// MessageSubTypeMusic 音乐
	MessageSubTypeMusic = 92

	// MessageSubTypePay 转账
	MessageSubTypePay = 2000

	// MessageSubTypeRedEnvelope 红包
	MessageSubTypeRedEnvelope = 2001

	// MessageSubTypeRedEnvelopeCover 红包封面
	MessageSubTypeRedEnvelopeCover = 2003
)

Variables

View Source
var Debug = false

Functions

func ParseBytesExtra

func ParseBytesExtra(b []byte) map[int]string

ParseBytesExtra 解析额外数据 按需解析

func ParseBytesExtraPath

func ParseBytesExtraPath(s string) string

func ParsePackedInfo

func ParsePackedInfo(b []byte) *wxproto.PackedInfo

Types

type App

type App struct {
	Type              int         `xml:"type"`
	Title             string      `xml:"title"`
	Des               string      `xml:"des"`
	URL               string      `xml:"url"`                         // type 5 分享
	AppAttach         *AppAttach  `xml:"appattach,omitempty"`         // type 6 文件
	MD5               string      `xml:"md5,omitempty"`               // type 6 文件
	RecordItem        *RecordItem `xml:"recorditem,omitempty"`        // type 19 合并转发
	SourceDisplayName string      `xml:"sourcedisplayname,omitempty"` // type 33 小程序
	FinderFeed        *FinderFeed `xml:"finderFeed,omitempty"`        // type 51 视频号
	ReferMsg          *ReferMsg   `xml:"refermsg,omitempty"`          // type 57 引用
	PatMsg            *PatMsg     `xml:"patMsg,omitempty"`            // type 62 拍一拍
	PatInfo           *PatInfo    `xml:"patinfo,omitempty"`           // type 62 拍一拍 v2
	FinderLive        *FinderLive `xml:"finderLive,omitempty"`        // type 63 视频号直播
	WCPayInfo         *WCPayInfo  `xml:"wcpayinfo,omitempty"`         // type 2000 微信转账
}

type AppAttach

type AppAttach struct {
	TotalLen       string `xml:"totallen"`
	AttachID       string `xml:"attachid"`
	CDNAttachURL   string `xml:"cdnattachurl"`
	EmoticonMD5    string `xml:"emoticonmd5"`
	AESKey         string `xml:"aeskey"`
	FileExt        string `xml:"fileext"`
	IsLargeFileMsg string `xml:"islargefilemsg"`
}

AppAttach 表示应用附件

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 ChatRoomDarwinV3

type ChatRoomDarwinV3 struct {
	M_nsUsrName           string `json:"m_nsUsrName"`
	Nickname              string `json:"nickname"`
	M_nsRemark            string `json:"m_nsRemark"`
	M_nsChatRoomMemList   string `json:"m_nsChatRoomMemList"`
	M_nsChatRoomAdminList string `json:"m_nsChatRoomAdminList"`
}

CREATE TABLE GroupContact( m_nsUsrName TEXT PRIMARY KEY ASC, m_uiConType INTEGER, nickname TEXT, m_nsFullPY TEXT, m_nsShortPY TEXT, m_nsRemark TEXT, m_nsRemarkPYFull TEXT, m_nsRemarkPYShort TEXT, m_uiCertificationFlag INTEGER, m_uiSex INTEGER, m_uiType INTEGER, m_nsImgStatus TEXT, m_uiImgKey INTEGER, m_nsHeadImgUrl TEXT, m_nsHeadHDImgUrl TEXT, m_nsHeadHDMd5 TEXT, m_nsChatRoomMemList TEXT, m_nsChatRoomAdminList TEXT, m_uiChatRoomStatus INTEGER, m_nsChatRoomDesc TEXT, m_nsDraft TEXT, m_nsBrandIconUrl TEXT, m_nsGoogleContactName TEXT, m_nsAliasName TEXT, m_nsEncodeUserName TEXT, m_uiChatRoomVersion INTEGER, m_uiChatRoomMaxCount INTEGER, m_uiChatRoomType INTEGER, m_patSuffix TEXT, richChatRoomDesc TEXT, _packed_WCContactData BLOB, openIMInfo BLOB )

func (*ChatRoomDarwinV3) Wrap

func (c *ChatRoomDarwinV3) Wrap(user2DisplayName map[string]string) *ChatRoom

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 ContactDarwinV3

type ContactDarwinV3 struct {
	M_nsUsrName   string `json:"m_nsUsrName"`
	Nickname      string `json:"nickname"`
	M_nsRemark    string `json:"m_nsRemark"`
	M_uiSex       int    `json:"m_uiSex"`
	M_nsAliasName string `json:"m_nsAliasName"`
}

CREATE TABLE WCContact( m_nsUsrName TEXT PRIMARY KEY ASC, m_uiConType INTEGER, nickname TEXT, m_nsFullPY TEXT, m_nsShortPY TEXT, m_nsRemark TEXT, m_nsRemarkPYFull TEXT, m_nsRemarkPYShort TEXT, m_uiCertificationFlag INTEGER, m_uiSex INTEGER, m_uiType INTEGER, m_nsImgStatus TEXT, m_uiImgKey INTEGER, m_nsHeadImgUrl TEXT, m_nsHeadHDImgUrl TEXT, m_nsHeadHDMd5 TEXT, m_nsChatRoomMemList TEXT, m_nsChatRoomAdminList TEXT, m_uiChatRoomStatus INTEGER, m_nsChatRoomDesc TEXT, m_nsDraft TEXT, m_nsBrandIconUrl TEXT, m_nsGoogleContactName TEXT, m_nsAliasName TEXT, m_nsEncodeUserName TEXT, m_uiChatRoomVersion INTEGER, m_uiChatRoomMaxCount INTEGER, m_uiChatRoomType INTEGER, m_patSuffix TEXT, richChatRoomDesc TEXT, _packed_WCContactData BLOB, openIMInfo BLOB )

func (*ContactDarwinV3) Wrap

func (c *ContactDarwinV3) Wrap() *Contact

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 ContentTemplate

type ContentTemplate struct {
	Type     string   `xml:"type,attr"`
	Plain    string   `xml:"plain"`
	Template string   `xml:"template"`
	LinkList LinkList `xml:"link_list"`
}

type DataItem

type DataItem struct {
	DataType      string `xml:"datatype,attr,omitempty"`
	DataID        string `xml:"dataid,attr,omitempty"`
	HTMLID        string `xml:"htmlid,attr,omitempty"`
	DataFmt       string `xml:"datafmt,omitempty"`
	SourceName    string `xml:"sourcename,omitempty"`
	SourceTime    string `xml:"sourcetime,omitempty"`
	SourceHeadURL string `xml:"sourceheadurl,omitempty"`
	DataDesc      string `xml:"datadesc,omitempty"`

	// 图片特有字段
	ThumbSourcePath  string `xml:"thumbsourcepath,omitempty"`
	ThumbSize        string `xml:"thumbsize,omitempty"`
	CDNDataURL       string `xml:"cdndataurl,omitempty"`
	CDNDataKey       string `xml:"cdndatakey,omitempty"`
	CDNThumbURL      string `xml:"cdnthumburl,omitempty"`
	CDNThumbKey      string `xml:"cdnthumbkey,omitempty"`
	DataSourcePath   string `xml:"datasourcepath,omitempty"`
	FullMD5          string `xml:"fullmd5,omitempty"`
	ThumbFullMD5     string `xml:"thumbfullmd5,omitempty"`
	ThumbHead256MD5  string `xml:"thumbhead256md5,omitempty"`
	DataSize         string `xml:"datasize,omitempty"`
	CDNEncryVer      string `xml:"cdnencryver,omitempty"`
	SrcChatname      string `xml:"srcChatname,omitempty"`
	SrcMsgLocalID    string `xml:"srcMsgLocalid,omitempty"`
	SrcMsgCreateTime string `xml:"srcMsgCreateTime,omitempty"`
	MessageUUID      string `xml:"messageuuid,omitempty"`
	FromNewMsgID     string `xml:"fromnewmsgid,omitempty"`

	// 链接
	Link string `xml:"link,omitempty"`

	// 音乐
	StreamWebURL string `xml:"streamweburl,omitempty"`

	// 位置
	Location DataItemLocation `xml:"location,omitempty"`

	// 套娃合并转发
	DataTitle string     `xml:"datatitle,omitempty"`
	RecordXML *RecordXML `xml:"recordxml,omitempty"`
}

DataItem 表示数据项

type DataItemLocation

type DataItemLocation struct {
	Lat     string `xml:"lat,attr"`
	Lng     string `xml:"lng,attr"`
	Scale   string `xml:"scale,attr"`
	Label   string `xml:"label,attr"`
	PoiName string `xml:"poiname,attr"`
}

type DataList

type DataList struct {
	Count     string     `xml:"count,attr,omitempty"`
	DataItems []DataItem `xml:"dataitem,omitempty"`
}

DataList 表示数据列表

type DelChatRoomMember

type DelChatRoomMember struct {
	Plain string `xml:"plain"`
	Text  string `xml:"text"`
	Link  QRLink `xml:"link"`
}

第一种消息类型:删除群成员/二维码邀请

type Emoji

type Emoji struct {
	FromUsername string `xml:"fromusername,attr"`
	ToUsername   string `xml:"tousername,attr"`
	Type         string `xml:"type,attr"`
	IdBuffer     string `xml:"idbuffer,attr"`
	Md5          string `xml:"md5,attr"`
	Len          string `xml:"len,attr"`
	CdnURL       string `xml:"cdnurl,attr"`
	AesKey       string `xml:"aeskey,attr"`
	Width        string `xml:"width,attr"`
	Height       string `xml:"height,attr"`
}

type FinderFeed

type FinderFeed struct {
	ObjectID            string          `xml:"objectId"`
	FeedType            string          `xml:"feedType"`
	Nickname            string          `xml:"nickname"`
	Avatar              string          `xml:"avatar"`
	Desc                string          `xml:"desc"`
	MediaCount          string          `xml:"mediaCount"`
	ObjectNonceID       string          `xml:"objectNonceId"`
	LiveID              string          `xml:"liveId"`
	Username            string          `xml:"username"`
	AuthIconURL         string          `xml:"authIconUrl"`
	AuthIconType        int             `xml:"authIconType"`
	ContactJumpInfoStr  string          `xml:"contactJumpInfoStr"`
	SourceCommentScene  int             `xml:"sourceCommentScene"`
	MediaList           FinderMediaList `xml:"mediaList"`
	MegaVideo           FinderMegaVideo `xml:"megaVideo"`
	BizUsername         string          `xml:"bizUsername"`
	BizNickname         string          `xml:"bizNickname"`
	BizAvatar           string          `xml:"bizAvatar"`
	BizUsernameV2       string          `xml:"bizUsernameV2"`
	BizAuthIconURL      string          `xml:"bizAuthIconUrl"`
	BizAuthIconType     int             `xml:"bizAuthIconType"`
	EcSource            string          `xml:"ecSource"`
	LastGMsgID          string          `xml:"lastGMsgID"`
	ShareBypData        string          `xml:"shareBypData"`
	IsDebug             int             `xml:"isDebug"`
	ContentType         int             `xml:"content_type"`
	FinderForwardSource string          `xml:"finderForwardSource"`
}

FinderFeed 视频号信息

type FinderLive

type FinderLive struct {
	FinderLiveID               string          `xml:"finderLiveID"`
	FinderUsername             string          `xml:"finderUsername"`
	FinderObjectID             string          `xml:"finderObjectID"`
	FinderNonceID              string          `xml:"finderNonceID"`
	Nickname                   string          `xml:"nickname"`
	HeadURL                    string          `xml:"headUrl"`
	Desc                       string          `xml:"desc"`
	LiveStatus                 int             `xml:"liveStatus"`
	LiveSourceTypeStr          string          `xml:"liveSourceTypeStr"`
	ExtFlag                    int             `xml:"extFlag"`
	LiveSecondaryDeviceFlagStr string          `xml:"liveSecondaryDeviceFlagStr"`
	LiveFlag                   int             `xml:"liveFlag"`
	AuthIconURL                string          `xml:"authIconUrl"`
	AuthIconTypeStr            string          `xml:"authIconTypeStr"`
	BindType                   int             `xml:"bindType"`
	BizUsername                string          `xml:"bizUsername"`
	BizNickname                string          `xml:"bizNickname"`
	ChargeFlag                 int             `xml:"chargeFlag"`
	ReplayStatus               int             `xml:"replayStatus"`
	SpamLiveExtFlagString      string          `xml:"spamLiveExtFlagString"`
	EnterSessionID             string          `xml:"enterSessionId"`
	LiveMode                   int             `xml:"liveMode"`
	LiveSubMode                int             `xml:"liveSubMode"`
	Media                      FinderLiveMedia `xml:"media"`
	ShareScene                 int             `xml:"shareScene"`
}

type FinderLiveMedia

type FinderLiveMedia struct {
	CoverURL FinderLiveMediaCoverURL `xml:"coverUrl"`
	Height   int                     `xml:"height"`
	Width    int                     `xml:"width"`
}

type FinderLiveMediaCoverURL

type FinderLiveMediaCoverURL struct {
	Text string `xml:",cdata"`
}

type FinderMedia

type FinderMedia struct {
	ThumbURL          string `xml:"thumbUrl"`
	FullCoverURL      string `xml:"fullCoverUrl"`
	VideoPlayDuration string `xml:"videoPlayDuration"`
	URL               string `xml:"url"`
	CoverURL          string `xml:"coverUrl"`
	Height            string `xml:"height"`
	MediaType         string `xml:"mediaType"`
	FullClipInset     string `xml:"fullClipInset"`
	Width             string `xml:"width"`
}

type FinderMediaList

type FinderMediaList struct {
	Media []FinderMedia `xml:"media"`
}

type FinderMegaVideo

type FinderMegaVideo struct {
	ObjectID      string `xml:"objectId"`
	ObjectNonceID string `xml:"objectNonceId"`
}

type Image

type Image struct {
	MD5 string `xml:"md5,attr"`
}
type Link struct {
	Name       string     `xml:"name,attr"`
	Type       string     `xml:"type,attr"`
	MemberList MemberList `xml:"memberlist"`
	Separator  string     `xml:"separator,omitempty"`
	Title      string     `xml:"title,omitempty"`
}
type LinkList struct {
	Links []Link `xml:"link"`
}

type Location

type Location struct {
	X        string `xml:"x,attr"`
	Y        string `xml:"y,attr"`
	Scale    string `xml:"scale,attr"`
	Label    string `xml:"label,attr"`
	MapType  string `xml:"maptype,attr"`
	Adcode   string `xml:"adcode,attr"`
	CityName string `xml:"cityname,attr"`
}

type Media

type Media struct {
	Type       string `json:"type"` // 媒体类型:image, video, voice, file
	Key        string `json:"key"`  // MD5
	Path       string `json:"path"`
	Name       string `json:"name"`
	Size       int64  `json:"size"`
	Data       []byte `json:"data"` // for voice
	ModifyTime int64  `json:"modifyTime"`
}

type MediaDarwinV3

type MediaDarwinV3 struct {
	MediaMd5     string `json:"mediaMd5"`
	MediaSize    int64  `json:"mediaSize"`
	InodeNumber  int64  `json:"inodeNumber"`
	ModifyTime   int64  `json:"modifyTime"`
	RelativePath string `json:"relativePath"`
	FileName     string `json:"fileName"`
}

CREATE TABLE HlinkMediaRecord( mediaMd5 TEXT, mediaSize INTEGER, inodeNumber INTEGER, modifyTime INTEGER , CONSTRAINT _Md5_Size UNIQUE (mediaMd5,mediaSize) ) CREATE TABLE HlinkMediaDetail( localId INTEGER PRIMARY KEY AUTOINCREMENT, inodeNumber INTEGER, relativePath TEXT, fileName TEXT )

func (*MediaDarwinV3) Wrap

func (m *MediaDarwinV3) Wrap() *Media

type MediaMsg

type MediaMsg struct {
	XMLName  xml.Name `xml:"msg"`
	Image    Image    `xml:"img,omitempty"`
	Video    Video    `xml:"videomsg,omitempty"`
	App      App      `xml:"appmsg,omitempty"`
	Emoji    Emoji    `xml:"emoji,omitempty"`
	Location Location `xml:"location,omitempty"`
}

type MediaV3

type MediaV3 struct {
	Type       string `json:"type"`
	Key        string `json:"key"`
	Dir1       string `json:"dir1"`
	Dir2       string `json:"dir2"`
	Name       string `json:"name"`
	ModifyTime int64  `json:"modifyTime"`
}

func (*MediaV3) Wrap

func (m *MediaV3) Wrap() *Media

type MediaV4

type MediaV4 struct {
	Type       string `json:"type"`
	Key        string `json:"key"`
	Dir1       string `json:"dir1"`
	Dir2       string `json:"dir2"`
	Name       string `json:"name"`
	Size       int64  `json:"size"`
	ModifyTime int64  `json:"modifyTime"`
}

func (*MediaV4) Wrap

func (m *MediaV4) Wrap() *Media

type Member

type Member struct {
	Username string `xml:"username"`
	Nickname string `xml:"nickname"`
}

type MemberList

type MemberList struct {
	Members []Member `xml:"member"`
}

type Message

type Message struct {
	Version    string                 `json:"-"`                  // 消息版本,内部判断
	Seq        int64                  `json:"seq"`                // 消息序号,10位时间戳 + 3位序号
	Time       time.Time              `json:"time"`               // 消息创建时间,10位时间戳
	Talker     string                 `json:"talker"`             // 聊天对象,微信 ID or 群 ID
	TalkerName string                 `json:"talkerName"`         // 聊天对象名称
	IsChatRoom bool                   `json:"isChatRoom"`         // 是否为群聊消息
	Sender     string                 `json:"sender"`             // 发送人,微信 ID
	SenderName string                 `json:"senderName"`         // 发送人名称
	IsSelf     bool                   `json:"isSelf"`             // 是否为自己发送的消息
	Type       int64                  `json:"type"`               // 消息类型
	SubType    int64                  `json:"subType"`            // 消息子类型
	Content    string                 `json:"content"`            // 消息内容,文字聊天内容
	Contents   map[string]interface{} `json:"contents,omitempty"` // 消息内容,多媒体消息,采用更灵活的记录方式

	// Debug Info
	MediaMsg *MediaMsg `json:"mediaMsg,omitempty"` // 原始多媒体消息,XML 格式
	SysMsg   *SysMsg   `json:"sysMsg,omitempty"`   // 原始系统消息,XML 格式
}

func (*Message) CSV

func (m *Message) CSV(host string) []string

func (*Message) ParseMediaInfo

func (m *Message) ParseMediaInfo(data string) error

func (*Message) PlainText

func (m *Message) PlainText(showChatRoom bool, timeFormat string, host string) string

func (*Message) PlainTextContent

func (m *Message) PlainTextContent() string

func (*Message) SetContent

func (m *Message) SetContent(key string, value interface{})

type MessageDarwinV3

type MessageDarwinV3 struct {
	MsgCreateTime int64  `json:"msgCreateTime"`
	MsgContent    string `json:"msgContent"`
	MessageType   int64  `json:"messageType"`
	MesDes        int    `json:"mesDes"` // 0: 发送, 1: 接收
}

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 )

func (*MessageDarwinV3) Wrap

func (m *MessageDarwinV3) Wrap(talker string) *Message

type MessageV3

type MessageV3 struct {
	MsgSvrID        int64  `json:"MsgSvrID"`        // 消息 ID
	Sequence        int64  `json:"Sequence"`        // 消息序号,10位时间戳 + 3位序号
	CreateTime      int64  `json:"CreateTime"`      // 消息创建时间,10位时间戳
	StrTalker       string `json:"StrTalker"`       // 聊天对象,微信 ID or 群 ID
	IsSender        int    `json:"IsSender"`        // 是否为发送消息,0 接收消息,1 发送消息
	Type            int64  `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位序号
	ServerID       int64  `json:"server_id"`        // 消息 ID,用于关联 voice
	LocalType      int64  `json:"local_type"`       // 消息类型
	UserName       string `json:"user_name"`        // 发送人,通过 Join 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(FIXME 不准, 需要判断 UserName)
}

CREATE TABLE Msg_md5(talker)( 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(talker string) *Message

type PatInfo

type PatInfo struct {
	FromUsername     string `xml:"fromusername"`
	ChatUsername     string `xml:"chatusername"`
	PattedUsername   string `xml:"pattedusername"`
	PatSuffix        string `xml:"patsuffix"`
	PatSuffixVersion int    `xml:"patsuffixversion"`
	Template         string `xml:"template"`
}

PatInfo 拍一拍 v2

type PatMsg

type PatMsg struct {
	ChatUser  string  `xml:"chatUser"`  // 被拍的用户
	RecordNum int     `xml:"recordNum"` // 记录数量
	Records   Records `xml:"records"`   // 拍一拍记录
}

PatMsg 拍一拍消息结构

type PatRecord

type PatRecord struct {
	FromUser   string `xml:"fromUser"`   // 发起拍一拍的用户
	PattedUser string `xml:"pattedUser"` // 被拍的用户
	Templete   string `xml:"templete"`   // 模板文本
	CreateTime int64  `xml:"createTime"` // 创建时间
	SvrId      string `xml:"svrId"`      // 服务器ID
	ReadStatus int    `xml:"readStatus"` // 已读状态
}

PatRecord 单条拍一拍记录

type QRLink struct {
	Scene      string       `xml:"scene"`
	Text       string       `xml:"text"`
	MemberList QRMemberList `xml:"memberlist"`
	QRCode     string       `xml:"qrcode"`
}

type QRMemberList

type QRMemberList struct {
	Usernames []UsernameItem `xml:"username"`
}

type RecordInfo

type RecordInfo struct {
	XMLName       xml.Name `xml:"recordinfo"`
	FromScene     string   `xml:"fromscene,omitempty"`
	FavUsername   string   `xml:"favusername,omitempty"`
	FavCreateTime string   `xml:"favcreatetime,omitempty"`
	IsChatRoom    string   `xml:"isChatRoom,omitempty"`
	Title         string   `xml:"title,omitempty"`
	Desc          string   `xml:"desc,omitempty"`
	Info          string   `xml:"info,omitempty"`
	DataList      DataList `xml:"datalist,omitempty"`
}

RecordInfo 表示聊天记录信息

func (*RecordInfo) String

func (r *RecordInfo) String(_type, title, host string) string

type RecordItem

type RecordItem struct {
	CDATA string `xml:",cdata"`

	// 解析后的记录信息
	RecordInfo *RecordInfo
}

type RecordXML

type RecordXML struct {
	RecordInfo RecordInfo `xml:"recordinfo,omitempty"`
}

type Records

type Records struct {
	Record []PatRecord `xml:"record"` // 拍一拍记录列表
}

Records 拍一拍记录集合

type ReferMsg

type ReferMsg struct {
	Type        int64  `xml:"type"`
	SvrID       string `xml:"svrid"`
	FromUsr     string `xml:"fromusr"`
	ChatUsr     string `xml:"chatusr"`
	DisplayName string `xml:"displayname"`
	MsgSource   string `xml:"msgsource"`
	Content     string `xml:"content"`
	StrID       string `xml:"strid"`
	CreateTime  int64  `xml:"createtime"`
}

ReferMsg 表示引用消息

type RevokeMsg

type RevokeMsg struct {
	Content    string `xml:"content"`
	RevokeTime int    `xml:"revoketime"`
}

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 SessionDarwinV3

type SessionDarwinV3 struct {
	M_nsUserName string `json:"m_nsUserName"`
	M_uLastTime  int    `json:"m_uLastTime"`
}

CREATE TABLE SessionAbstract( m_nsUserName TEXT PRIMARY KEY, m_uUnReadCount INTEGER, m_bShowUnReadAsRedDot INTEGER, m_bMarkUnread INTEGER, m_uLastTime INTEGER, strRes1 TEXT, strRes2 TEXT, strRes3 TEXT, intRes1 INTEGER, intRes2 INTEGER, intRes3 INTEGER, _packed_MMSessionInfo BLOB )

func (*SessionDarwinV3) Wrap

func (s *SessionDarwinV3) Wrap() *Session

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 )

func (*SessionV4) Wrap

func (s *SessionV4) Wrap() *Session

type SysMsg

type SysMsg struct {
	Type              string             `xml:"type,attr"`
	DelChatRoomMember *DelChatRoomMember `xml:"delchatroommember,omitempty"`
	SysMsgTemplate    *SysMsgTemplate    `xml:"sysmsgtemplate,omitempty"`
	RevokeMsg         *RevokeMsg         `xml:"revokemsg,omitempty"`
}

func (*SysMsg) DelChatRoomMemberString

func (s *SysMsg) DelChatRoomMemberString() string

func (*SysMsg) String

func (s *SysMsg) String() string

func (*SysMsg) SysMsgTemplateString

func (s *SysMsg) SysMsgTemplateString() string

type SysMsgTemplate

type SysMsgTemplate struct {
	ContentTemplate ContentTemplate `xml:"content_template"`
}

第二种消息类型:系统消息模板

type UsernameItem

type UsernameItem struct {
	Value string `xml:",chardata"`
}

type Video

type Video struct {
	Md5    string `xml:"md5,attr"`
	RawMd5 string `xml:"rawmd5,attr"`
}

type WCPayInfo

type WCPayInfo struct {
	PaySubType        int    `xml:"paysubtype"`        // 支付子类型
	FeeDesc           string `xml:"feedesc"`           // 金额描述,如"¥200000.00"
	TranscationID     string `xml:"transcationid"`     // 交易ID
	TransferID        string `xml:"transferid"`        // 转账ID
	InvalidTime       string `xml:"invalidtime"`       // 失效时间
	BeginTransferTime string `xml:"begintransfertime"` // 开始转账时间
	EffectiveDate     string `xml:"effectivedate"`     // 生效日期
	PayMemo           string `xml:"pay_memo"`          // 支付备注
	ReceiverUsername  string `xml:"receiver_username"` // 接收方用户名
	PayerUsername     string `xml:"payer_username"`    // 支付方用户名
}

WCPayInfo 微信支付信息

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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