package packetlog import ( "encoding/xml" "errors" "fmt" "strings" ) type Message struct { ID string From string To string Type string Body string Subject string SendTime string ReceiptID string ReceiptType string Consumed bool Read bool } type xmppMessage struct { XMLName xml.Name `xml:"message"` ID string `xml:"id,attr"` From string `xml:"from,attr"` To string `xml:"to,attr"` Type string `xml:"type,attr"` Body string `xml:"body"` Subject string `xml:"subject"` Receipt xmppReceipt `xml:"received"` ISphere xmppISphere `xml:"isphere"` Consumed *struct{} `xml:"consumed"` Readed *struct{} `xml:"readed"` } type xmppReceipt struct { ID string `xml:"id,attr"` Type string `xml:"type,attr"` } type xmppISphere struct { SendTime string `xml:"sendtime,attr"` } func ParseMessageLog(plaintext string) (Message, error) { start := strings.Index(plaintext, "