app

package
v0.9.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 15, 2026 License: MIT Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultBackfillCount    = 50
	DefaultBackfillRequests = 1
	MaxBackfillCount        = 500
	MaxBackfillRequests     = 100
)

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App struct {
	// contains filtered or unexported fields
}

func New

func New(opts Options) (*App, error)

func (*App) AllowUnauthed

func (a *App) AllowUnauthed() bool

func (*App) ArchiveChat

func (a *App) ArchiveChat(ctx context.Context, jid types.JID, archive bool) error

func (*App) BackfillHistory

func (a *App) BackfillHistory(ctx context.Context, opts BackfillOptions) (BackfillResult, error)

func (*App) Close

func (a *App) Close()

func (*App) Connect

func (a *App) Connect(ctx context.Context, allowQR bool, qrWriter func(string)) error

func (*App) DB

func (a *App) DB() *store.DB

func (*App) EnsureAuthed

func (a *App) EnsureAuthed() error

func (*App) Events

func (a *App) Events() *out.EventWriter

func (*App) MarkChatRead

func (a *App) MarkChatRead(ctx context.Context, jid types.JID, read bool) error

func (*App) MuteChat

func (a *App) MuteChat(ctx context.Context, jid types.JID, mute bool, duration time.Duration) error

func (*App) OpenWA

func (a *App) OpenWA() error

func (*App) PinChat

func (a *App) PinChat(ctx context.Context, jid types.JID, pin bool) error

func (*App) ResolveMediaOutputPath

func (a *App) ResolveMediaOutputPath(info store.MediaDownloadInfo, requested string) (string, error)

func (*App) StoreDir

func (a *App) StoreDir() string

func (*App) Sync

func (a *App) Sync(ctx context.Context, opts SyncOptions) (SyncResult, error)

func (*App) Version

func (a *App) Version() string

func (*App) WA

func (a *App) WA() WAClient

type BackfillOptions

type BackfillOptions struct {
	ChatJID        string
	Count          int
	Requests       int
	WaitPerRequest time.Duration
	IdleExit       time.Duration
}

type BackfillResult

type BackfillResult struct {
	ChatJID        string
	RequestsSent   int
	ResponsesSeen  int
	MessagesAdded  int64
	MessagesSynced int64
}

type Options

type Options struct {
	StoreDir      string
	Version       string
	JSON          bool
	Events        *out.EventWriter
	AllowUnauthed bool
}

type SyncMode

type SyncMode string
const (
	SyncModeBootstrap SyncMode = "bootstrap"
	SyncModeOnce      SyncMode = "once"
	SyncModeFollow    SyncMode = "follow"
)

type SyncOptions

type SyncOptions struct {
	Mode            SyncMode
	AllowQR         bool
	OnQRCode        func(string)
	PairPhoneNumber string
	OnPairCode      func(string)
	AfterConnect    func(context.Context) error
	DownloadMedia   bool
	RefreshContacts bool
	RefreshGroups   bool
	RefreshChannels bool
	IdleExit        time.Duration // only used for bootstrap/once
	MaxReconnect    time.Duration // max time to attempt reconnection before giving up (0 = unlimited)
	MaxMessages     int64         // 0 = unlimited
	MaxDBSizeBytes  int64         // 0 = unlimited
	WarnNoLimits    bool
	WebhookURL      string
	WebhookSecret   string
	Verbosity       int // future
}

type SyncResult

type SyncResult struct {
	MessagesStored int64
}

type WAClient

