whatsmgr

package module
v0.0.0-...-648edbb Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2026 License: MIT Imports: 22 Imported by: 0

README

WhatsApp Manager

GoDoc

whatsmgr is a work in progress library that will act as a wrapper to tulir/whatsmeow to provide simple management of multiple device connections.

Acknowledgements

Thanks to the contributors of tulir/whatsmeow.

Documentation

Index

Constants

View Source
const (
	CallStatusOffer     CallStatus = "offer"
	CallStatusAccept    CallStatus = "accept"
	CallStatusPreAccept CallStatus = "pre-accept"
	CallStatusTransport CallStatus = "transport"
	CallStatusTerminate CallStatus = "terminate"
	CallStatusReject    CallStatus = "reject"

	CallMediaAudio CallMedia = "audio"
	CallMediaVideo CallMedia = "video"

	CallTypeGroup CallType = "group"
)
View Source
const (
	MessageStatusSent        MessageStatus = "sent"
	MessageStatusDelivered   MessageStatus = "delivered"
	MessageStatusRead        MessageStatus = "read"
	MessageStatusServerError MessageStatus = "server-error"

	CallLogOutcomeConnected CallLogOutcome = "connected"
	CallLogOutcomeMissed    CallLogOutcome = "missed"
	CallLogOutcomeFailed    CallLogOutcome = "failed"
	CallLogOutcomeRejected  CallLogOutcome = "rejected"
	CallLogOutcomeAccepted  CallLogOutcome = "accepted"
	CallLogOutcomeOngoing   CallLogOutcome = "ongoing"
	CallLogOutcomeSilenced  CallLogOutcome = "silenced"

	CallLogTypeRegular   CallLogType = "regular"
	CallLogTypeScheduled CallLogType = "scheduled"
	CallLogTypeVoiceChat CallLogType = "voice-chat"
)

Variables

View Source
var ErrAlreadyConnected = errors.New("already connected")

Functions

This section is empty.

Types

type Call

type Call struct {
	Timestamp   time.Time
	CallID      string `json:",omitempty"`
	From        string `json:",omitempty"`
	CallCreator string `json:",omitempty"`

	Status CallStatus `json:",omitempty"` // use CallStatus* constants

	Media *CallMedia `json:",omitempty"` // use CallMedia* constants, not always set
	Type  *CallType  `json:",omitempty"` // use CallType* constants, not always set

	TerminateReaason *string `json:",omitempty"`
}

type CallLogOutcome

type CallLogOutcome string

type CallLogType

type CallLogType string

type CallMedia

type CallMedia string

type CallStatus

type CallStatus string

type CallType

type CallType string

type Callbacks

type Callbacks struct {
	QRCode func(string)

	ConnStatus func(ConnStatus)
	Error      func(error)

	Contact func(Contact)
	Message func(Message)
	Call    func(Call)
	User    func(User)

	GetExistingProfilePhotoID func(jid string) (photoID string)
	PushNewProfilePhotoID     func(jid, photoID string)
}

type ConnStatus

type ConnStatus string
const (
	ConnStatusConnected    ConnStatus = "connected"
	ConnStatusDisconnected ConnStatus = "disconnected"
	ConnStatusQRCodeScan   ConnStatus = "qr code scan"
	ConnStatusLoggedOut    ConnStatus = "logged out"
	ConnStatusError        ConnStatus = "error"
)

type Connection

type Connection struct {
	Number    string
	DBPath    string
	MediaPath string
	Log       Logger

	Callbacks Callbacks
	// contains filtered or unexported fields
}

func (*Connection) Connect

func (conn *Connection) Connect(ctx context.Context) error

func (*Connection) Disconnect

func (conn *Connection) Disconnect()

func (*Connection) IsConnected

func (conn *Connection) IsConnected() bool

func (*Connection) IsLoggedIn

func (conn *Connection) IsLoggedIn() bool

func (*Connection) SendEdit

func (conn *Connection) SendEdit(message Message) error

func (*Connection) SendMessage

func (conn *Connection) SendMessage(message Message, sendOnCallback bool) (Message, error)

func (*Connection) SendPlayed

func (conn *Connection) SendPlayed(messageIDs []string, when time.Time, chatJID string, senderJID string) error

func (*Connection) SendRead

func (conn *Connection) SendRead(messageIDs []string, when time.Time, chatJID string, senderJID string, receiptTypeExtra ...types.ReceiptType) error

func (*Connection) SyncAllContacts

func (conn *Connection) SyncAllContacts() error

type Contact

