wa

package module
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2023 License: MIT Imports: 21 Imported by: 88

README

wa

WhatsApp Handler Helper

go get -u all     #update existing package
go mod tidy     #generate go mod
git tag                                  #check current version
git tag v0.0.3                           #set tag version
git push origin --tags                   #push tag version to repo
go list -m github.com/whatsauth/wa@v0.0.3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConnectClient added in v0.2.1

func ConnectClient(client *whatsmeow.Client) error

func CreateContainerDB added in v0.0.3

func CreateContainerDB(pgstring string) (container *sqlstore.Container, err error)

func DefaultID added in v0.3.4

func DefaultID(client *WaClient) string

func FindByPhoneNum added in v0.3.7

func FindByPhoneNum(phonenumber string, clients GetStoreClient, mongoconn *mongo.Database) (idMap string, err error)

func GetDeviceIDFromContainer added in v0.0.8

func GetDeviceIDFromContainer(phonenumber string, container *sqlstore.Container) (deviceid uint16, err error)

func GetDeviceStoreFromContainer added in v0.2.1

func GetDeviceStoreFromContainer(phonenumber string, container *sqlstore.Container) (device *store.Device, err error)

func HandlingMessage

func HandlingMessage(Info *types.MessageInfo, Message *waProto.Message, client *WaClient)

func PairConnect

func PairConnect(client *WaClient, qr chan QRStatus)

func PairConnectStore added in v0.3.4

func PairConnectStore(client *WaClient, storeMap GetStoreClient, qr chan QRStatus)

func PairConnectStoreMap added in v0.4.0

func PairConnectStoreMap(client *WaClient, storeMap GetStoreClient, qr chan QRStatus)

func QRConnect

func QRConnect(client *WaClient, qr chan QRStatus)

func ResetDeviceStore added in v0.0.4

func ResetDeviceStore(mongoconn *mongo.Database, client *WaClient, container *sqlstore.Container) (err error)

func SendTextMessage

func SendTextMessage(txt TextMessage, whatsapp *whatsmeow.Client) (resp whatsmeow.SendResponse, err error)

func WithPhoneNumber

func WithPhoneNumber(phonenumber string, clients []*WaClient, mongoconn *mongo.Database) (idx int, err error)

Types

type Clients added in v0.2.7

type Clients struct {
	List []*WaClient
}

type GetClient added in v0.3.5

type GetClient interface {
	GetClient(id string) (client *WaClient, ok bool)
}

type GetStoreClient added in v0.3.5

type GetStoreClient interface {
	StoreClient
	GetClient
}

type MapClient added in v0.3.0

type MapClient struct {
	*xsync.MapOf[string, *WaClient]
}

func NewMapClient added in v0.3.3

func NewMapClient(size ...int) MapClient

func (*MapClient) CheckClientOnline added in v0.3.0

func (m *MapClient) CheckClientOnline(id string) (ok bool)

func (*MapClient) GetAllClient added in v0.3.0

func (m *MapClient) GetAllClient() (listCli []*WaClient)

func (*MapClient) GetClient added in v0.3.0

func (m *MapClient) GetClient(id string) (client *WaClient, ok bool)

func (*MapClient) OfflineClient added in v0.3.1

func (m *MapClient) OfflineClient() (res []string)

func (*MapClient) SetOnlineClient added in v0.3.0

func (m *MapClient) SetOnlineClient(id string) (ok bool)

func (*MapClient) StatusAllClient added in v0.3.1

func (m *MapClient) StatusAllClient() (res map[string]bool)

func (*MapClient) StoreAllClient added in v0.3.0

func (m *MapClient) StoreAllClient(listClient []*WaClient) (ok bool)

func (*MapClient) StoreAllClientCustomId added in v0.3.5

func (m *MapClient) StoreAllClientCustomId(listClient []*WaClient, f func(*WaClient) string) (ok bool)

func (*MapClient) StoreClient added in v0.3.0

func (m *MapClient) StoreClient(id string, client *WaClient)

func (*MapClient) StoreOnlineClient added in v0.3.0

func (m *MapClient) StoreOnlineClient(id string, client *WaClient) (ok bool)

type QRStatus

type QRStatus struct {
	PhoneNumber string `json:"phonenumber"`
	Status      bool   `json:"status"`
	Code        string `json:"code"`
	Message     string `json:"message"`
}

func RePairConnect added in v0.4.0

func RePairConnect(client *WaClient) (qr QRStatus, err error)

type StoreClient added in v0.3.4

type StoreClient interface {
	StoreClient(id string, client *WaClient)
	StoreOnlineClient(id string, client *WaClient) (ok bool)
}

type TextMessage

type TextMessage struct {
	To       string `json:"to"`
	IsGroup  bool   `json:"isgroup,omitempty"`
	Messages string `json:"messages"`
}

type User

type User struct {
	PhoneNumber string  `bson:"phonenumber" json:"phonenumber"`
	DeviceID    uint16  `bson:"deviceid" json:"deviceid"`
	WebHook     WebHook `bson:"webhook" json:"webhook"`
	Mongostring string  `bson:"mongostring" json:"mongostring"`
	Token       string  `bson:"token" json:"token"`
}

type WaClient

type WaClient struct {
	PhoneNumber string
	WAClient    *whatsmeow.Client

	Mongoconn *mongo.Database
	// contains filtered or unexported fields
}

func ConnectAllClient

func ConnectAllClient(mongoconn *mongo.Database, container *sqlstore.Container) (clients []*WaClient, err error)

func CreateClientfromContainer added in v0.0.8

func CreateClientfromContainer(phonenumber string, mongoconn *mongo.Database, container *sqlstore.Container) (client *WaClient, err error)

func GetWaClient

func GetWaClient(phonenumber string, client []*WaClient, mongoconn *mongo.Database, container *sqlstore.Container) (waclient *WaClient, err error)

func GetWaClientMap added in v0.3.7

func GetWaClientMap(phonenumber string, client GetStoreClient, mongoconn *mongo.Database, container *sqlstore.Container) (waclient *WaClient, err error)

func SetWaClient added in v0.2.7

func SetWaClient(phonenumber string, client *Clients, mongoconn *mongo.Database, container *sqlstore.Container) (waclient *WaClient, err error)

func (*WaClient) EventHandler

func (mycli *WaClient) EventHandler(evt interface{})

type WebHook

type WebHook struct {
	URL    string `bson:"url" json:"url"`
	Secret string `bson:"secret" json:"secret"`
}

Jump to

Keyboard shortcuts

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