WHATSAPP BOOK (LIBRARY)

Library writted in Golang that allow to devs convert the whatsapp chat (.txt) to JSON with file link with QR code.

Status:

Finished

External link:

No avaliable

Repository:

Preview

mika-baumeister-QBCS3iSKAyE-unsplash.jpg

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

Technologies used for this project

Powered by yellyoshua

Get in touch with me

Twitter
Linkedin
Github
telegram
Telegram

"Primero en tu mente, luego en tu realidad" - Julio Verne

Todo empieza en la mente de alguien.

Buy Me A Coffee

ยฉ Copyright 2023 Yoshua Lรณpez. All Rights Reserved.