whatsapp

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUnsupportedMessageType = errors.New("got unsupported message type")

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client represents a whatsapp connection wrapper.

func NewClient

func NewClient(wc *whatsapp.Conn) *Client

NewClient returns new instance of Client.

func (*Client) GetContacts

func (c *Client) GetContacts() map[string]domain.WhatsappContact

GetContacts method returns a list of whatsapp contacts.

func (*Client) Logout added in v0.2.0

func (c *Client) Logout() error

Logout method invalidates the current whatsapp session.

func (*Client) Restore

func (c *Client) Restore() error

Restore method restores the current whatsapp session.

func (*Client) Send

func (c *Client) Send(msg domain.WhatsappMessage) (err error)

Send method sends data via whatsapp client.

type EventsProvider

type EventsProvider struct {
	// contains filtered or unexported fields
}

EventsProvider represents whatsapp events provider.

func NewEventsProvider

func NewEventsProvider(log *zap.Logger, opts *Opts) *EventsProvider

NewEventsProvider creates new instance of EventsProvider.

func (*EventsProvider) HandleError

func (wh *EventsProvider) HandleError(err error)

HandleError method is called when error occurs.

func (*EventsProvider) HandleTextMessage

func (wh *EventsProvider) HandleTextMessage(message whatsapp.TextMessage)

HandleTextMessage method is called when new text message is received.

func (*EventsProvider) ShouldCallSynchronously

func (wh *EventsProvider) ShouldCallSynchronously() bool

ShouldCallSynchronously method indicates how whatsapp events should be handled.

type Opts

type Opts struct {
	// ChatID is identifier of telegram chat.
	ChatID int64

	// OutgoingEvents is a channel to send events to.
	OutgoingEvents chan domain.Event

	// WhatsappClient represents a client to work with whatsapp API.
	WhatsappClient domain.WhatsappClient
}

Opts represents options to create new instance of EventsProvider.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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