types

package
v0.0.0-...-ea7fefe Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2022 License: MPL-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package types contains various structs and other types used by whatsmeow.

Index

Constants

View Source
const (
	DefaultUserServer = "s.whatsapp.net"
	GroupServer       = "g.us"
	LegacyUserServer  = "c.us"
	BroadcastServer   = "broadcast"
)

Known JID servers on WhatsApp

Variables

View Source
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 BasicCallMeta struct {
	From        JID
	Timestamp   time.Time
	CallCreator JID
	CallID      string
}

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 CallRemoteMeta struct {
	RemotePlatform string // The platform of the caller's WhatsApp client
	RemoteVersion  string // Version of the caller's WhatsApp client
}

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

type GroupAnnounce struct {
	IsAnnounce        bool
	AnnounceVersionID string
}

GroupAnnounce specifies whether only admins can send messages in the group.

type GroupEphemeral

type GroupEphemeral struct {
	IsEphemeral       bool
	DisappearingTimer uint32
}

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 GroupName

type GroupName struct {
	Name      string
	NameSetAt time.Time
	NameSetBy JID
}

GroupName contains the name of a group along with metadata of who set it and when.

type GroupParticipant

type GroupParticipant struct {
	JID          JID
	IsAdmin      bool
	IsSuperAdmin bool
}

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
}

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

type JID struct {
	User   string
	Agent  uint8
	Device uint8
	Server string
	AD     bool
}

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 NewADJID

func NewADJID(user string, agent, device uint8) JID

NewADJID creates a new AD JID.

func NewJID

func NewJID(user, server string) JID

NewJID creates a new regular JID.

func ParseJID

func ParseJID(jid string) (JID, error)

ParseJID parses a JID out of the given string. It supports both regular and AD JIDs.

func (JID) IsBroadcastList

func (jid JID) IsBroadcastList() bool

IsBroadcastList returns true if the JID is a broadcast list, but not the status broadcast.

func (JID) IsEmpty

func (jid JID) IsEmpty() bool

IsEmpty returns true if the JID has no server (which is required for all JIDs).

func (JID) MarshalText

func (jid JID) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler for JID

func (*JID) Scan

func (jid *JID) Scan(src interface{}) error

Scan scans the given SQL value into this JID.

func (JID) SignalAddress

func (jid JID) SignalAddress() *signalProtocol.SignalAddress

SignalAddress returns the Signal protocol address for the user.

func (JID) String

func (jid JID) String() 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

func (jid JID) ToNonAD() JID

ToNonAD returns a version of the JID struct that doesn't have the agent and device set.

func (*JID) UnmarshalText

func (jid *JID) UnmarshalText(val []byte) error

UnmarshalText implements encoding.TextUnmarshaler for JID

func (JID) UserInt

func (jid JID) UserInt() uint64

UserInt returns the user as an integer. This is only safe to run on normal users, not on groups or broadcast lists.

func (JID) Value

func (jid JID) Value() (driver.Value, error)

Value returns the string representation of the JID as a value that the SQL package can use.

type LocalChatSettings

type LocalChatSettings struct {
	Found bool

	MutedUntil time.Time
	Pinned     bool
	Archived   bool
}

LocalChatSettings contains the cached local settings for a chat.

type MessageID

type MessageID = string

MessageID is the internal ID of a WhatsApp message.

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 Presence

type Presence string
const (
	PresenceAvailable   Presence = "available"
	PresenceUnavailable Presence = "unavailable"
)

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.

Directories

Path Synopsis
Package events contains all the events that whatsmeow.Client emits to functions registered with AddEventHandler.
Package events contains all the events that whatsmeow.Client emits to functions registered with AddEventHandler.

Jump to

Keyboard shortcuts

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