Introduction
This package allow to convert your exported whatsapp chats to JSON format.
Next Features
- SUPPORT FOR CHAT GROUP
Avaliable Features
- QR image that contain the link to audio and video files
Installation ๐ป
$ go get github.com/yellyoshua/whatsapp-chat-parser
Example ๐
package main
import (
"io/ioutil""log""path""github.com/yellyoshua/whatsapp-chat-parser/chat""github.com/yellyoshua/whatsapp-chat-parser/constants"
)
func readFile(filename string) []byte {
data, err := ioutil.ReadFile(filename)
if err != nil {
log.Fatal(err)
}
return data
}
func main() {
var whatsappChat = readFile("chat.txt")
parser := chat.Create(whatsappChat, chat.Configuration{
UrlForQrFiles: "https://my-bucket.assets/file/",
})
chatInstance, rawMessages := parser.ParseMessages(
"en"
)
log.Printf("%v - %s - %s",
rawMessages[0].Date,
rawMessages[0].Author,
rawMessages[0].Message,
)
messages, err := chatInstance.NewPaperBook().ExportJSON()
if err != nil {
log.Fatal(err)
}
log.Printf("Were processed %d messages", messages.Count)
log.Print(string(messages.Value))
// {author: "", message: "", date: "", attachment: {}...}
}
API
๐ฌ Struct of whatsapp.Message
github.com/yellyoshua/whatsapp-chat-parser/whatsapp
type DateFormat struct {
Hours string `json:"hours"`Mins string `json:"mins"`Format string `json:"format"`Day int `json:"day"`Month int `json:"month"`Year int `json:"year"`UTC string `json:"utc"`
}
type Attachment struct {
Exist bool `json:"exist"`FileName string `json:"fileName,omitempty"`Extension string `json:"extension,omitempty"`
}
// Message _type Message struct {
Date DateFormat `json:"date"`Author string `json:"author"`IsSender bool `json:"isSender"`IsInfo bool `json:"isInfo"`IsReceiver bool `json:"isReceiver"`Message string `json:"message"`Attachment Attachment `json:"attachment"`
}
๐ Interface of paper.Book
github.com/yellyoshua/whatsapp-chat-parser/paper
// Book __type Book interface {
Export() []whatsapp.MessageExportJSON() (MessagesJSON, error)
}
๐ Exports from chat
package
github.com/yellyoshua/whatsapp-chat-parser/whatsapp
func Create(chatContent string, config Configuration) Parser