whatsauth

package module
v0.0.83 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2023 License: MIT Imports: 8 Imported by: 91

README

whatsauth

golang websocket package for whatsapp authentication

Usage

go get github.com/whatsauth/whatsauth
package controller

import (
 "encoding/json"
 "fmt"
 "strconv"

 "github.com/gin-gonic/gin"
 "github.com/whatsauth/whatsauth"
)

func WsWhatsAuthQR(c *gin.Context) {
 roomid:=whatsauth.ServeWs(c.Writer, c.Request)
}

func PostWhatsAuthRequest(c *gin.Context) {
  var req whatsauth.WhatsauthRequest
  c.BindJSON(&req)
  status := whatsauth.SendStructTo(req.Uuid, infologin)
  c.JSON(200, status)
}

Tagging

develop and publish new version of whatsauth

git tag v0.0.1
git push origin --tags
go list -m github.com/whatsauth/whatsauth@v0.0.1

Environment

Setting up environment

GOPROXY=proxy.golang.org

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Clients = make(map[string]*websocket.Conn) // Note: although large maps with pointer-like types (e.g. strings) as keys are slow, using pointers themselves as keys is acceptable and fast
View Source
var Register = make(chan Client) // Register channel for Client Struct
View Source
var SendMesssage = make(chan Message)
View Source
var Unregister = make(chan string)

Functions

func EventReadSocket added in v0.0.83

func EventReadSocket(roomId string, PublicKey string, usertables []LoginInfo, db *sql.DB)

func GenerateButtonMessage added in v0.0.83

func GenerateButtonMessage(header string, content string, footer string) (btnmsg atmodel.ButtonsMessage)

func GenerateButtonMessageCustom added in v0.0.83

func GenerateButtonMessageCustom(
	uuid string,
	header string,
	content string,
	footer string,
	button []string,
) (btnmsg atmodel.ButtonsMessage)

func GetHashPasswordfromUsername added in v0.0.9

func GetHashPasswordfromUsername(username string, usertables []LoginInfo, db *sql.DB) (hashpassword string)

func GetListUsernamefromPhonenumber added in v0.0.83

func GetListUsernamefromPhonenumber(phone_number string, usertables []LoginInfo, db *sql.DB) (usernames []string)

func GetUserIdfromUsername added in v0.0.9

func GetUserIdfromUsername(username string, usertables []LoginInfo, db *sql.DB) (userid string)

func GetUsernamefromPhonenumber added in v0.0.9

func GetUsernamefromPhonenumber(phone_number string, usertables []LoginInfo, db *sql.DB) (username string)

func RunHub added in v0.0.83

func RunHub()

func RunModule added in v0.0.83

func RunModule(req WhatsauthRequest, PrivateKey string, usertables []LoginInfo, db *sql.DB) atmodel.NotifButton

func RunSocket added in v0.0.83

func RunSocket(c *websocket.Conn, PublicKey string, usertables []LoginInfo, db *sql.DB) (Id string)

func RunWithUsernames added in v0.0.83

func RunWithUsernames(req WhatsauthRequest, PrivateKey string, usertables []LoginInfo, db *sql.DB) atmodel.NotifButton

func SelectedRoles added in v0.0.83

func SelectedRoles(
	req WhatsAuthRoles,
	PrivateKey string,
	usertables []LoginInfo,
	db *sql.DB,
) (notifbtn atmodel.NotifButton)

func SendMessageTo

func SendMessageTo(ID string, msg string) (res bool)

func SendStructTo added in v0.0.5

func SendStructTo(ID string, strc interface{}) (res bool)

func UpdatePasswordfromUsername added in v0.0.9

func UpdatePasswordfromUsername(username string, usertables []LoginInfo, db *sql.DB) (newPassword string)

Types

type Client added in v0.0.83

type Client struct {
	Id   string
	Conn *websocket.Conn

} // Register Conn socket with ID

type LoginInfo added in v0.0.7

type LoginInfo struct {
	Userid   string `json:"user_id,omitempty" bson:"user_id,omitempty"`
	Username string `json:"user_name,omitempty" bson:"user_name,omitempty"`
	Password string `json:"user_pass,omitempty" bson:"user_pass,omitempty"`
	Phone    string `json:"phone,omitempty" bson:"phone,omitempty"`
	Login    string `json:"login,omitempty" bson:"login,omitempty"`
	Uuid     string `json:"uuid,omitempty" bson:"uuid,omitempty"`
}

func GetLoginInfofromPhoneNumber added in v0.0.9

func GetLoginInfofromPhoneNumber(phonenumber string, usertables []LoginInfo, db *sql.DB) (response LoginInfo)

func GetRolesByPhonenumber added in v0.0.83

func GetRolesByPhonenumber(
	phoneNumber string,
	userRoles string,
	usertables []LoginInfo,
	db *sql.DB,
) (loginInfo LoginInfo)

type Message added in v0.0.83

type Message struct {
	Id      string
	Message string

} // To send message to Id

type WhatsAuthRoles added in v0.0.83

type WhatsAuthRoles struct {
	Uuid        string `json:"uuid,omitempty" bson:"uuid,omitempty"`
	Phonenumber string `json:"phonenumber,omitempty" bson:"phonenumber,omitempty"`
	Roles       string `json:"roles,omitempty" bson:"roles,omitempty"`
}

type Whatsauth added in v0.0.83

type Whatsauth struct {
	Uuid string `json:"uuid"`
}

type WhatsauthMessage added in v0.0.7

type WhatsauthMessage struct {
	Id      string    `json:"id,omitempty" bson:"id,omitempty"`
	Message LoginInfo `json:"message,omitempty" bson:"message,omitempty"`
}

type WhatsauthRequest added in v0.0.7

type WhatsauthRequest struct {
	Uuid        string `json:"uuid,omitempty" bson:"uuid,omitempty"`
	Phonenumber string `json:"phonenumber,omitempty" bson:"phonenumber,omitempty"`
	Delay       uint32 `json:"delay,omitempty" bson:"delay,omitempty"`
}

type WhatsauthStatus added in v0.0.7

type WhatsauthStatus struct {
	Status string `json:"status,omitempty" bson:"status,omitempty"`
}

Jump to

Keyboard shortcuts

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