Documentation
¶
Overview ¶
Package wxparse extracts structured info from wechat XML payloads stored in transfer / red-packet / favorite tables. Standalone parsers — no dep on the message_content enrich pipeline.
Index ¶
- func FavoriteInfo(content string) (title, desc, url string, err error)
- func RedPacketInfo(content string) (wishing, sceneText string, err error)
- func StripMsgPrefix(raw string) string
- func TransferInfo(content string) (amount, des, memo string, err error)
- type ForwardItem
- type ForwardLink
- type ForwardReferMsg
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FavoriteInfo ¶
FavoriteInfo extracts (title, description, url) from a favorite XML. Picks whichever inner item shape is populated. Non-nil err = parser drift.
func RedPacketInfo ¶
RedPacketInfo extracts (wishing, sceneText) from a red-packet XML. Non-nil err = parser drift; empty fields with nil err = legitimately absent.
func StripMsgPrefix ¶
StripMsgPrefix trims the "wxid_xxx:\n" sender prefix WeChat prepends to group message content so xml.Unmarshal sees a clean XML document.
func TransferInfo ¶
TransferInfo extracts (amount, description, memo) from a transfer message XML. Returns a non-nil error on parse failure so callers can distinguish "no transfer payload in this message" (all fields empty, err nil) from "parser drifted on this WeChat schema" (err set).
Types ¶
type ForwardItem ¶
type ForwardItem struct {
DataType int `json:"datatype"`
DataID string `json:"dataid,omitempty"`
SourceName string `json:"sourcename,omitempty"`
SourceHeadURL string `json:"sourceheadurl,omitempty"`
SourceTime string `json:"sourcetime,omitempty"`
DataTitle string `json:"datatitle,omitempty"`
DataDesc string `json:"datadesc,omitempty"`
DataFmt string `json:"datafmt,omitempty"`
FullMD5 string `json:"fullmd5,omitempty"`
DataSize int64 `json:"datasize,omitempty"`
CDNThumbURL string `json:"cdnthumburl,omitempty"`
CDNThumbKey string `json:"cdnthumbkey,omitempty"`
ThumbFullMD5 string `json:"thumbfullmd5,omitempty"`
ThumbSize int64 `json:"thumbsize,omitempty"`
CDNDataURL string `json:"cdndataurl,omitempty"`
CDNDataKey string `json:"cdndatakey,omitempty"`
SrcMsgLocalID int64 `json:"src_msg_localid,omitempty"`
SrcMsgCreateTime int64 `json:"src_msg_create_time,omitempty"`
MessageUUID string `json:"messageuuid,omitempty"`
FromNewMsgID string `json:"fromnewmsgid,omitempty"`
Link *ForwardLink `json:"link,omitempty"`
ReferMsg *ForwardReferMsg `json:"refermsg,omitempty"`
NestedItems []ForwardItem `json:"nested_items,omitempty"`
// ParseError surfaces nested-forward (datatype=17) parse failure on this
// item without losing the rest of the outer forward. Outer-XML parser
// drift propagates as ForwardItems' returned error instead.
ParseError string `json:"parse_error,omitempty"`
}
ForwardItem is a JSON-serializable view of one forwarded sub-message. Only populated fields are emitted (omitempty) so text items don't carry file-specific keys. NestedItems is set for datatype=17 (合并转发 nested).
func ForwardItems ¶
func ForwardItems(content string, depth int) ([]ForwardItem, error)
ForwardItems extracts structured sub-messages from a forward_chat (subtype=19) XML. depth bounds nested-forward recursion (pass ≥1 to include nested; 0 keeps datatype=17 items but without NestedItems). Non-nil err = parser drift. Empty slice with nil err = legitimately not a forward / empty datalist. Binary/media payloads (cdndataurl / aeskey) are intentionally dropped — encrypted CDN pointers unusable without the WeChat client.