Documentation
¶
Index ¶
- Constants
- Variables
- func CleanJID(jid waTypes.JID) waTypes.JID
- func DownloadMediaFromURL(ctx context.Context, url string) ([]byte, error)
- func FormatRecipient(to string) waTypes.JID
- func IsUpstreamTimeout(err error) bool
- func MigrateCustomTables(db *sql.DB, dialect string) error
- func OpenContainer(ctx context.Context, driver, dsn string, logger *slog.Logger) (*sqlstore.Container, error)
- func ResizeImageIfNeeded(imageData []byte) ([]byte, error)
- type BulkCheckResult
- type BusinessCategory
- type BusinessHours
- type BusinessProfileResponse
- type CallService
- type ChatListItem
- type ChatPictureResponse
- type ChatRecord
- type ChatService
- func (c *ChatService) ArchiveChat(ctx context.Context, chatID string, archived bool) error
- func (c *ChatService) ClearChat(ctx context.Context, chatID string) error
- func (c *ChatService) DeleteChat(ctx context.Context, chatID string) error
- func (c *ChatService) GetBusinessProfile(ctx context.Context, chatID string) (BusinessProfileResponse, error)
- func (c *ChatService) GetChatInfo(ctx context.Context, chatID string) (ChatListItem, error)
- func (c *ChatService) GetChatPicture(ctx context.Context, chatID string) (ChatPictureResponse, error)
- func (c *ChatService) ListChats(ctx context.Context) ([]ChatListItem, error)
- func (c *ChatService) MarkChatAsRead(ctx context.Context, chatID string, read bool) error
- func (c *ChatService) MuteChat(ctx context.Context, chatID string, duration string) error
- func (c *ChatService) PinChat(ctx context.Context, chatID string, pinned bool) error
- func (c *ChatService) RequestMessages(ctx context.Context, chatID, lastMessageID, lastMessageSenderID string, ...) error
- func (c *ChatService) SendChatPresence(ctx context.Context, chatID string, state string) error
- func (c *ChatService) SetEphemeralExpiration(ctx context.Context, chatID string, expiration string) error
- func (c *ChatService) SubscribeChatPresence(ctx context.Context, chatID string) error
- type ChatStore
- func (s *ChatStore) Delete(ctx context.Context, ourJID, chatJID string) error
- func (s *ChatStore) Get(ctx context.Context, ourJID, chatJID string) (ChatRecord, error)
- func (s *ChatStore) List(ctx context.Context, ourJID string) ([]ChatRecord, error)
- func (s *ChatStore) Upsert(ctx context.Context, rec ChatRecord) error
- type CommunityInfoResponse
- type CommunityService
- func (c *CommunityService) CreateCommunity(ctx context.Context, name string, participants []string, approvalMode string) (string, error)
- func (c *CommunityService) CreateCommunityGroup(ctx context.Context, communityID string, name string, participants []string) (string, error)
- func (c *CommunityService) GetCommunityInfo(ctx context.Context, communityID string) (CommunityInfoResponse, error)
- func (c *CommunityService) GetCommunityInviteLink(ctx context.Context, communityID string) (string, error)
- func (c *CommunityService) GetCommunityParticipants(ctx context.Context, communityID string) ([]identity.Identity, error)
- func (c *CommunityService) GetCommunitySubGroups(ctx context.Context, communityID string) ([]CommunitySubGroupResponse, error)
- func (c *CommunityService) GetJoinedCommunities(ctx context.Context) ([]CommunityInfoResponse, error)
- func (c *CommunityService) LeaveCommunity(ctx context.Context, communityID string) error
- func (c *CommunityService) LinkGroupToCommunity(ctx context.Context, communityID string, groupID string) error
- func (c *CommunityService) ResetCommunityInviteLink(ctx context.Context, communityID string) (string, error)
- func (c *CommunityService) SetCommunityDescription(ctx context.Context, communityID string, description string) error
- func (c *CommunityService) SetCommunityLocked(ctx context.Context, communityID string, locked bool) error
- func (c *CommunityService) SetCommunityName(ctx context.Context, communityID string, name string) error
- func (c *CommunityService) SetCommunityPicture(ctx context.Context, communityID string, photo []byte) (string, error)
- func (c *CommunityService) UnlinkGroupFromCommunity(ctx context.Context, communityID string, groupID string) error
- func (c *CommunityService) UpdateCommunityParticipants(ctx context.Context, communityID string, participants []string, action string) error
- type CommunitySubGroupResponse
- type ContactInfo
- type ContactRecord
- type ContactService
- func (c *ContactService) BlockContact(ctx context.Context, contactID string) error
- func (c *ContactService) CreateOrUpdateContact(ctx context.Context, contactID string, fullName string, firstName string) error
- func (c *ContactService) GetAllContacts(ctx context.Context) ([]ContactInfo, error)
- func (c *ContactService) GetBlocklist(ctx context.Context) ([]identity.Identity, error)
- func (c *ContactService) GetContact(ctx context.Context, contactID string) (ContactInfo, error)
- func (c *ContactService) SyncContacts(ctx context.Context) error
- func (c *ContactService) UnblockContact(ctx context.Context, contactID string) error
- type ContactStore
- func (s *ContactStore) Delete(ctx context.Context, ourJID, contactJID string) error
- func (s *ContactStore) Get(ctx context.Context, ourJID, contactJID string) (ContactRecord, error)
- func (s *ContactStore) List(ctx context.Context, ourJID string) ([]ContactRecord, error)
- func (s *ContactStore) Upsert(ctx context.Context, rec ContactRecord) error
- type GroupInfoResponse
- type GroupParticipant
- type GroupParticipantRequest
- type GroupService
- func (g *GroupService) CreateGroup(ctx context.Context, name string, participants []string) (string, error)
- func (g *GroupService) GetGroupInfo(ctx context.Context, groupID string) (GroupInfoResponse, error)
- func (g *GroupService) GetGroupInfoFromInvite(ctx context.Context, groupID, inviterID, code string, expiration int64) (GroupInfoResponse, error)
- func (g *GroupService) GetGroupInfoFromLink(ctx context.Context, code string) (GroupInfoResponse, error)
- func (g *GroupService) GetGroupInviteLink(ctx context.Context, groupID string, reset bool) (string, error)
- func (g *GroupService) GetGroupParticipants(ctx context.Context, groupID string) ([]GroupParticipant, error)
- func (g *GroupService) GetGroupRequestParticipants(ctx context.Context, groupID string) ([]GroupParticipantRequest, error)
- func (g *GroupService) GetJoinedGroups(ctx context.Context) ([]GroupInfoResponse, error)
- func (g *GroupService) JoinGroupWithInvite(ctx context.Context, groupID, inviterID, code string, expiration int64) error
- func (g *GroupService) JoinGroupWithLink(ctx context.Context, code string) (string, error)
- func (g *GroupService) LeaveGroup(ctx context.Context, groupID string) error
- func (g *GroupService) SetGroupAnnounceMode(ctx context.Context, groupID string, announceMode bool) error
- func (g *GroupService) SetGroupDescription(ctx context.Context, groupID string, description string) error
- func (g *GroupService) SetGroupJoinApprovalMode(ctx context.Context, groupID string, joinApprovalMode bool) error
- func (g *GroupService) SetGroupLocked(ctx context.Context, groupID string, locked bool) error
- func (g *GroupService) SetGroupMemberAddMode(ctx context.Context, groupID string, onlyAdminAdd bool) error
- func (g *GroupService) SetGroupName(ctx context.Context, groupID string, name string) error
- func (g *GroupService) SetGroupPicture(ctx context.Context, groupID string, photo []byte) (string, error)
- func (g *GroupService) UpdateGroupParticipants(ctx context.Context, groupID string, participants []string, action string) error
- func (g *GroupService) UpdateGroupRequestParticipants(ctx context.Context, groupID string, participants []string, action string) error
- type HistorySyncService
- type HistorySyncStore
- func (s *HistorySyncStore) DeleteAll(ctx context.Context, ourJID string) error
- func (s *HistorySyncStore) GetMessages(ctx context.Context, ourJID, chatJID string) ([]string, error)
- func (s *HistorySyncStore) Insert(ctx context.Context, ourJID, chatJID, messagesJSON string, expireAt time.Time) error
- func (s *HistorySyncStore) ListChats(ctx context.Context, ourJID string) ([]string, error)
- type InstanceRecord
- type InstanceStore
- func (s *InstanceStore) DeleteInstance(ctx context.Context, id string) error
- func (s *InstanceStore) GetInstance(ctx context.Context, id string) (InstanceRecord, error)
- func (s *InstanceStore) ListInstances(ctx context.Context) ([]InstanceRecord, error)
- func (s *InstanceStore) SaveInstance(ctx context.Context, inst InstanceRecord) error
- func (s *InstanceStore) UpdateDeviceState(ctx context.Context, id, deviceID string, loggedIn bool) error
- type MediaDownloadResult
- type MediaSendOptions
- type MediaService
- type MessageService
- func (m *MessageService) DeleteMessage(ctx context.Context, chatID, senderID, messageID string) error
- func (m *MessageService) DeleteMessageForMe(ctx context.Context, chatID, senderID string, isFromMe bool, messageID string, ...) error
- func (m *MessageService) EditMessage(ctx context.Context, to, messageID, text string, opts SendOptions) (string, error)
- func (m *MessageService) MarkAsRead(ctx context.Context, chatID, senderID, messageID, receiptType string) error
- func (m *MessageService) PinMessage(ctx context.Context, chatID, senderID, messageID string, pinned bool, ...) error
- func (m *MessageService) SendAudio(ctx context.Context, to string, data []byte, mimeType string, ...) (string, error)
- func (m *MessageService) SendContact(ctx context.Context, to, displayName, vcard string, opts SendOptions) (string, error)
- func (m *MessageService) SendDocument(ctx context.Context, to string, data []byte, filename string, ...) (string, error)
- func (m *MessageService) SendImage(ctx context.Context, to string, data []byte, mimeType string, ...) (string, error)
- func (m *MessageService) SendLink(ctx context.Context, to, text, url, title, description string, ...) (string, error)
- func (m *MessageService) SendLocation(ctx context.Context, to string, lat, lng float64, ...) (string, error)
- func (m *MessageService) SendReaction(ctx context.Context, to, senderID, messageID, reaction string) (string, error)
- func (m *MessageService) SendSticker(ctx context.Context, to string, data []byte, isAnimated bool, opts SendOptions) (string, error)
- func (m *MessageService) SendText(ctx context.Context, to, text string, opts SendOptions) (string, error)
- func (m *MessageService) SendVideo(ctx context.Context, to string, data []byte, mimeType string, ...) (string, error)
- func (m *MessageService) SendVoice(ctx context.Context, to string, data []byte, opts MediaSendOptions) (string, error)
- func (m *MessageService) StarMessage(ctx context.Context, chatID, senderID, messageID string, starred bool) error
- type NewsletterInfoResponse
- type NewsletterService
- func (n *NewsletterService) CreateNewsletter(ctx context.Context, name, description string, picture []byte) (NewsletterInfoResponse, error)
- func (n *NewsletterService) FollowNewsletter(ctx context.Context, newsletterID string) error
- func (n *NewsletterService) GetNewsletterInfo(ctx context.Context, newsletterID string) (NewsletterInfoResponse, error)
- func (n *NewsletterService) GetNewsletterInfoWithInvite(ctx context.Context, inviteCode string) (NewsletterInfoResponse, error)
- func (n *NewsletterService) GetSubscribedNewsletters(ctx context.Context) ([]NewsletterInfoResponse, error)
- func (n *NewsletterService) ToggleMuteNewsletter(ctx context.Context, newsletterID string, mute bool) error
- func (n *NewsletterService) UnfollowNewsletter(ctx context.Context, newsletterID string) error
- type PrivacySettingsResponse
- type SendOptions
- type Service
- func (s *Service) AddEventHandler(handler whatsmeow.EventHandler)
- func (s *Service) Client() *whatsmeow.Client
- func (s *Service) Connect() error
- func (s *Service) DeleteDevice()
- func (s *Service) Disconnect()
- func (s *Service) GetDeviceJID() string
- func (s *Service) IsConnected() bool
- func (s *Service) IsLoggedIn() bool
- func (s *Service) RemoveEventHandlers()
- func (s *Service) SetMaxParallelRetryReceipts(n int)
- func (s *Service) SetPairClient(clientType, clientOS string)
- type SessionService
- func (s *SessionService) Connect() error
- func (s *SessionService) Disconnect()
- func (s *SessionService) GeneratePairCode(ctx context.Context, phone string) (string, error)
- func (s *SessionService) GenerateQRCode(ctx context.Context) (string, error)
- func (s *SessionService) GenerateQRImage(ctx context.Context) ([]byte, error)
- func (s *SessionService) IsConnected() bool
- func (s *SessionService) IsLoggedIn() bool
- func (s *SessionService) Logout(ctx context.Context) error
- type SlogAdapter
- type StatusPrivacyResponse
- type StatusService
- func (s *StatusService) DeleteStatus(ctx context.Context, messageID string) error
- func (s *StatusService) GetStatusPrivacy(ctx context.Context) ([]StatusPrivacyResponse, error)
- func (s *StatusService) PostImageStatus(ctx context.Context, data []byte, mimeType, caption string) (string, error)
- func (s *StatusService) PostTextStatus(ctx context.Context, text string) (string, error)
- func (s *StatusService) PostVideoStatus(ctx context.Context, data []byte, mimeType, caption string) (string, error)
- type UserInfo
- type UserMeInfo
- type UserMeService
- func (a *UserMeService) GetMyInfo(ctx context.Context) (UserMeInfo, error)
- func (a *UserMeService) GetPrivacySettings(ctx context.Context) (PrivacySettingsResponse, error)
- func (a *UserMeService) SendPresence(ctx context.Context, presenceType string) error
- func (a *UserMeService) SetName(ctx context.Context, name string) error
- func (a *UserMeService) SetPrivacySetting(ctx context.Context, settingType, value string) (PrivacySettingsResponse, error)
- func (a *UserMeService) SetProfilePicture(ctx context.Context, picture []byte) (string, error)
- func (a *UserMeService) SetStatus(ctx context.Context, status string) error
- type UserService
Constants ¶
const SendAckTimeout = 75 * time.Second
SendAckTimeout is whatsmeow's defaultRequestTimeout: how long SendMessage waits for the server to acknowledge a message before giving up. It is an unexported constant upstream, mirrored here because the HTTP server's write deadline has to outlast it — see ServerConfig.WriteTimeoutDuration.
Variables ¶
var ErrInstanceNotFound = errors.New("instance not found")
ErrInstanceNotFound means the row was already gone. Callers deleting an instance should treat it as success: the desired end state is the same.
var ErrNotFound = errors.New("not found")
ErrNotFound indicates the requested resource was not found.
var ErrTimeout = errors.New("timeout")
ErrTimeout indicates a service-side wait exceeded its budget. Distinct from context.Canceled (caller went away): this is the server giving up.
var ErrTooLarge = errors.New("file too large")
ErrTooLarge indicates the requested media file exceeds the configured size limit.
var ErrUpstream = errors.New("upstream error")
ErrUpstream indicates the WhatsApp server returned an error.
Functions ¶
func DownloadMediaFromURL ¶
DownloadMediaFromURL downloads media from a URL with size limits and browser-like headers to avoid 406 responses from some servers.
func FormatRecipient ¶
FormatRecipient takes a phone number or JID string and returns a proper whatsmeow JID. If the input already contains '@', it is parsed as-is; otherwise '@s.whatsapp.net' is appended. A leading '+' is stripped, since WhatsApp JIDs use bare E.164 digits (e.g. "250725258789"), not the "+250725258789" display form.
func IsUpstreamTimeout ¶
IsUpstreamTimeout reports whether err is whatsmeow giving up waiting on WhatsApp. Two sentinels mean this, and a send can hit either:
- ErrMessageTimedOut — the message went out, no acknowledgement came back.
- ErrIQTimedOut — an info query stalled. Sends make these too, to fetch prekeys or sessions for a recipient they have no session with yet.
Both are bare errors.New values (whatsmeow/errors.go:21,24) wrapping neither context.DeadlineExceeded nor anything else, so callers matching on the usual timeout sentinels miss them entirely and fall through to whatever their default case is. Keeping the check here means the handler layer maps them without importing whatsmeow.
Both share the same 75s budget (defaultRequestTimeout), so neither is distinguishable from the other by duration alone — only by the error text, which is why ServiceError logs it.
func MigrateCustomTables ¶
MigrateCustomTables runs all pending schema migrations for WSAPI custom tables in the database. It must be called before creating any stores.
func OpenContainer ¶
func OpenContainer(ctx context.Context, driver, dsn string, logger *slog.Logger) (*sqlstore.Container, error)
OpenContainer initializes a whatsmeow sqlstore container.
func ResizeImageIfNeeded ¶
ResizeImageIfNeeded resizes an image if it is larger than 640 pixels in any direction while maintaining the aspect ratio. Returns the resized image as a byte slice.
Types ¶
type BulkCheckResult ¶
type BulkCheckResult struct {
Query string `json:"query"`
IsInWhatsApp bool `json:"isInWhatsApp"`
JID string `json:"jid,omitempty"`
}
BulkCheckResult is the domain response type for a bulk WhatsApp check.
type BusinessCategory ¶
BusinessCategory represents a business category.
type BusinessHours ¶
type BusinessHours struct {
DayOfWeek string `json:"dayOfWeek"`
Mode string `json:"mode"`
OpenTime string `json:"openTime"`
CloseTime string `json:"closeTime"`
}
BusinessHours represents business hours for a day.
type BusinessProfileResponse ¶
type BusinessProfileResponse struct {
ID string `json:"id"`
Address string `json:"address"`
Email string `json:"email"`
Description string `json:"description"`
Website string `json:"website"`
Latitude float64 `json:"latitude"`
Longitude float64 `json:"longitude"`
MemberSince string `json:"memberSince"`
Categories []BusinessCategory `json:"categories"`
BusinessHours []BusinessHours `json:"businessHours"`
BusinessHoursTimeZone string `json:"businessHoursTimeZone"`
ProfileOptions map[string]string `json:"profileOptions"`
}
BusinessProfileResponse is the domain response type for a business profile.
type CallService ¶
type CallService struct {
// contains filtered or unexported fields
}
CallService wraps the whatsmeow client for call operations.
func (*CallService) RejectCall ¶
func (c *CallService) RejectCall(ctx context.Context, callerID, callID string) error
RejectCall rejects an incoming call.
type ChatListItem ¶
type ChatListItem struct {
ID string `json:"id"`
LID string `json:"lid,omitempty"`
IsGroup bool `json:"isGroup"`
IsArchived bool `json:"isArchived"`
IsPinned bool `json:"isPinned"`
IsMuted bool `json:"isMuted"`
MuteEndTime *string `json:"muteEndTime,omitempty"`
PushName string `json:"pushName,omitempty"`
BusinessName string `json:"businessName,omitempty"`
FullName string `json:"fullName,omitempty"`
LastActivity *string `json:"lastActivity,omitempty"`
}
ChatListItem is the response type for a single chat in the list.
type ChatPictureResponse ¶
type ChatPictureResponse struct {
PictureID string `json:"pictureId"`
PictureURL string `json:"pictureUrl"`
}
ChatPictureResponse is the domain response type for a chat picture.
type ChatRecord ¶
ChatRecord tracks a known chat JID for a device.
type ChatService ¶
type ChatService struct {
// contains filtered or unexported fields
}
ChatService wraps the whatsmeow client for chat operations.
func (*ChatService) ArchiveChat ¶
ArchiveChat archives or unarchives a chat.
func (*ChatService) ClearChat ¶
func (c *ChatService) ClearChat(ctx context.Context, chatID string) error
ClearChat clears all messages from a chat but keeps the chat in the list.
func (*ChatService) DeleteChat ¶
func (c *ChatService) DeleteChat(ctx context.Context, chatID string) error
DeleteChat deletes a chat entirely.
func (*ChatService) GetBusinessProfile ¶
func (c *ChatService) GetBusinessProfile(ctx context.Context, chatID string) (BusinessProfileResponse, error)
GetBusinessProfile retrieves the business profile for a contact.
func (*ChatService) GetChatInfo ¶
func (c *ChatService) GetChatInfo(ctx context.Context, chatID string) (ChatListItem, error)
GetChatInfo returns details for a single chat, enriched with contact info and chat settings from the whatsmeow store.
func (*ChatService) GetChatPicture ¶
func (c *ChatService) GetChatPicture(ctx context.Context, chatID string) (ChatPictureResponse, error)
GetChatPicture retrieves the profile picture for a chat.
func (*ChatService) ListChats ¶
func (c *ChatService) ListChats(ctx context.Context) ([]ChatListItem, error)
ListChats returns all known chats for the device, enriched with contact info and chat settings from the whatsmeow store.
func (*ChatService) MarkChatAsRead ¶
MarkChatAsRead marks a chat as read or unread.
func (*ChatService) RequestMessages ¶
func (c *ChatService) RequestMessages(ctx context.Context, chatID, lastMessageID, lastMessageSenderID string, count int) error
RequestMessages sends an on-demand history sync request for the given chat. The response arrives asynchronously as a message_history_sync event.
func (*ChatService) SendChatPresence ¶
SendChatPresence sends a presence update (typing, paused, recording) to a chat.
func (*ChatService) SetEphemeralExpiration ¶
func (c *ChatService) SetEphemeralExpiration(ctx context.Context, chatID string, expiration string) error
SetEphemeralExpiration sets the disappearing messages timer for a chat.
func (*ChatService) SubscribeChatPresence ¶
func (c *ChatService) SubscribeChatPresence(ctx context.Context, chatID string) error
SubscribeChatPresence subscribes to presence updates for a chat.
type ChatStore ¶
type ChatStore struct {
// contains filtered or unexported fields
}
ChatStore manages the wsapi_chats table in the whatsmeow database. It uses the same our_jid FK pattern as whatsmeow so that chat records are automatically purged when a device is deleted or logged out.
func NewChatStore ¶
NewChatStore creates a ChatStore using the given shared database pool. MigrateCustomTables must be called before this.
type CommunityInfoResponse ¶
type CommunityInfoResponse struct {
CommunityID string `json:"communityId"`
Owner identity.Identity `json:"owner"`
Name string `json:"name"`
Created time.Time `json:"created"`
Description string `json:"description"`
IsLocked bool `json:"isLocked"`
CommunityApprovalMode string `json:"communityApprovalMode"`
Participants []GroupParticipant `json:"participants"`
}
CommunityInfoResponse is the domain response type for community information.
type CommunityService ¶
type CommunityService struct {
// contains filtered or unexported fields
}
CommunityService wraps the whatsmeow client for community operations.
func (*CommunityService) CreateCommunity ¶
func (c *CommunityService) CreateCommunity(ctx context.Context, name string, participants []string, approvalMode string) (string, error)
CreateCommunity creates a new WhatsApp community.
func (*CommunityService) CreateCommunityGroup ¶
func (c *CommunityService) CreateCommunityGroup(ctx context.Context, communityID string, name string, participants []string) (string, error)
CreateCommunityGroup creates a new group within a community.
func (*CommunityService) GetCommunityInfo ¶
func (c *CommunityService) GetCommunityInfo(ctx context.Context, communityID string) (CommunityInfoResponse, error)
GetCommunityInfo returns info about a specific community.
func (*CommunityService) GetCommunityInviteLink ¶
func (c *CommunityService) GetCommunityInviteLink(ctx context.Context, communityID string) (string, error)
GetCommunityInviteLink returns the invite link for a community.
func (*CommunityService) GetCommunityParticipants ¶
func (c *CommunityService) GetCommunityParticipants(ctx context.Context, communityID string) ([]identity.Identity, error)
GetCommunityParticipants returns all participants across all community groups.
func (*CommunityService) GetCommunitySubGroups ¶
func (c *CommunityService) GetCommunitySubGroups(ctx context.Context, communityID string) ([]CommunitySubGroupResponse, error)
GetCommunitySubGroups returns all groups within a community.
func (*CommunityService) GetJoinedCommunities ¶
func (c *CommunityService) GetJoinedCommunities(ctx context.Context) ([]CommunityInfoResponse, error)
GetJoinedCommunities returns all communities the user has joined.
func (*CommunityService) LeaveCommunity ¶
func (c *CommunityService) LeaveCommunity(ctx context.Context, communityID string) error
LeaveCommunity leaves the specified community.
func (*CommunityService) LinkGroupToCommunity ¶
func (c *CommunityService) LinkGroupToCommunity(ctx context.Context, communityID string, groupID string) error
LinkGroupToCommunity links an existing group to a community.
func (*CommunityService) ResetCommunityInviteLink ¶
func (c *CommunityService) ResetCommunityInviteLink(ctx context.Context, communityID string) (string, error)
ResetCommunityInviteLink resets and returns a new invite link for a community.
func (*CommunityService) SetCommunityDescription ¶
func (c *CommunityService) SetCommunityDescription(ctx context.Context, communityID string, description string) error
SetCommunityDescription sets the description of a community.
func (*CommunityService) SetCommunityLocked ¶
func (c *CommunityService) SetCommunityLocked(ctx context.Context, communityID string, locked bool) error
SetCommunityLocked sets the locked mode for a community.
func (*CommunityService) SetCommunityName ¶
func (c *CommunityService) SetCommunityName(ctx context.Context, communityID string, name string) error
SetCommunityName sets the name of a community.
func (*CommunityService) SetCommunityPicture ¶
func (c *CommunityService) SetCommunityPicture(ctx context.Context, communityID string, photo []byte) (string, error)
SetCommunityPicture sets the picture of a community.
func (*CommunityService) UnlinkGroupFromCommunity ¶
func (c *CommunityService) UnlinkGroupFromCommunity(ctx context.Context, communityID string, groupID string) error
UnlinkGroupFromCommunity removes a group from a community.
func (*CommunityService) UpdateCommunityParticipants ¶
func (c *CommunityService) UpdateCommunityParticipants(ctx context.Context, communityID string, participants []string, action string) error
UpdateCommunityParticipants updates participants in a community.
type CommunitySubGroupResponse ¶
type CommunitySubGroupResponse struct {
GroupID string `json:"groupId"`
Name string `json:"name"`
NameSetAt time.Time `json:"nameSetAt"`
IsAnnouncementGroup bool `json:"isAnnouncementGroup"`
}
CommunitySubGroupResponse represents a sub-group within a community.
type ContactInfo ¶
type ContactInfo struct {
identity.Identity
FullName string `json:"fullName"`
FirstName string `json:"firstName,omitempty"`
PushName string `json:"pushName"`
BusinessName string `json:"businessName,omitempty"`
InPhoneAddressBook bool `json:"inPhoneAddressBook"`
}
ContactInfo is the domain response type for contact information.
type ContactRecord ¶
type ContactRecord struct {
OurJID string
ContactJID string
ContactLID string
FirstName string
FullName string
InPhoneAddressBook bool
}
ContactRecord tracks a saved contact for a device.
type ContactService ¶
type ContactService struct {
// contains filtered or unexported fields
}
ContactService wraps the whatsmeow client for contact operations.
func (*ContactService) BlockContact ¶
func (c *ContactService) BlockContact(ctx context.Context, contactID string) error
BlockContact blocks a contact.
func (*ContactService) CreateOrUpdateContact ¶
func (c *ContactService) CreateOrUpdateContact(ctx context.Context, contactID string, fullName string, firstName string) error
CreateOrUpdateContact creates or updates a contact via WhatsApp app state sync.
func (*ContactService) GetAllContacts ¶
func (c *ContactService) GetAllContacts(ctx context.Context) ([]ContactInfo, error)
GetAllContacts returns all saved contacts from the custom contact store, enriched with push name and business name from whatsmeow's built-in store.
func (*ContactService) GetBlocklist ¶
GetBlocklist returns the list of blocked contacts.
func (*ContactService) GetContact ¶
func (c *ContactService) GetContact(ctx context.Context, contactID string) (ContactInfo, error)
GetContact retrieves information about a specific contact. It reads from the custom contact store first, falling back to whatsmeow's built-in store if the contact is not found.
func (*ContactService) SyncContacts ¶
func (c *ContactService) SyncContacts(ctx context.Context) error
SyncContacts triggers a full contact sync from the WhatsApp server.
func (*ContactService) UnblockContact ¶
func (c *ContactService) UnblockContact(ctx context.Context, contactID string) error
UnblockContact unblocks a contact.
type ContactStore ¶
type ContactStore struct {
// contains filtered or unexported fields
}
ContactStore manages the wsapi_contacts table in the whatsmeow database. It uses the same our_jid FK pattern as whatsmeow so that contact records are automatically purged when a device is deleted or logged out.
func NewContactStore ¶
func NewContactStore(db *sql.DB, dialect string) *ContactStore
NewContactStore creates a ContactStore using the given shared database pool. MigrateCustomTables must be called before this.
func (*ContactStore) Delete ¶
func (s *ContactStore) Delete(ctx context.Context, ourJID, contactJID string) error
func (*ContactStore) Get ¶
func (s *ContactStore) Get(ctx context.Context, ourJID, contactJID string) (ContactRecord, error)
func (*ContactStore) List ¶
func (s *ContactStore) List(ctx context.Context, ourJID string) ([]ContactRecord, error)
func (*ContactStore) Upsert ¶
func (s *ContactStore) Upsert(ctx context.Context, rec ContactRecord) error
type GroupInfoResponse ¶
type GroupInfoResponse struct {
GroupID string `json:"groupId"`
Owner identity.Identity `json:"owner"`
Name string `json:"name"`
CreatedAt time.Time `json:"createdAt"`
Description string `json:"description"`
IsAnnounce bool `json:"isAnnounce"`
IsLocked bool `json:"isLocked"`
IsEphemeral bool `json:"isEphemeral"`
EphemeralExpiration int64 `json:"ephemeralExpiration"`
Participants []GroupParticipant `json:"participants"`
CommunityID string `json:"communityId,omitempty"`
IsAnnouncementGroup bool `json:"isAnnouncementGroup,omitempty"`
IsJoinApprovalRequired bool `json:"isJoinApprovalRequired"`
MemberAddMode string `json:"memberAddMode"`
}
GroupInfoResponse is the domain response type for group information.
type GroupParticipant ¶
type GroupParticipant struct {
identity.Identity
IsAdmin bool `json:"isAdmin"`
IsSuperAdmin bool `json:"isSuperAdmin"`
DisplayName string `json:"displayName"`
}
GroupParticipant represents a participant in a group or community.
type GroupParticipantRequest ¶
type GroupParticipantRequest struct {
User identity.Identity `json:"user"`
RequestedAt time.Time `json:"requestedAt"`
}
GroupParticipantRequest represents a pending join request.
type GroupService ¶
type GroupService struct {
// contains filtered or unexported fields
}
GroupService wraps the whatsmeow client for group operations.
func (*GroupService) CreateGroup ¶
func (g *GroupService) CreateGroup(ctx context.Context, name string, participants []string) (string, error)
CreateGroup creates a new WhatsApp group with the given name and participants.
func (*GroupService) GetGroupInfo ¶
func (g *GroupService) GetGroupInfo(ctx context.Context, groupID string) (GroupInfoResponse, error)
GetGroupInfo returns information about a group.
func (*GroupService) GetGroupInfoFromInvite ¶
func (g *GroupService) GetGroupInfoFromInvite(ctx context.Context, groupID, inviterID, code string, expiration int64) (GroupInfoResponse, error)
GetGroupInfoFromInvite gets the group info from an invite message.
func (*GroupService) GetGroupInfoFromLink ¶
func (g *GroupService) GetGroupInfoFromLink(ctx context.Context, code string) (GroupInfoResponse, error)
GetGroupInfoFromLink resolves an invite link and returns group info.
func (*GroupService) GetGroupInviteLink ¶
func (g *GroupService) GetGroupInviteLink(ctx context.Context, groupID string, reset bool) (string, error)
GetGroupInviteLink returns or resets the group invite link.
func (*GroupService) GetGroupParticipants ¶
func (g *GroupService) GetGroupParticipants(ctx context.Context, groupID string) ([]GroupParticipant, error)
GetGroupParticipants returns just the participants for a group.
func (*GroupService) GetGroupRequestParticipants ¶
func (g *GroupService) GetGroupRequestParticipants(ctx context.Context, groupID string) ([]GroupParticipantRequest, error)
GetGroupRequestParticipants returns the list of pending join requests.
func (*GroupService) GetJoinedGroups ¶
func (g *GroupService) GetJoinedGroups(ctx context.Context) ([]GroupInfoResponse, error)
GetJoinedGroups returns the list of groups the user is participating in.
func (*GroupService) JoinGroupWithInvite ¶
func (g *GroupService) JoinGroupWithInvite(ctx context.Context, groupID, inviterID, code string, expiration int64) error
JoinGroupWithInvite joins a group using an invite message.
func (*GroupService) JoinGroupWithLink ¶
JoinGroupWithLink joins a group using an invite link code.
func (*GroupService) LeaveGroup ¶
func (g *GroupService) LeaveGroup(ctx context.Context, groupID string) error
LeaveGroup leaves the specified group.
func (*GroupService) SetGroupAnnounceMode ¶
func (g *GroupService) SetGroupAnnounceMode(ctx context.Context, groupID string, announceMode bool) error
SetGroupAnnounceMode sets the announce mode for a group.
func (*GroupService) SetGroupDescription ¶
func (g *GroupService) SetGroupDescription(ctx context.Context, groupID string, description string) error
SetGroupDescription sets the description for a group.
func (*GroupService) SetGroupJoinApprovalMode ¶
func (g *GroupService) SetGroupJoinApprovalMode(ctx context.Context, groupID string, joinApprovalMode bool) error
SetGroupJoinApprovalMode sets the join approval mode for a group.
func (*GroupService) SetGroupLocked ¶
SetGroupLocked sets the locked mode for a group.
func (*GroupService) SetGroupMemberAddMode ¶
func (g *GroupService) SetGroupMemberAddMode(ctx context.Context, groupID string, onlyAdminAdd bool) error
SetGroupMemberAddMode sets the member add mode for a group.
func (*GroupService) SetGroupName ¶
SetGroupName sets the name for a group.
func (*GroupService) SetGroupPicture ¶
func (g *GroupService) SetGroupPicture(ctx context.Context, groupID string, photo []byte) (string, error)
SetGroupPicture sets the photo for a group.
func (*GroupService) UpdateGroupParticipants ¶
func (g *GroupService) UpdateGroupParticipants(ctx context.Context, groupID string, participants []string, action string) error
UpdateGroupParticipants adds, removes, promotes, or demotes participants.
func (*GroupService) UpdateGroupRequestParticipants ¶
func (g *GroupService) UpdateGroupRequestParticipants(ctx context.Context, groupID string, participants []string, action string) error
UpdateGroupRequestParticipants approves or rejects pending join requests.
type HistorySyncService ¶
type HistorySyncService struct {
// contains filtered or unexported fields
}
HistorySyncService provides the flush-history-sync endpoint logic.
func (*HistorySyncService) FlushHistory ¶
func (s *HistorySyncService) FlushHistory(ctx context.Context, pub publisher.Publisher, instanceID string)
FlushHistory reads all cached history sync messages from the DB, publishes them as message_history_sync events (one per chat, chunked at 500 messages), and deletes the cache. It is intended to run asynchronously in a goroutine.
type HistorySyncStore ¶
type HistorySyncStore struct {
// contains filtered or unexported fields
}
HistorySyncStore manages the wsapi_history_sync_messages table in the whatsmeow database. It caches projected history sync messages during initial pairing so they can be flushed on demand.
func NewHistorySyncStore ¶
func NewHistorySyncStore(db *sql.DB, dialect string) *HistorySyncStore
NewHistorySyncStore creates a HistorySyncStore using the given shared database pool. MigrateCustomTables must be called before this.
func (*HistorySyncStore) DeleteAll ¶
func (s *HistorySyncStore) DeleteAll(ctx context.Context, ourJID string) error
DeleteAll removes all cached history sync rows for the given device.
func (*HistorySyncStore) GetMessages ¶
func (s *HistorySyncStore) GetMessages(ctx context.Context, ourJID, chatJID string) ([]string, error)
GetMessages returns the cached JSON message arrays for a specific chat, ordered by insertion order. Only non-expired rows are returned.
type InstanceRecord ¶
type InstanceRecord struct {
ID string `json:"id"`
DeviceID string `json:"deviceId"`
APIKey string `json:"apiKey"`
WebhookURL string `json:"webhookUrl"`
SigningSecret string `json:"signingSecret"`
EventFilters []string `json:"eventFilters"`
HistorySync *bool `json:"historySync"`
PublishEvents *bool `json:"publishEvents"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
LoggedInAt *time.Time `json:"loggedInAt,omitempty"`
LoggedOutAt *time.Time `json:"loggedOutAt,omitempty"`
}
InstanceRecord is the persisted representation of a managed instance.
type InstanceStore ¶
type InstanceStore struct {
// contains filtered or unexported fields
}
InstanceStore manages the wsapi_instances table.
func NewInstanceStore ¶
func NewInstanceStore(db *sql.DB, dialect string) *InstanceStore
NewInstanceStore creates an InstanceStore using the given shared database pool. MigrateCustomTables must be called before this.
func (*InstanceStore) DeleteInstance ¶
func (s *InstanceStore) DeleteInstance(ctx context.Context, id string) error
func (*InstanceStore) GetInstance ¶
func (s *InstanceStore) GetInstance(ctx context.Context, id string) (InstanceRecord, error)
func (*InstanceStore) ListInstances ¶
func (s *InstanceStore) ListInstances(ctx context.Context) ([]InstanceRecord, error)
func (*InstanceStore) SaveInstance ¶
func (s *InstanceStore) SaveInstance(ctx context.Context, inst InstanceRecord) error
func (*InstanceStore) UpdateDeviceState ¶
type MediaDownloadResult ¶
type MediaDownloadResult struct {
// Body streams the decrypted media content from a temp file.
Body io.ReadCloser
// Size is the number of decrypted bytes.
Size int64
// Filename is the suggested filename.
Filename string
// MimeType is the media MIME type.
MimeType string
}
MediaDownloadResult holds the result of a media download. The caller must call Close when done reading.
type MediaSendOptions ¶
type MediaSendOptions struct {
SendOptions
Caption string
ViewOnce bool
}
MediaSendOptions extends SendOptions with media-specific fields.
type MediaService ¶
type MediaService struct {
// contains filtered or unexported fields
}
MediaService wraps the whatsmeow client for media download operations.
slots, when non-nil, caps the number of concurrent in-flight Download calls across all instances sharing this channel. A nil channel means unlimited. downloadTimeout caps how long a single Download may hold a slot.
func (*MediaService) DownloadByID ¶
func (m *MediaService) DownloadByID(ctx context.Context, mediaID string) (*MediaDownloadResult, error)
DownloadByID downloads and decrypts a media file using an encoded media ID. The returned result streams content from a temp file to keep memory bounded.
type MessageService ¶
type MessageService struct {
// contains filtered or unexported fields
}
MessageService wraps the whatsmeow client for message operations.
func (*MessageService) DeleteMessage ¶
func (m *MessageService) DeleteMessage(ctx context.Context, chatID, senderID, messageID string) error
DeleteMessage revokes (deletes) a message for all participants.
func (*MessageService) DeleteMessageForMe ¶
func (m *MessageService) DeleteMessageForMe(ctx context.Context, chatID, senderID string, isFromMe bool, messageID string, timestamp time.Time) error
DeleteMessageForMe deletes a message only for the current user.
func (*MessageService) EditMessage ¶
func (m *MessageService) EditMessage(ctx context.Context, to, messageID, text string, opts SendOptions) (string, error)
EditMessage edits a previously sent message.
func (*MessageService) MarkAsRead ¶
func (m *MessageService) MarkAsRead(ctx context.Context, chatID, senderID, messageID, receiptType string) error
MarkAsRead marks a message as read.
func (*MessageService) PinMessage ¶
func (m *MessageService) PinMessage(ctx context.Context, chatID, senderID, messageID string, pinned bool, expiration string) error
PinMessage pins or unpins a message in a chat.
func (*MessageService) SendAudio ¶
func (m *MessageService) SendAudio(ctx context.Context, to string, data []byte, mimeType string, opts MediaSendOptions) (string, error)
SendAudio sends an audio message to the specified recipient.
func (*MessageService) SendContact ¶
func (m *MessageService) SendContact(ctx context.Context, to, displayName, vcard string, opts SendOptions) (string, error)
SendContact sends a contact card message to the specified recipient.
func (*MessageService) SendDocument ¶
func (m *MessageService) SendDocument(ctx context.Context, to string, data []byte, filename string, opts MediaSendOptions) (string, error)
SendDocument sends a document message to the specified recipient.
func (*MessageService) SendImage ¶
func (m *MessageService) SendImage(ctx context.Context, to string, data []byte, mimeType string, opts MediaSendOptions) (string, error)
SendImage sends an image message to the specified recipient.
func (*MessageService) SendLink ¶
func (m *MessageService) SendLink(ctx context.Context, to, text, url, title, description string, jpegThumbnail []byte, opts SendOptions) (string, error)
SendLink sends a link preview message to the specified recipient.
func (*MessageService) SendLocation ¶
func (m *MessageService) SendLocation(ctx context.Context, to string, lat, lng float64, name, address, url, ephemeralExp string) (string, error)
SendLocation sends a location message to the specified recipient.
func (*MessageService) SendReaction ¶
func (m *MessageService) SendReaction(ctx context.Context, to, senderID, messageID, reaction string) (string, error)
SendReaction sends a reaction to a message.
func (*MessageService) SendSticker ¶
func (m *MessageService) SendSticker(ctx context.Context, to string, data []byte, isAnimated bool, opts SendOptions) (string, error)
SendSticker sends a sticker message to the specified recipient.
func (*MessageService) SendText ¶
func (m *MessageService) SendText(ctx context.Context, to, text string, opts SendOptions) (string, error)
SendText sends a text message to the specified recipient.
func (*MessageService) SendVideo ¶
func (m *MessageService) SendVideo(ctx context.Context, to string, data []byte, mimeType string, opts MediaSendOptions) (string, error)
SendVideo sends a video message to the specified recipient.
func (*MessageService) SendVoice ¶
func (m *MessageService) SendVoice(ctx context.Context, to string, data []byte, opts MediaSendOptions) (string, error)
SendVoice sends a voice (PTT) message to the specified recipient.
func (*MessageService) StarMessage ¶
func (m *MessageService) StarMessage(ctx context.Context, chatID, senderID, messageID string, starred bool) error
StarMessage stars or unstars a message.
type NewsletterInfoResponse ¶
type NewsletterInfoResponse struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
SubscriberCount int `json:"subscriberCount"`
VerificationState string `json:"verificationState"`
PictureURL string `json:"pictureUrl,omitempty"`
InviteCode string `json:"inviteCode,omitempty"`
Role string `json:"role,omitempty"`
Mute string `json:"mute,omitempty"`
State string `json:"state"`
CreatedAt time.Time `json:"createdAt"`
}
NewsletterInfoResponse is the domain response type for newsletter information.
type NewsletterService ¶
type NewsletterService struct {
// contains filtered or unexported fields
}
NewsletterService wraps the whatsmeow client for newsletter operations.
func (*NewsletterService) CreateNewsletter ¶
func (n *NewsletterService) CreateNewsletter(ctx context.Context, name, description string, picture []byte) (NewsletterInfoResponse, error)
CreateNewsletter creates a new newsletter.
func (*NewsletterService) FollowNewsletter ¶
func (n *NewsletterService) FollowNewsletter(ctx context.Context, newsletterID string) error
FollowNewsletter subscribes to a newsletter.
func (*NewsletterService) GetNewsletterInfo ¶
func (n *NewsletterService) GetNewsletterInfo(ctx context.Context, newsletterID string) (NewsletterInfoResponse, error)
GetNewsletterInfo returns info about a specific newsletter.
func (*NewsletterService) GetNewsletterInfoWithInvite ¶
func (n *NewsletterService) GetNewsletterInfoWithInvite(ctx context.Context, inviteCode string) (NewsletterInfoResponse, error)
GetNewsletterInfoWithInvite returns info about a newsletter using an invite code.
func (*NewsletterService) GetSubscribedNewsletters ¶
func (n *NewsletterService) GetSubscribedNewsletters(ctx context.Context) ([]NewsletterInfoResponse, error)
GetSubscribedNewsletters returns all newsletters the user is subscribed to.
func (*NewsletterService) ToggleMuteNewsletter ¶
func (n *NewsletterService) ToggleMuteNewsletter(ctx context.Context, newsletterID string, mute bool) error
ToggleMuteNewsletter mutes or unmutes a newsletter.
func (*NewsletterService) UnfollowNewsletter ¶
func (n *NewsletterService) UnfollowNewsletter(ctx context.Context, newsletterID string) error
UnfollowNewsletter unsubscribes from a newsletter.
type PrivacySettingsResponse ¶
type PrivacySettingsResponse struct {
GroupAdd string `json:"groupAdd"`
LastSeen string `json:"lastSeen"`
Status string `json:"status"`
Profile string `json:"profile"`
ReadReceipts string `json:"readReceipts"`
Online string `json:"online"`
CallAdd string `json:"callAdd"`
}
PrivacySettingsResponse is the domain response type for privacy settings.
type SendOptions ¶
type SendOptions struct {
Mentions []string
ReplyTo string
ReplyToSenderID string
IsForwarded bool
EphemeralExpiration string
}
SendOptions holds common optional parameters for sending messages.
type Service ¶
type Service struct {
Messages *MessageService
Groups *GroupService
Communities *CommunityService
Contacts *ContactService
Chats *ChatService
Account *UserMeService
Users *UserService
Media *MediaService
Session *SessionService
Calls *CallService
Newsletters *NewsletterService
Status *StatusService
HistorySync *HistorySyncService
// contains filtered or unexported fields
}
Service wraps a whatsmeow client and exposes domain-specific sub-services.
func NewService ¶
func NewService(ctx context.Context, container *sqlstore.Container, deviceID string, logger, waLogger *slog.Logger, chatStore *ChatStore, contactStore *ContactStore, historySyncStore *HistorySyncStore, maxMediaFileSize int64, mediaDownloadSlots chan struct{}) (*Service, error)
NewService creates a whatsmeow-backed Service. If deviceID is non-empty the existing device store is loaded; otherwise a new device is created.
mediaDownloadSlots, when non-nil, is a process-wide channel shared by every Service to cap the number of concurrent /media/download operations. Pass nil to leave concurrency unbounded.
func (*Service) AddEventHandler ¶
func (s *Service) AddEventHandler(handler whatsmeow.EventHandler)
AddEventHandler registers an event handler on the underlying whatsmeow client.
func (*Service) DeleteDevice ¶
func (s *Service) DeleteDevice()
DeleteDevice disconnects and removes the device from the store.
func (*Service) Disconnect ¶
func (s *Service) Disconnect()
Disconnect tears down the WhatsApp connection.
func (*Service) GetDeviceJID ¶
GetDeviceJID returns the device JID string, or empty if not paired.
func (*Service) IsConnected ¶
IsConnected reports whether the client is connected.
func (*Service) IsLoggedIn ¶
IsLoggedIn reports whether the client has a paired device.
func (*Service) RemoveEventHandlers ¶
func (s *Service) RemoveEventHandlers()
RemoveEventHandlers removes all event handlers.
func (*Service) SetMaxParallelRetryReceipts ¶
SetMaxParallelRetryReceipts caps the number of retry-receipt handlers that run concurrently on this client. n <= 0 means unlimited (the whatsmeow default). Must be called before Connect to avoid data races.
func (*Service) SetPairClient ¶
SetPairClient configures the pair client type and OS used during pairing. This sets both the session-level fields (for phone code pairing) and the global store.DeviceProps (for QR pairing) to keep them consistent.
type SessionService ¶
type SessionService struct {
// contains filtered or unexported fields
}
SessionService wraps the whatsmeow client for session management operations.
func (*SessionService) Connect ¶
func (s *SessionService) Connect() error
Connect establishes a connection to WhatsApp.
func (*SessionService) Disconnect ¶
func (s *SessionService) Disconnect()
Disconnect disconnects from WhatsApp.
func (*SessionService) GeneratePairCode ¶
GeneratePairCode generates a pair code for WhatsApp Web login using a phone number.
func (*SessionService) GenerateQRCode ¶
func (s *SessionService) GenerateQRCode(ctx context.Context) (string, error)
GenerateQRCode generates a QR code string for WhatsApp Web login. Lifetime semantics match GenerateQRImage: ctx governs only the wait, not the QR pairing session itself.
func (*SessionService) GenerateQRImage ¶
func (s *SessionService) GenerateQRImage(ctx context.Context) ([]byte, error)
GenerateQRImage generates a QR code image for WhatsApp Web login and returns the PNG bytes. Honors ctx for the wait — if the inbound HTTP request is cancelled the function returns promptly. The underlying QR pairing session is intentionally NOT tied to ctx: it must outlive a single HTTP request so the user can still scan a code returned to a previous poll.
func (*SessionService) IsConnected ¶
func (s *SessionService) IsConnected() bool
IsConnected reports whether the client is connected to WhatsApp.
func (*SessionService) IsLoggedIn ¶
func (s *SessionService) IsLoggedIn() bool
IsLoggedIn reports whether the client has a paired device.
func (*SessionService) Logout ¶
func (s *SessionService) Logout(ctx context.Context) error
Logout disconnects from WhatsApp and removes the device session. The caller is responsible for discarding this *whatsmeow.Client afterwards (Manager.HandleLogout rebuilds the service) — calling Connect() on this client again would fail with "invalid use of deleted device".
type SlogAdapter ¶
type SlogAdapter struct {
// contains filtered or unexported fields
}
SlogAdapter adapts slog.Logger to whatsmeow's waLog.Logger interface.
func NewSlogAdapter ¶
func NewSlogAdapter(logger *slog.Logger) *SlogAdapter
func (*SlogAdapter) Debugf ¶
func (a *SlogAdapter) Debugf(msg string, args ...interface{})
func (*SlogAdapter) Errorf ¶
func (a *SlogAdapter) Errorf(msg string, args ...interface{})
func (*SlogAdapter) Infof ¶
func (a *SlogAdapter) Infof(msg string, args ...interface{})
func (*SlogAdapter) Warnf ¶
func (a *SlogAdapter) Warnf(msg string, args ...interface{})
type StatusPrivacyResponse ¶
type StatusPrivacyResponse struct {
Type string `json:"type"`
List []string `json:"list,omitempty"`
IsDefault bool `json:"isDefault"`
}
StatusPrivacyResponse is the domain response type for a status privacy setting.
type StatusService ¶
type StatusService struct {
// contains filtered or unexported fields
}
StatusService wraps the whatsmeow client for status/stories operations.
func (*StatusService) DeleteStatus ¶
func (s *StatusService) DeleteStatus(ctx context.Context, messageID string) error
DeleteStatus revokes (deletes) a previously posted status update.
func (*StatusService) GetStatusPrivacy ¶
func (s *StatusService) GetStatusPrivacy(ctx context.Context) ([]StatusPrivacyResponse, error)
GetStatusPrivacy returns the status broadcast privacy settings.
func (*StatusService) PostImageStatus ¶
func (s *StatusService) PostImageStatus(ctx context.Context, data []byte, mimeType, caption string) (string, error)
PostImageStatus posts an image status update.
func (*StatusService) PostTextStatus ¶
PostTextStatus posts a text status update.
func (*StatusService) PostVideoStatus ¶
func (s *StatusService) PostVideoStatus(ctx context.Context, data []byte, mimeType, caption string) (string, error)
PostVideoStatus posts a video status update.
type UserInfo ¶
type UserInfo struct {
identity.Identity
IsInWhatsApp bool `json:"isInWhatsApp"`
Status string `json:"status"`
PictureID string `json:"pictureId"`
PictureURL string `json:"pictureUrl,omitempty"`
IsVerified bool `json:"isVerified"`
}
UserInfo is the domain response type for user information.
type UserMeInfo ¶
type UserMeInfo struct {
identity.Identity
DeviceID uint16 `json:"deviceId"`
PushName string `json:"pushName"`
BusinessName string `json:"businessName"`
Status string `json:"status"`
PictureID string `json:"pictureId"`
IsVerified bool `json:"isVerified"`
}
UserMeInfo is the domain response type for the logged-in user's profile.
type UserMeService ¶
type UserMeService struct {
// contains filtered or unexported fields
}
UserMeService wraps the whatsmeow client for own-account operations.
func (*UserMeService) GetMyInfo ¶
func (a *UserMeService) GetMyInfo(ctx context.Context) (UserMeInfo, error)
GetMyInfo returns information about the currently logged-in account.
func (*UserMeService) GetPrivacySettings ¶
func (a *UserMeService) GetPrivacySettings(ctx context.Context) (PrivacySettingsResponse, error)
GetPrivacySettings returns the current privacy settings.
func (*UserMeService) SendPresence ¶
func (a *UserMeService) SendPresence(ctx context.Context, presenceType string) error
SendPresence sets the presence state (available or unavailable).
func (*UserMeService) SetName ¶
func (a *UserMeService) SetName(ctx context.Context, name string) error
SetName sets the push name for the WhatsApp account.
func (*UserMeService) SetPrivacySetting ¶
func (a *UserMeService) SetPrivacySetting(ctx context.Context, settingType, value string) (PrivacySettingsResponse, error)
SetPrivacySetting updates a single privacy setting.
func (*UserMeService) SetProfilePicture ¶
SetProfilePicture sets the profile picture for the WhatsApp account.
func (*UserMeService) SetStatus ¶
func (a *UserMeService) SetStatus(ctx context.Context, status string) error
SetStatus sets the about/status text for the WhatsApp account.
Bypasses whatsmeow's SetStatusMessage, which now sends a mex mutation that a live account either rejects or accepts without changing the About text. The legacy IQ below is what whatsmeow sent before and still works.
type UserService ¶
type UserService struct {
// contains filtered or unexported fields
}
UserService wraps the whatsmeow client for user lookup operations.
func (*UserService) BulkCheckOnWhatsApp ¶
func (u *UserService) BulkCheckOnWhatsApp(ctx context.Context, phones []string) ([]BulkCheckResult, error)
BulkCheckOnWhatsApp checks multiple phone numbers at once.
func (*UserService) CheckOnWhatsApp ¶
CheckOnWhatsApp checks whether a phone number is registered on WhatsApp.
func (*UserService) GetUserInfo ¶
GetUserInfo looks up a phone number and returns user information.