Documentation ¶
Overview ¶
Package types contains various structs and other types used by whatsmeow.
Index ¶
- Constants
- Variables
- type BasicCallMeta
- type Blocklist
- type BotEditType
- type BotListInfo
- type BotProfileCommand
- type BotProfileInfo
- type BusinessHoursConfig
- type BusinessMessageLinkTarget
- type BusinessProfile
- type CallRemoteMeta
- type Category
- type ChatPresence
- type ChatPresenceMedia
- type ContactInfo
- type ContactQRLinkTarget
- type DeviceSentMeta
- type EditAttribute
- type GraphQLError
- type GraphQLErrorExtensions
- type GraphQLErrors
- type GraphQLResponse
- type GroupAnnounce
- type GroupDelete
- type GroupEphemeral
- type GroupIncognito
- type GroupInfo
- type GroupIsDefaultSub
- type GroupLinkChange
- type GroupLinkChangeType
- type GroupLinkTarget
- type GroupLinkedParent
- type GroupLocked
- type GroupMemberAddMode
- type GroupName
- type GroupParent
- type GroupParticipant
- type GroupParticipantAddRequest
- type GroupTopic
- type GroupUnlinkReason
- type IsOnWhatsAppResponse
- type JID
- func (jid JID) ADString() string
- func (jid JID) ActualAgent() uint8
- func (jid JID) IsBot() bool
- func (jid JID) IsBroadcastList() bool
- func (jid JID) IsEmpty() bool
- func (jid JID) MarshalText() ([]byte, error)
- func (jid *JID) Scan(src interface{}) error
- func (jid JID) SignalAddress() *signalProtocol.SignalAddress
- func (jid JID) String() string
- func (jid JID) ToNonAD() JID
- func (jid *JID) UnmarshalText(val []byte) error
- func (jid JID) UserInt() uint64
- func (jid JID) Value() (driver.Value, error)
- type LocalChatSettings
- type MessageID
- type MessageInfo
- type MessageServerID
- type MessageSource
- type MsgBotInfo
- type MsgMetaInfo
- type NewsletterKeyType
- type NewsletterMessage
- type NewsletterMetadata
- type NewsletterMuteState
- type NewsletterMuted
- type NewsletterPrivacy
- type NewsletterReactionSettings
- type NewsletterReactionsMode
- type NewsletterRole
- type NewsletterSettings
- type NewsletterState
- type NewsletterText
- type NewsletterThreadMetadata
- type NewsletterVerificationState
- type NewsletterViewerMetadata
- type Presence
- type PrivacySetting
- type PrivacySettingType
- type PrivacySettings
- type ProfilePictureInfo
- type ReceiptType
- type StatusPrivacy
- type StatusPrivacyType
- type UserInfo
- type VerifiedName
- type WrappedNewsletterState
Constants ¶
const ( DefaultUserServer = "s.whatsapp.net" GroupServer = "g.us" LegacyUserServer = "c.us" BroadcastServer = "broadcast" HiddenUserServer = "lid" MessengerServer = "msgr" InteropServer = "interop" NewsletterServer = "newsletter" HostedServer = "hosted" )
Known JID servers on WhatsApp
Variables ¶
var ( EmptyJID = JID{} GroupServerJID = NewJID("", GroupServer) ServerJID = NewJID("", DefaultUserServer) BroadcastServerJID = NewJID("", BroadcastServer) StatusBroadcastJID = NewJID("status", BroadcastServer) PSAJID = NewJID("0", LegacyUserServer) OfficialBusinessJID = NewJID("16505361212", LegacyUserServer) MetaAIJID = NewJID("13135550002", DefaultUserServer) )
Some JIDs that are contacted often.
Functions ¶
This section is empty.
Types ¶
type BasicCallMeta ¶
type BotEditType ¶
type BotEditType string
const ( EditTypeFirst BotEditType = "first" EditTypeInner BotEditType = "inner" EditTypeLast BotEditType = "last" )
type BotListInfo ¶
type BotProfileCommand ¶
type BotProfileInfo ¶
type BusinessHoursConfig ¶
BusinessHoursConfig contains business operating hours of a WhatsApp business.
type BusinessMessageLinkTarget ¶
type BusinessMessageLinkTarget struct { JID JID // The JID of the business. PushName string // The notify / push name of the business. VerifiedName string // The verified business name. IsSigned bool // Some boolean, seems to be true? VerifiedLevel string // I guess the level of verification, starting from "unknown". Message string // The message that WhatsApp clients will pre-fill in the input box when clicking the link. }
BusinessMessageLinkTarget contains the info that is found using a business message link (see Client.ResolveBusinessMessageLink)
type BusinessProfile ¶
type BusinessProfile struct { JID JID Address string Email string Categories []Category ProfileOptions map[string]string BusinessHoursTimeZone string BusinessHours []BusinessHoursConfig }
BusinessProfile contains the profile information of a WhatsApp business.
type CallRemoteMeta ¶
type ChatPresence ¶
type ChatPresence string
const ( ChatPresenceComposing ChatPresence = "composing" ChatPresencePaused ChatPresence = "paused" )
type ChatPresenceMedia ¶
type ChatPresenceMedia string
const ( ChatPresenceMediaText ChatPresenceMedia = "" ChatPresenceMediaAudio ChatPresenceMedia = "audio" )
type ContactInfo ¶
type ContactInfo struct { Found bool FirstName string FullName string PushName string BusinessName string }
ContactInfo contains the cached names of a WhatsApp user.
type ContactQRLinkTarget ¶
type ContactQRLinkTarget struct { JID JID // The JID of the user. Type string // Might always be "contact". PushName string // The notify / push name of the user. }
ContactQRLinkTarget contains the info that is found using a contact QR link (see Client.ResolveContactQRLink)
type DeviceSentMeta ¶
type DeviceSentMeta struct { DestinationJID string // The destination user. This should match the MessageInfo.Recipient field. Phash string }
DeviceSentMeta contains metadata from messages sent by another one of the user's own devices.
type EditAttribute ¶
type EditAttribute string
const ( EditAttributeEmpty EditAttribute = "" EditAttributeMessageEdit EditAttribute = "1" EditAttributePinInChat EditAttribute = "2" EditAttributeAdminEdit EditAttribute = "3" // only used in newsletters EditAttributeSenderRevoke EditAttribute = "7" EditAttributeAdminRevoke EditAttribute = "8" )
type GraphQLError ¶
type GraphQLError struct { Extensions GraphQLErrorExtensions `json:"extensions"` Message string `json:"message"` Path []string `json:"path"` }
func (GraphQLError) Error ¶
func (gqle GraphQLError) Error() string
type GraphQLErrorExtensions ¶
type GraphQLErrors ¶
type GraphQLErrors []GraphQLError
func (GraphQLErrors) Error ¶
func (gqles GraphQLErrors) Error() string
func (GraphQLErrors) Unwrap ¶
func (gqles GraphQLErrors) Unwrap() []error
type GraphQLResponse ¶
type GraphQLResponse struct { Data json.RawMessage `json:"data"` Errors GraphQLErrors `json:"errors"` }
type GroupAnnounce ¶
GroupAnnounce specifies whether only admins can send messages in the group.
type GroupDelete ¶
type GroupEphemeral ¶
GroupEphemeral contains the group's disappearing messages settings.
type GroupIncognito ¶
type GroupIncognito struct {
IsIncognito bool
}
type GroupInfo ¶
type GroupInfo struct { JID JID OwnerJID JID GroupName GroupTopic GroupLocked GroupAnnounce GroupEphemeral GroupIncognito GroupParent GroupLinkedParent GroupIsDefaultSub GroupCreated time.Time ParticipantVersionID string Participants []GroupParticipant MemberAddMode GroupMemberAddMode }
GroupInfo contains basic information about a group chat on WhatsApp.
type GroupIsDefaultSub ¶
type GroupIsDefaultSub struct {
IsDefaultSubGroup bool
}
type GroupLinkChange ¶
type GroupLinkChange struct { Type GroupLinkChangeType UnlinkReason GroupUnlinkReason Group GroupLinkTarget }
type GroupLinkChangeType ¶
type GroupLinkChangeType string
const ( GroupLinkChangeTypeParent GroupLinkChangeType = "parent_group" GroupLinkChangeTypeSub GroupLinkChangeType = "sub_group" GroupLinkChangeTypeSibling GroupLinkChangeType = "sibling_group" )
type GroupLinkTarget ¶
type GroupLinkTarget struct { JID JID GroupName GroupIsDefaultSub }
type GroupLinkedParent ¶
type GroupLinkedParent struct {
LinkedParentJID JID
}
type GroupLocked ¶
type GroupLocked struct {
IsLocked bool
}
GroupLocked specifies whether the group info can only be edited by admins.
type GroupMemberAddMode ¶
type GroupMemberAddMode string
const (
GroupMemberAddModeAdmin GroupMemberAddMode = "admin_add"
)
type GroupParent ¶
type GroupParticipant ¶
type GroupParticipant struct { JID JID LID JID IsAdmin bool IsSuperAdmin bool // This is only present for anonymous users in announcement groups, it's an obfuscated phone number DisplayName string // When creating groups, adding some participants may fail. // In such cases, the error code will be here. Error int AddRequest *GroupParticipantAddRequest }
GroupParticipant contains info about a participant of a WhatsApp group chat.
type GroupTopic ¶
type GroupTopic struct { Topic string TopicID string TopicSetAt time.Time TopicSetBy JID TopicDeleted bool }
GroupTopic contains the topic (description) of a group along with metadata of who set it and when.
type GroupUnlinkReason ¶
type GroupUnlinkReason string
const ( GroupUnlinkReasonDefault GroupUnlinkReason = "unlink_group" GroupUnlinkReasonDelete GroupUnlinkReason = "delete_parent" )
type IsOnWhatsAppResponse ¶
type IsOnWhatsAppResponse struct { Query string // The query string used JID JID // The canonical user ID IsIn bool // Whether the phone is registered or not. VerifiedName *VerifiedName // If the phone is a business, the verified business details. }
IsOnWhatsAppResponse contains information received in response to checking if a phone number is on WhatsApp.
type JID ¶
JID represents a WhatsApp user ID.
There are two types of JIDs: regular JID pairs (user and server) and AD-JIDs (user, agent and device). AD JIDs are only used to refer to specific devices of users, so the server is always s.whatsapp.net (DefaultUserServer). Regular JIDs can be used for entities on any servers (users, groups, broadcasts).
func ParseJID ¶
ParseJID parses a JID out of the given string. It supports both regular and AD JIDs.
func (JID) ActualAgent ¶
func (JID) IsBroadcastList ¶
IsBroadcastList returns true if the JID is a broadcast list, but not the status broadcast.
func (JID) IsEmpty ¶
IsEmpty returns true if the JID has no server (which is required for all JIDs).
func (JID) MarshalText ¶
MarshalText implements encoding.TextMarshaler for JID
func (JID) SignalAddress ¶
func (jid JID) SignalAddress() *signalProtocol.SignalAddress
SignalAddress returns the Signal protocol address for the user.
func (JID) String ¶
String converts the JID to a string representation. The output string can be parsed with ParseJID.
func (JID) ToNonAD ¶
ToNonAD returns a version of the JID struct that doesn't have the agent and device set.
func (*JID) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler for JID
type LocalChatSettings ¶
LocalChatSettings contains the cached local settings for a chat.
type MessageInfo ¶
type MessageInfo struct { MessageSource ID MessageID ServerID MessageServerID Type string PushName string Timestamp time.Time Category string Multicast bool MediaType string Edit EditAttribute MsgBotInfo MsgBotInfo MsgMetaInfo MsgMetaInfo VerifiedName *VerifiedName DeviceSentMeta *DeviceSentMeta // Metadata for direct messages sent from another one of the user's own devices. }
MessageInfo contains metadata about an incoming message.
type MessageServerID ¶
type MessageServerID = int
MessageServerID is the server ID of a WhatsApp newsletter message.
type MessageSource ¶
type MessageSource struct { Chat JID // The chat where the message was sent. Sender JID // The user who sent the message. IsFromMe bool // Whether the message was sent by the current user instead of someone else. IsGroup bool // Whether the chat is a group chat or broadcast list. // When sending a read receipt to a broadcast list message, the Chat is the broadcast list // and Sender is you, so this field contains the recipient of the read receipt. BroadcastListOwner JID }
MessageSource contains basic sender and chat information about a message.
func (*MessageSource) IsIncomingBroadcast ¶
func (ms *MessageSource) IsIncomingBroadcast() bool
IsIncomingBroadcast returns true if the message was sent to a broadcast list instead of directly to the user.
If this is true, it means the message shows up in the direct chat with the Sender.
func (*MessageSource) SourceString ¶
func (ms *MessageSource) SourceString() string
SourceString returns a log-friendly representation of who sent the message and where.
type MsgBotInfo ¶
type MsgBotInfo struct { EditType BotEditType EditTargetID MessageID EditSenderTimestampMS time.Time }
MsgBotInfo targets <bot>
type MsgMetaInfo ¶
MsgMetaInfo targets <meta>
type NewsletterKeyType ¶
type NewsletterKeyType string
const ( NewsletterKeyTypeJID NewsletterKeyType = "JID" NewsletterKeyTypeInvite NewsletterKeyType = "INVITE" )
type NewsletterMessage ¶
type NewsletterMetadata ¶
type NewsletterMetadata struct { ID JID `json:"id"` State WrappedNewsletterState `json:"state"` ThreadMeta NewsletterThreadMetadata `json:"thread_metadata"` ViewerMeta *NewsletterViewerMetadata `json:"viewer_metadata"` }
type NewsletterMuteState ¶
type NewsletterMuteState string
const ( NewsletterMuteOn NewsletterMuteState = "on" NewsletterMuteOff NewsletterMuteState = "off" )
func (*NewsletterMuteState) UnmarshalText ¶
func (nms *NewsletterMuteState) UnmarshalText(text []byte) error
type NewsletterMuted ¶
type NewsletterMuted struct {
Muted bool
}
type NewsletterPrivacy ¶
type NewsletterPrivacy string
const ( NewsletterPrivacyPrivate NewsletterPrivacy = "private" NewsletterPrivacyPublic NewsletterPrivacy = "public" )
func (*NewsletterPrivacy) UnmarshalText ¶
func (np *NewsletterPrivacy) UnmarshalText(text []byte) error
type NewsletterReactionSettings ¶
type NewsletterReactionSettings struct {
Value NewsletterReactionsMode `json:"value"`
}
type NewsletterReactionsMode ¶
type NewsletterReactionsMode string
const ( NewsletterReactionsModeAll NewsletterReactionsMode = "all" NewsletterReactionsModeBasic NewsletterReactionsMode = "basic" NewsletterReactionsModeNone NewsletterReactionsMode = "none" NewsletterReactionsModeBlocklist NewsletterReactionsMode = "blocklist" )
type NewsletterRole ¶
type NewsletterRole string
const ( NewsletterRoleSubscriber NewsletterRole = "subscriber" NewsletterRoleGuest NewsletterRole = "guest" NewsletterRoleAdmin NewsletterRole = "admin" NewsletterRoleOwner NewsletterRole = "owner" )
func (*NewsletterRole) UnmarshalText ¶
func (nr *NewsletterRole) UnmarshalText(text []byte) error
type NewsletterSettings ¶
type NewsletterSettings struct {
ReactionCodes NewsletterReactionSettings `json:"reaction_codes"`
}
type NewsletterState ¶
type NewsletterState string
const ( NewsletterStateActive NewsletterState = "active" NewsletterStateSuspended NewsletterState = "suspended" NewsletterStateGeoSuspended NewsletterState = "geosuspended" )
func (*NewsletterState) UnmarshalText ¶
func (ns *NewsletterState) UnmarshalText(text []byte) error
type NewsletterText ¶
type NewsletterText struct { Text string `json:"text"` ID string `json:"id"` UpdateTime jsontime.UnixMicroString `json:"update_time"` }
type NewsletterThreadMetadata ¶
type NewsletterThreadMetadata struct { CreationTime jsontime.UnixString `json:"creation_time"` InviteCode string `json:"invite"` Name NewsletterText `json:"name"` Description NewsletterText `json:"description"` SubscriberCount int `json:"subscribers_count,string"` VerificationState NewsletterVerificationState `json:"verification"` Picture *ProfilePictureInfo `json:"picture"` Preview ProfilePictureInfo `json:"preview"` Settings NewsletterSettings `json:"settings"` }
type NewsletterVerificationState ¶
type NewsletterVerificationState string
const ( NewsletterVerificationStateVerified NewsletterVerificationState = "verified" NewsletterVerificationStateUnverified NewsletterVerificationState = "unverified" )
func (*NewsletterVerificationState) UnmarshalText ¶
func (nvs *NewsletterVerificationState) UnmarshalText(text []byte) error
type NewsletterViewerMetadata ¶
type NewsletterViewerMetadata struct { Mute NewsletterMuteState `json:"mute"` Role NewsletterRole `json:"role"` }
type PrivacySetting ¶
type PrivacySetting string
PrivacySetting is an individual setting value in the user's privacy settings.
const ( PrivacySettingUndefined PrivacySetting = "" PrivacySettingAll PrivacySetting = "all" PrivacySettingContacts PrivacySetting = "contacts" PrivacySettingContactBlacklist PrivacySetting = "contact_blacklist" PrivacySettingMatchLastSeen PrivacySetting = "match_last_seen" PrivacySettingKnown PrivacySetting = "known" PrivacySettingNone PrivacySetting = "none" )
Possible privacy setting values.
type PrivacySettingType ¶
type PrivacySettingType string
PrivacySettingType is the type of privacy setting.
const ( PrivacySettingTypeGroupAdd PrivacySettingType = "groupadd" // Valid values: PrivacySettingAll, PrivacySettingContacts, PrivacySettingContactBlacklist, PrivacySettingNone PrivacySettingTypeLastSeen PrivacySettingType = "last" // Valid values: PrivacySettingAll, PrivacySettingContacts, PrivacySettingContactBlacklist, PrivacySettingNone PrivacySettingTypeStatus PrivacySettingType = "status" // Valid values: PrivacySettingAll, PrivacySettingContacts, PrivacySettingContactBlacklist, PrivacySettingNone PrivacySettingTypeProfile PrivacySettingType = "profile" // Valid values: PrivacySettingAll, PrivacySettingContacts, PrivacySettingContactBlacklist, PrivacySettingNone PrivacySettingTypeReadReceipts PrivacySettingType = "readreceipts" // Valid values: PrivacySettingAll, PrivacySettingNone PrivacySettingTypeOnline PrivacySettingType = "online" // Valid values: PrivacySettingAll, PrivacySettingMatchLastSeen PrivacySettingTypeCallAdd PrivacySettingType = "calladd" // Valid values: PrivacySettingAll, PrivacySettingKnown )
type PrivacySettings ¶
type PrivacySettings struct { GroupAdd PrivacySetting // Valid values: PrivacySettingAll, PrivacySettingContacts, PrivacySettingContactBlacklist, PrivacySettingNone LastSeen PrivacySetting // Valid values: PrivacySettingAll, PrivacySettingContacts, PrivacySettingContactBlacklist, PrivacySettingNone Status PrivacySetting // Valid values: PrivacySettingAll, PrivacySettingContacts, PrivacySettingContactBlacklist, PrivacySettingNone Profile PrivacySetting // Valid values: PrivacySettingAll, PrivacySettingContacts, PrivacySettingContactBlacklist, PrivacySettingNone ReadReceipts PrivacySetting // Valid values: PrivacySettingAll, PrivacySettingNone CallAdd PrivacySetting // Valid values: PrivacySettingAll, PrivacySettingKnown Online PrivacySetting // Valid values: PrivacySettingAll, PrivacySettingMatchLastSeen }
PrivacySettings contains the user's privacy settings.
type ProfilePictureInfo ¶
type ProfilePictureInfo struct { URL string `json:"url"` // The full URL for the image, can be downloaded with a simple HTTP request. ID string `json:"id"` // The ID of the image. This is the same as UserInfo.PictureID. Type string `json:"type"` // The type of image. Known types include "image" (full res) and "preview" (thumbnail). DirectPath string `json:"direct_path"` // The path to the image, probably not very useful }
ProfilePictureInfo contains the ID and URL for a WhatsApp user's profile picture or group's photo.
type ReceiptType ¶
type ReceiptType string
ReceiptType represents the type of a Receipt event.
const ( // ReceiptTypeDelivered means the message was delivered to the device (but the user might not have noticed). ReceiptTypeDelivered ReceiptType = "" // ReceiptTypeSender is sent by your other devices when a message you sent is delivered to them. ReceiptTypeSender ReceiptType = "sender" // ReceiptTypeRetry means the message was delivered to the device, but decrypting the message failed. ReceiptTypeRetry ReceiptType = "retry" // ReceiptTypeRead means the user opened the chat and saw the message. ReceiptTypeRead ReceiptType = "read" // ReceiptTypeReadSelf means the current user read a message from a different device, and has read receipts disabled in privacy settings. ReceiptTypeReadSelf ReceiptType = "read-self" // ReceiptTypePlayed means the user opened a view-once media message. // // This is dispatched for both incoming and outgoing messages when played. If the current user opened the media, // it means the media should be removed from all devices. If a recipient opened the media, it's just a notification // for the sender that the media was viewed. ReceiptTypePlayed ReceiptType = "played" // ReceiptTypePlayedSelf probably means the current user opened a view-once media message from a different device, // and has read receipts disabled in privacy settings. ReceiptTypePlayedSelf ReceiptType = "played-self" ReceiptTypeServerError ReceiptType = "server-error" ReceiptTypeInactive ReceiptType = "inactive" ReceiptTypePeerMsg ReceiptType = "peer_msg" ReceiptTypeHistorySync ReceiptType = "hist_sync" )
func (ReceiptType) GoString ¶
func (rt ReceiptType) GoString() string
GoString returns the name of the Go constant for the ReceiptType value.
type StatusPrivacy ¶
type StatusPrivacy struct { Type StatusPrivacyType List []JID IsDefault bool }
StatusPrivacy contains the settings for who to send status messages to by default.
type StatusPrivacyType ¶
type StatusPrivacyType string
StatusPrivacyType is the type of list in StatusPrivacy.
const ( // StatusPrivacyTypeContacts means statuses are sent to all contacts. StatusPrivacyTypeContacts StatusPrivacyType = "contacts" // StatusPrivacyTypeBlacklist means statuses are sent to all contacts, except the ones on the list. StatusPrivacyTypeBlacklist StatusPrivacyType = "blacklist" // StatusPrivacyTypeWhitelist means statuses are only sent to users on the list. StatusPrivacyTypeWhitelist StatusPrivacyType = "whitelist" )
type UserInfo ¶
type UserInfo struct { VerifiedName *VerifiedName Status string PictureID string Devices []JID }
UserInfo contains info about a WhatsApp user.
type VerifiedName ¶
type VerifiedName struct { Certificate *waProto.VerifiedNameCertificate Details *waProto.VerifiedNameCertificate_Details }
VerifiedName contains verified WhatsApp business details.
type WrappedNewsletterState ¶
type WrappedNewsletterState struct {
Type NewsletterState `json:"type"`
}