modulepackage
0.0.0-20240326075735-a833e92773b9
Repository: https://github.com/0xzer/messagix.git
Documentation: pkg.go.dev
# README
Messagix
Messagix is a easy-to-use Go library for interacting with facebooks/metas lightspeed API.
- Login
- Phone
- Fetch contact information
- Typing Notifications
- Fetch Messages (with message history support!)
- Send Messages
- Videos
- External Media
- Images
- Replies
- Forwarding
- Stickers/Decals
- Send Reactions
- Remove
- Update
- New
- Appstate
- Online
- Offline
Installation
Use the package manager to install messagix.
go get github.com/0xzer/messagix
Simplistic Usage
package client_test
import (
"log"
"os"
"testing"
"github.com/0xzer/messagix"
"github.com/0xzer/messagix/debug"
"github.com/0xzer/messagix/types"
)
var cli *messagix.Client
func TestClient(t *testing.T) {
cookies := types.NewCookiesFromString("")
cli = messagix.NewClient(cookies, debug.NewLogger(), "")
cli.SetEventHandler(evHandler)
err := cli.Connect()
if err != nil {
log.Fatal(err)
}
err = cli.SaveSession("session.json")
if err != nil {
log.Fatal(err)
}
// making sure the main program does not exit so that the socket can continue reading
wait := make(chan struct{})
<-wait
}
func evHandler(evt interface{}) {
switch evtData := evt.(type) {
case *messagix.Event_Ready:
cli.Logger.Info().
Any("connectionCode", evtData.ConnectionCode.ToString()).
Any("isNewSession", evtData.IsNewSession).
Any("total_messages", len(evtData.Messages)).
Any("total_threads", len(evtData.Threads)).
Any("total_contacts", len(evtData.Contacts)).
Msg("Client is ready!")
contacts, err := cli.Account.GetContacts(100)
if err != nil {
log.Fatalf("failed to get contacts: %e", err)
}
cli.Logger.Info().Any("data", contacts).Msg("Contacts Response")
case *messagix.Event_PublishResponse:
cli.Logger.Info().Any("evtData", evtData).Msg("Got new event!")
case *messagix.Event_Error:
cli.Logger.Err(evtData.Err).Msg("The library encountered an error")
os.Exit(1)
case *messagix.Event_SocketClosed:
cli.Logger.Info().Any("code", evtData.Code).Any("text", evtData.Text).Msg("Socket was closed.")
os.Exit(1)
default:
cli.Logger.Info().Any("data", evtData).Interface("type", evt).Msg("Got unknown event!")
}
}
Login
package main
import (
"log"
"github.com/0xzer/messagix"
"github.com/0xzer/messagix/debug"
)
func main() {
cli := messagix.NewClient(nil, debug.NewLogger(), "")
session, err := cli.Account.Login("[email protected]", "mypassword123")
if err != nil {
log.Fatal(err)
}
cli.SaveSession("session.json")
}
# Packages
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Functions
pass an empty zerolog.Logger{} for no logging.
# Constants
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Variables
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Structs
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Event_Error is emitted whenever the library encounters/receives an error.
No description provided by the author
Event_PublishACK is never emitted, it only handles the acknowledgement after a PUBLISH packet has been sent.
Event_PublishResponse is emitted if the packetId/requestId from the websocket is 0 or nil
It will also be used for handling the responses after calling a function like GetContacts through the requestId.
Event_Ready represents the CONNACK packet's response.
Event_SocketClosed is emitted whenever the websockets CloseHandler() is called.
Event_SubscribeACK is never emitted, it only handles the acknowledgement after a SUBSCRIBE packet has been sent.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
specific methods for insta api, not socket related.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Interfaces
No description provided by the author
No description provided by the author
No description provided by the author
# Type aliases
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author