type WAClient interface {
	Close()
	IsAuthed() bool
	IsConnected() bool
	Connect(ctx context.Context, opts wa.ConnectOptions) error

	AddEventHandler(handler func(interface{})) uint32
	RemoveEventHandler(id uint32)
	ReconnectWithBackoff(ctx context.Context, minDelay, maxDelay time.Duration) error

	ResolveChatName(ctx context.Context, chat types.JID, pushName string) string
	ResolveLIDToPN(ctx context.Context, jid types.JID) types.JID
	ResolvePNToLID(ctx context.Context, jid types.JID) types.JID
	GetUserInfo(ctx context.Context, jids []types.JID) (map[types.JID]types.UserInfo, error)
	IsOnWhatsApp(ctx context.Context, phones []string) ([]types.IsOnWhatsAppResponse, error)
	GetContact(ctx context.Context, jid types.JID) (types.ContactInfo, error)
	GetAllContacts(ctx context.Context) (map[types.JID]types.ContactInfo, error)

	GetJoinedGroups(ctx context.Context) ([]*types.GroupInfo, error)
	GetGroupInfo(ctx context.Context, jid types.JID) (*types.GroupInfo, error)
	SetGroupName(ctx context.Context, jid types.JID, name string) error
	UpdateGroupParticipants(ctx context.Context, group types.JID, users []types.JID, action wa.GroupParticipantAction) ([]types.GroupParticipant, error)
	GetGroupInviteLink(ctx context.Context, group types.JID, reset bool) (string, error)
	JoinGroupWithLink(ctx context.Context, code string) (types.JID, error)
	LeaveGroup(ctx context.Context, group types.JID) error

	GetNewsletterInfoWithInvite(ctx context.Context, key string) (*types.NewsletterMetadata, error)
	FollowNewsletter(ctx context.Context, jid types.JID) error
	UnfollowNewsletter(ctx context.Context, jid types.JID) error
	GetSubscribedNewsletters(ctx context.Context) ([]*types.NewsletterMetadata, error)
	GetNewsletterInfo(ctx context.Context, jid types.JID) (*types.NewsletterMetadata, error)

	SendText(ctx context.Context, to types.JID, text string) (types.MessageID, error)
	SendProtoMessage(ctx context.Context, to types.JID, msg *waProto.Message) (types.MessageID, error)
	SendProtoMessageWithExtra(ctx context.Context, to types.JID, msg *waProto.Message, mediaHandle string) (types.MessageID, error)
	SendReaction(ctx context.Context, chat, sender types.JID, targetID types.MessageID, reaction string) (types.MessageID, error)
	SendPoll(ctx context.Context, to types.JID, name string, options []string, selectable int, ephemeral bool) (types.MessageID, error)
	SendPollVote(ctx context.Context, pollInfo *types.MessageInfo, options []string) (types.MessageID, error)
	DecryptPollVote(ctx context.Context, evt *events.Message) (*waE2E.PollVoteMessage, error)
	DecryptSecretEncryptedMessage(ctx context.Context, evt *events.Message) (*waE2E.Message, error)
	RevokeMessage(ctx context.Context, chat types.JID, targetID types.MessageID) (types.MessageID, error)
	DeleteMessageForMe(ctx context.Context, info types.MessageInfo, deleteMedia bool) error
	EditMessage(ctx context.Context, chat types.JID, targetID types.MessageID, text string) (types.MessageID, error)
	ArchiveChat(ctx context.Context, target types.JID, archive bool, lastMsgTS time.Time, lastMsgKey *waCommon.MessageKey) error
	PinChat(ctx context.Context, target types.JID, pin bool) error
	MuteChat(ctx context.Context, target types.JID, mute bool, duration time.Duration) error
	MarkChatAsRead(ctx context.Context, target types.JID, read bool, lastMsgTS time.Time, lastMsgKey *waCommon.MessageKey) error
	Upload(ctx context.Context, data []byte, mediaType whatsmeow.MediaType) (whatsmeow.UploadResponse, error)
	UploadNewsletter(ctx context.Context, data []byte, mediaType whatsmeow.MediaType) (whatsmeow.UploadResponse, error)
	DownloadMediaToFile(ctx context.Context, directPath string, encFileHash, fileHash, mediaKey []byte, fileLength uint64, mediaType, mmsType string, targetPath string) (int64, error)

	SendChatPresence(ctx context.Context, jid types.JID, state types.ChatPresence, media types.ChatPresenceMedia) error
	ParseWebMessage(chatJID types.JID, webMsg *waWeb.WebMessageInfo) (*events.Message, error)
	DecryptReaction(ctx context.Context, reaction *events.Message) (*waProto.ReactionMessage, error)
	SetManualHistorySyncDownload(enabled bool)
	DownloadHistorySync(ctx context.Context, notif *waE2E.HistorySyncNotification) (*waHistorySync.HistorySync, error)
	DeleteHistorySyncMedia(ctx context.Context, notif *waE2E.HistorySyncNotification) error
	RequestHistorySyncOnDemand(ctx context.Context, lastKnown types.MessageInfo, count int) (types.MessageID, error)
	FetchAppState(ctx context.Context, name string, fullSync, onlyIfNotSynced bool) error
	RequestAppStateRecovery(ctx context.Context, name string) (types.MessageID, error)
	Logout(ctx context.Context) error
	LinkedJID() string

	SetProfilePicture(ctx context.Context, avatar []byte) (string, error)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL