Documentation
¶
Overview ¶
Package engine is the WhatsApp engine without the protocol library: the client boundary, plain-data events, the supervisor, the durable ingest pipeline and the history worker.
Index ¶
- Constants
- Variables
- func RejectionCode(err error) int
- func RetryAfter(err error) time.Duration
- type BackfillRequest
- type CATRefreshFailed
- type Canonicaliser
- type Client
- type ClientOutdated
- type Clock
- type ConnectFailure
- type Connected
- type Contact
- type ContactName
- type Conversation
- type Disconnected
- type Engine
- func (e *Engine) Backfill(ctx context.Context, req BackfillRequest) (string, error)
- func (e *Engine) FetchMedia(ctx context.Context, req MediaRequest) (Staged, error)
- func (e *Engine) NewMessageID() string
- func (e *Engine) Pair(ctx context.Context) (string, error)
- func (e *Engine) Ready() bool
- func (e *Engine) Reconnect() error
- func (e *Engine) Send(ctx context.Context, req SendRequest) (Sent, error)
- func (e *Engine) Start(ctx context.Context, recentStarts int)
- func (e *Engine) Status() Status
- func (e *Engine) Stop(ctx context.Context) error
- type Event
- type Group
- type History
- type HistoryDecoder
- type HistoryNotification
- type HistoryRef
- type Identity
- type Key
- type Kind
- type LIDMapping
- type LoggedOut
- type MediaKind
- type MediaRequest
- type Message
- type Notifier
- type Options
- type PairRejected
- type Paired
- type Participant
- type Reason
- type RejectedError
- type Reply
- type SendQuote
- type SendRequest
- type Sent
- type Staged
- type State
- type Status
- type StreamReplaced
- type TemporaryBan
- type ThrottledError
- type Version
- type VersionSource
Constants ¶
View Source
const ( DefaultHistoryMaxBytes = 32 << 20 MaxHistoryMaxBytes = 256 << 20 DefaultMediaRefRetention = 30 * 24 * time.Hour )
View Source
const ( VariantGIF = "gif" VariantVideoNote = "video_note" VariantVoiceNote = "voice_note" VariantAnimated = "animated" VariantLottie = "lottie" )
View Source
const (
MaxRecentStarts = 5
)
View Source
const SyncOnDemand = "ON_DEMAND"
Variables ¶
View Source
var ( ErrMediaExpired = errors.New("engine: the attachment has expired") ErrMediaTooLarge = errors.New("engine: the attachment is larger than allowed") ErrMediaFailed = errors.New("engine: fetching the attachment failed") ErrMediaThrottled = errors.New("engine: attachment fetches are throttled") )
View Source
var ( ErrNotConnected = errors.New("engine: not connected, nothing was sent") ErrRejected = errors.New("engine: WhatsApp rejected the message") ErrOutcomeUnknown = errors.New("engine: whether WhatsApp received the message is unknown") ErrSendBusy = errors.New("engine: another send is in progress") )
View Source
var ( ErrAlreadyPaired = errors.New("engine: a device is already paired") ErrOwnerPhoneMissing = errors.New("engine: the owner's phone number is not configured") ErrPairRateLimited = errors.New("engine: three pairing attempts were made in the last hour") ErrPairFailed = errors.New("engine: pairing failed") ErrNotPaired = errors.New("engine: no device is paired") ErrOwnerMismatch = errors.New("engine: the stored device belongs to another number than the owner's") ErrAlreadyConnected = errors.New("engine: already connected") ErrStopped = errors.New("engine: stopped") )
Functions ¶
func RejectionCode ¶ added in v1.0.0
func RetryAfter ¶ added in v1.2.0
Types ¶
type BackfillRequest ¶ added in v1.0.0
type CATRefreshFailed ¶
type CATRefreshFailed struct{}
type Canonicaliser ¶ added in v1.2.0
type Canonicaliser interface {
Canonical(ctx context.Context, c policy.CanonicalChat) (policy.CanonicalChat, error)
}
type Client ¶
type Client interface {
Connect(ctx context.Context) error
Disconnect()
Paired() bool
Account() string
PairPhone(ctx context.Context, digits string) (code string, err error)
Logout(ctx context.Context) error
Version() Version
SetVersion(Version)
DownloadHistory(ctx context.Context, ref HistoryRef, dst io.Writer) error
AckHistory(ctx context.Context, ref HistoryRef) error
OnEvent(handler func(Event) bool) (cancel func())
NewMessageID() string
Send(ctx context.Context, req SendRequest) (Sent, error)
Backfill(ctx context.Context, req BackfillRequest) (requestID string, err error)
FetchMedia(ctx context.Context, req MediaRequest) (Staged, error)
}
type ClientOutdated ¶
type ClientOutdated struct{}
type ConnectFailure ¶
type ConnectFailure struct{ Code int }
type ContactName ¶ added in v0.3.0
type Conversation ¶
type Conversation struct {
Chat string
Subject string
Members []Participant
Messages []Message
}
type Disconnected ¶
type Disconnected struct{}
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
func (*Engine) FetchMedia ¶ added in v1.2.0
func (*Engine) NewMessageID ¶ added in v1.0.0
type Group ¶
type Group struct {
Chat string `json:"chat"`
Subject string `json:"subject,omitempty"`
Members []Participant `json:"members,omitempty"`
Joined []Participant `json:"joined,omitempty"`
Left []string `json:"left,omitempty"`
Timestamp time.Time `json:"ts"`
}
type History ¶
type History struct {
Conversations []Conversation
LIDMappings []LIDMapping
Contacts []Contact
}
type HistoryDecoder ¶
type HistoryNotification ¶
type HistoryNotification struct {
Sender string
FromMe bool
Ref HistoryRef
}
type HistoryRef ¶
type HistoryRef struct {
ID string `json:"id"`
DirectPath string `json:"direct_path,omitempty"`
MediaKey []byte `json:"media_key,omitempty"`
FileSHA256 []byte `json:"file_sha256,omitempty"`
FileEncSHA256 []byte `json:"file_enc_sha256,omitempty"`
FileLength uint64 `json:"file_length,omitempty"`
Inline []byte `json:"inline,omitempty"`
SyncType string `json:"sync_type,omitempty"`
RequestID string `json:"request_id,omitempty"`
}
type LIDMapping ¶
type MediaRequest ¶ added in v1.2.0
type MediaRequest struct {
ID string
Ref string
Kind MediaKind
Declared int64
Deadline time.Time
Chat policy.CanonicalChat
Sender policy.CanonicalChat
Canonical Canonicaliser
}
type Message ¶
type Message struct {
Chat string `json:"chat"`
ID string `json:"id"`
Sender string `json:"sender"`
SenderAlt string `json:"sender_alt,omitempty"`
RecipientAlt string `json:"recipient_alt,omitempty"`
Addressing string `json:"addressing,omitempty"`
FromMe bool `json:"from_me,omitempty"`
Timestamp time.Time `json:"ts"`
PushName string `json:"push_name,omitempty"`
Kind Kind `json:"kind,omitempty"`
Text string `json:"text,omitempty"`
MediaType string `json:"media_type,omitempty"`
MediaRef string `json:"media_ref,omitempty"`
MediaKind MediaKind `json:"media_kind,omitempty"`
MediaVariant string `json:"media_variant,omitempty"`
MediaBytes int64 `json:"media_bytes,omitempty"`
Target *Key `json:"target,omitempty"`
Reply *Reply `json:"reply,omitempty"`
Expiration time.Duration `json:"expiration,omitempty"`
}
type Options ¶
type Options struct {
Client Client
Versions VersionSource
Decoder HistoryDecoder
Archive *ingest.Store
DataDir string
OwnerPhone string
HistoryMaxBytes int64
MediaOn bool
MediaRefRetention time.Duration
Logger *slog.Logger
Notify Notifier
Metrics *metrics.Registry
Clock Clock
Jitter func(time.Duration) time.Duration
}
type PairRejected ¶
type PairRejected struct{}
type Participant ¶
type Reason ¶
type Reason string
const ( ReasonOutdated Reason = "outdated" ReasonReplaced Reason = "replaced" ReasonLoggedOut Reason = "logged_out" ReasonTemporaryBan Reason = "temporary_ban" ReasonCATRefresh Reason = "cat_refresh" ReasonConnectFailure Reason = "connect_failure" ReasonRestartBudget Reason = "restart_budget" ReasonOwnerMismatch Reason = "owner_mismatch" ReasonShutdown Reason = "shutdown" )
type RejectedError ¶ added in v1.0.0
type RejectedError struct{ Code int }
func (*RejectedError) Error ¶ added in v1.0.0
func (e *RejectedError) Error() string
func (*RejectedError) Unwrap ¶ added in v1.0.0
func (e *RejectedError) Unwrap() error
type SendRequest ¶ added in v1.0.0
type StreamReplaced ¶
type StreamReplaced struct{}
type TemporaryBan ¶
type ThrottledError ¶ added in v1.2.0
func (*ThrottledError) Error ¶ added in v1.2.0
func (e *ThrottledError) Error() string
func (*ThrottledError) Unwrap ¶ added in v1.2.0
func (e *ThrottledError) Unwrap() error
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package wa is the only user of the WhatsApp protocol library: it implements the engine's client boundary over a whatsmeow client, translates the library's events into the engine's plain data, guards pairing and caps downloads.
|
Package wa is the only user of the WhatsApp protocol library: it implements the engine's client boundary over a whatsmeow client, translates the library's events into the engine's plain data, guards pairing and caps downloads. |
|
internal/mediasrc
Package mediasrc declares the attachment source the adapter's media download takes: only Wrap puts a message in one, and the zero value carries none.
|
Package mediasrc declares the attachment source the adapter's media download takes: only Wrap puts a message in one, and the zero value carries none. |
Click to show internal directories.
Click to hide internal directories.