wawebhook

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2023 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IncomingMessage = "INCOMING_MESSAGE"
	OutgoingMessage = "OUTGOING_MESSAGE"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BotClientList

type BotClientList map[string]*WaBot

BotClientList defines the variable to store WaBot objects

type ReplyMessage

type ReplyMessage struct {
	Message string
}

type WaBot

type WaBot struct {
	Client         *whatsmeow.Client
	Log            *logger.Logger
	HttpClient     *http.Client
	EventHandlerID uint32
	Phone          string
	WebhookUrl     string
	EchoMsg        bool
	WHookEnabled   bool
}

WaBot defines the bot client

func LoginExistingWASession

func LoginExistingWASession(httpClient *http.Client, webhookUrl string, container *sqlstore.Container,
	log *logger.Logger, jidStr, phone string, echoMsg, wHookEnabled bool) (*WaBot, error)

LoginExistingWASession logins with an existing session on the database

func NewWhatsappClient

func NewWhatsappClient(httpClient *http.Client, webhookUrl string, container *sqlstore.Container, log *logger.Logger,
	phone, fileDir string, echoMsg, wHookEnabled bool) (*WaBot, error)

NewWhatsappClient initializes Whatsapp client

func (*WaBot) Register

func (wb *WaBot) Register()

Register registers a new event handler

func (*WaBot) SendMsg

func (wb *WaBot) SendMsg(recipient types.JID, msg string) error

SendMsg sends message to designated whatsapp number

func (*WaBot) ValidateAndGetRecipient

func (wb *WaBot) ValidateAndGetRecipient(phone string, ignoreInContactList bool) (*types.JID, error)

ValidateAndGetRecipient validates the phone number

type WaManager

type WaManager struct {
	Container *sqlstore.Container
	Log       *logger.Logger
}

WaManager defines the whatsapp container

func NewContainer

func NewContainer(dbName string, log *logger.Logger) (*WaManager, error)

NewContainer builds whatsapp Container

type WebhookBody

type WebhookBody struct {
	PhoneOwner   string `json:"phone_owner"`
	EventType    string `json:"event_type"`
	MsgId        string `json:"msg_id"`
	MsgType      string `json:"msg_type"`
	Phone        string `json:"phone"`
	Name         string `json:"name"`
	Message      string `json:"message"`
	TargetJID    string `json:"target_jid"`
	TargetDevice string `json:"target_device"`
	Timestamp    string `json:"timestamp"`
}

Jump to

Keyboard shortcuts

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