40 lines
854 B
Go
40 lines
854 B
Go
package whatsapp
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
)
|
|
|
|
type ConnectionState string
|
|
|
|
const (
|
|
StateDisconnected ConnectionState = "disconnected"
|
|
StateConnecting ConnectionState = "connecting"
|
|
StateWaitingQR ConnectionState = "waiting_qr"
|
|
StateConnected ConnectionState = "connected"
|
|
StateFailed ConnectionState = "failed"
|
|
)
|
|
|
|
type QRFrame struct {
|
|
QR string
|
|
State ConnectionState
|
|
Error string
|
|
}
|
|
|
|
type Contact struct {
|
|
Phone string
|
|
Name string
|
|
FromMe bool
|
|
Time time.Time
|
|
}
|
|
|
|
type ContactHandler interface {
|
|
OnContact(ctx context.Context, clientID int64, contact Contact) error
|
|
}
|
|
|
|
type Connector interface {
|
|
Connect(ctx context.Context, clientID int64) (<-chan QRFrame, error)
|
|
Disconnect(ctx context.Context, clientID int64) error
|
|
IsConnected(ctx context.Context, clientID int64) (bool, error)
|
|
SetClientDB(db interface{})
|
|
} |