type Contact struct {
	Timestamp *time.Time `json:",omitempty"` // not always set

	JID          string  `json:",omitempty"`
	PushName     *string `json:",omitempty"` // not always set
	ContactName  *string `json:",omitempty"` // not always set
	DisplayName  *string `json:",omitempty"` // not always set
	Username     *string `json:",omitempty"` // not always set
	ProfilePhoto *string `json:",omitempty"` // not always set

	Pinned           *bool  `json:",omitempty"` // not always set
	Muted            *bool  `json:",omitempty"` // not always set
	MuteEndTimestamp *int64 `json:",omitempty"` // not always set
	StatusMuted      *bool  `json:",omitempty"` // not always set
	Archived         *bool  `json:",omitempty"` // not always set

	Available *bool      `json:",omitempty"` // not always set
	LastSeen  *time.Time `json:",omitempty"` // not always set
	Typing    *string    `json:",omitempty"` // the JID who is typing, not always set
	Recording *string    `json:",omitempty"` // the JID who is recording, not always set

	IsGroup *bool `json:",omitempty"` // not always set

	Group
}

type Group

type Group struct {
	GroupName                    *string            `json:",omitempty"` // not always set
	GroupTopic                   *string            `json:",omitempty"` // not always set
	GroupInfoLockedToAdmins      *bool              `json:",omitempty"` // not always set
	GroupOnlyAdminCanMessage     *bool              `json:",omitempty"` // not always set
	GroupOnlyAdminsCanAddMembers *bool              `json:",omitempty"` // not always set
	GroupIsParent                *bool              `json:",omitempty"` // not always set
	GroupLinkedParentJID         *string            `json:",omitempty"` // not always set
	GroupIsDefaultSubGroup       *bool              `json:",omitempty"` // not always set
	GroupJoinApprovalRequired    *bool              `json:",omitempty"` // not always set
	GroupCreated                 *time.Time         `json:",omitempty"` // not always set
	GroupReplaceParticipants     []GroupParticipant `json:",omitempty"` // replace all existing participants with these, not always set
	GroupAddParticipants         []GroupParticipant `json:",omitempty"` // add to existing participants, not always set
	GroupRemovedParticipants     []GroupParticipant `json:",omitempty"` // remove from existing participants, not always set
	GroupInviteLink              *string            `json:",omitempty"` // not always set
}

type GroupParticipant

type GroupParticipant struct {
	UserJID string
	Rank    GroupParticipantRank
}

type GroupParticipantRank

type GroupParticipantRank string
const (
	GroupParticipantRankRegular    GroupParticipantRank = "regular"
	GroupParticipantRankAdmin      GroupParticipantRank = "admin"
	GroupParticipantRankSuperAdmin GroupParticipantRank = "superadmin"
)

type Logger

type Logger struct {
	zerolog.Logger
	Module string
}

func (*Logger) Debugf

func (l *Logger) Debugf(msg string, args ...any)

func (*Logger) Errorf

func (l *Logger) Errorf(msg string, args ...any)

func (*Logger) Infof

func (l *Logger) Infof(msg string, args ...any)

func (*Logger) Sub

func (l *Logger) Sub(module string) waLog.Logger

func (*Logger) Warnf

func (l *Logger) Warnf(msg string, args ...any)

type Message

type Message struct {
	Timestamp *time.Time `json:",omitempty"`

	MessageID string  `json:",omitempty"`
	ChatJID   string  `json:",omitempty"`
	SenderJID *string `json:",omitempty"`

	IsFromMe *bool          `json:",omitempty"`
	Type     *string        `json:",omitempty"` // not always set
	Status   *MessageStatus `json:",omitempty"` // use MessageStatus* constants, not always set

	Starred *bool `json:",omitempty"` // not always set
	Deleted *bool `json:",omitempty"` // not always set
	Edited  *bool `json:",omitempty"` // not always set

	ContentBody *string `json:",omitempty"` // not always set

	InfoQuotedMessageID *string `json:",omitempty"` // not always set
	InfoParticipant     *string `json:",omitempty"` // not always set
	InfoRemoteJID       *string `json:",omitempty"` // not always set

	Attachments []string `json:",omitempty"` // not always set

	ContactVcard       *string `json:",omitempty"` // not always set
	ContactDisplayName *string `json:",omitempty"` // not always set

	LocationLat              *float64 `json:",omitempty"` // not always set
	LocationLon              *float64 `json:",omitempty"` // not always set
	LocationName             *string  `json:",omitempty"` // not always set
	LocationAddress          *string  `json:",omitempty"` // not always set
	LocationURL              *string  `json:",omitempty"` // not always set
	LocationIsLive           *bool    `json:",omitempty"` // not always set
	LocationAccuracyInMeters *uint32  `json:",omitempty"` // not always set
	LocationComment          *string  `json:",omitempty"` // not always set

	CallLogOutcome         *CallLogOutcome `json:",omitempty"` // use CallLogOutcome* constants, not always set
	CallLogDurationSeconds *int64          `json:",omitempty"` // not always set
	CallLogType            *CallLogType    `json:",omitempty"` // use CallLogType* constants, not always set
	CallLogParticipantJIDs []string        `json:",omitempty"` // they have their own call outcomes that are not recorded, not always set

	Raw any `json:",omitempty"`
}

type MessageStatus

type MessageStatus string

type User

type User struct {
	Timestamp time.Time

	Name *string // not always set
}

Jump to

Keyboard shortcuts

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