Documentation ¶
Overview ¶
Package types contains various structs and other types used by whatsmeow.
Index ¶
- Constants
- Variables
- type BasicCallMeta
- type BusinessMessageLinkTarget
- type CallRemoteMeta
- type ChatPresence
- type ChatPresenceMedia
- type ContactInfo
- type ContactQRLinkTarget
- type DeviceSentMeta
- type GroupAnnounce
- type GroupEphemeral
- type GroupInfo
- type GroupLocked
- type GroupMemberAddMode
- type GroupName
- type GroupParticipant
- type GroupTopic
- type IsOnWhatsAppResponse
- type JID
- 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 MessageSource
- type Presence
- type PrivacySetting
- type PrivacySettings
- type ProfilePictureInfo
- type StatusPrivacy
- type StatusPrivacyType
- type UserInfo
- type VerifiedName
Constants ¶
const ( DefaultUserServer = "s.whatsapp.net" GroupServer = "g.us" LegacyUserServer = "c.us" BroadcastServer = "broadcast" )
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) )
Some JIDs that are contacted often.
Functions ¶
This section is empty.
Types ¶
type BasicCallMeta ¶
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 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 GroupAnnounce ¶
GroupAnnounce specifies whether only admins can send messages in the group.
type GroupEphemeral ¶
GroupEphemeral contains the group's disappearing messages settings.
type GroupInfo ¶
type GroupInfo struct { JID JID OwnerJID JID GroupName GroupTopic GroupLocked GroupAnnounce GroupEphemeral GroupCreated time.Time ParticipantVersionID string Participants []GroupParticipant MemberAddMode GroupMemberAddMode }
GroupInfo contains basic information about a group chat on WhatsApp.
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 GroupParticipant ¶
GroupParticipant contains info about a participant of a WhatsApp group chat.
type GroupTopic ¶
GroupTopic contains the topic (description) of a group along with metadata of who set it and when.
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) 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, except for JIDs with no User part specified.
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 string Type string PushName string Timestamp time.Time Category string Multicast bool MediaType string 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 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 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" PrivacySettingNone PrivacySetting = "none" )
Possible privacy setting values.
type PrivacySettings ¶
type PrivacySettings struct { GroupAdd PrivacySetting LastSeen PrivacySetting Status PrivacySetting Profile PrivacySetting ReadReceipts PrivacySetting }
PrivacySettings contains the user's privacy settings.
type ProfilePictureInfo ¶
type ProfilePictureInfo struct { URL string // The full URL for the image, can be downloaded with a simple HTTP request. ID string // The ID of the image. This is the same as UserInfo.PictureID. Type string // The type of image. Known types include "image" (full res) and "preview" (thumbnail). DirectPath string // 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 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.