send

package
v0.0.21 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ShortDesc defines a map for all the short description
	// of the available commands
	ShortDesc = map[string]string{
		"text":     i18n.T("Send a text message"),
		"image":    i18n.T("Send an image file"),
		"document": i18n.T("Send a document"),
		"audio":    i18n.T("Send an audio file"),
		"video":    i18n.T("Send a video file"),
	}
	// LongDesc defines a map for all the Long description
	// of the available commands which explain the function
	// of each of the subcommand
	LongDesc = map[string]string{
		"text": templates.LongDesc(i18n.T(`
			Send a text message
			
			send allows you to send a text message to a user,  it sends the message
			to the whatsapp infrastructure from there a job will be created which
			will take care of sending the message to the user
		`)),
		"image": templates.LongDesc(i18n.T(`
			Send an image file
			
			send a jpeg or a png file to the user, you need to provide the path to the file
			or you can directly give the url, from there it will read and uploaded it to the
			whatsapp infra, after that it will send to the user
		`)),
		"document": templates.LongDesc(i18n.T(`
			Send an document
			
			send a document supported by whatsapp, you need to provide the path to the file 
			or you can directly give the url, from there it will read and uploaded to the
			whatsapp infra, after that it will send to the user
		`)),
		"audio": templates.LongDesc(i18n.T(`
			Send an audio file
			
			send an audio file (.mp3 or .mp4) supported by whatsapp, you need to provide the path to the file
			from there it will read and uploaded it to the whatsapp infra, after that it will 
			send to the user
		`)),
		"video": templates.LongDesc(i18n.T(`
			Send an video file
			
			send an video file .mp4, 3gp supported by whatsapp, you need to provide the path to the file
			from there it will read and uploaded it to the whatsapp infra, after that it will 
			send to the user
		`)),
	}
	// ExampleDesc defines a map for all the available commands
	// it shows the current usage of each command all the available flags
	ExampleDesc = map[string]string{
		"text": templates.Examples(i18n.T(`
			# send a text message
			wabacli send text --to 9190000000 --message <string>
		`)),
		"image": templates.Examples(i18n.T(`
			# send an video with a caption
			wabacli send image --to 9190000000 --caption[optional] <string> --path <path/to/file>
			# send an video using url
			wabacli send image --to <wa_id with country code> --caption[optional] <string> --url <image url>
		`)),
		"document": templates.Examples(i18n.T(`
			# send an video with a caption
			wabacli send document --to 9190000000 --caption[optional] <string> --path <path/to/file>
			# send an video using url
			wabacli send document --to <wa_id with country code> --caption[optional] --url <file url>
		`)),
		"audio": templates.Examples(i18n.T(`
			# send an video with a caption
			wabacli send audio --to 9190000000 --caption[optional] <string> --path <path/to/file>
			# send an video using url
			wabacli send audio --to <wa_id with country code> --caption[optional] <string> --url <image url>
		`)),
		"video": templates.Examples(i18n.T(`
			# send an video with a caption
			wabacli send video --to 9190000000 --caption[optional] <string> --path <path/to/file>
			# send an video using url
			wabacli send video --to <wa_id with country code> --caption[optional] <string> --url <image url>
		`)),
	}
)

Functions

func NewDefaultSendCmd

func NewDefaultSendCmd(c *config.Configuration) *cobra.Command

NewDefaultSendCmd returns a cobra command with all of it's child commands added to it, send command supports all the basic type of messages a user can send like text, images, video etc which are supported by whatsapp. also send command is also capable of taking json request body and directly processing the request without using it's children.

Types

type Cmd

type Cmd string

type SendOptions

type SendOptions struct {
	Config        *config.Configuration
	File          *types.Media
	Message       types.WAMessage
	Request       map[string]interface{}
	FilePath      string
	Url           string
	Json          string
	VerifyContact bool
	VerifyAsync   bool
	VerifyForced  bool
}

SendOptions groups all the basic types and data which are required to process the user request and send the message to user

func NewSendOptions

func NewSendOptions(c *config.Configuration) *SendOptions

NewSendOptions initializes the SendOptions and returns a pointer to it

func (*SendOptions) GetCmdList

func (s *SendOptions) GetCmdList() []string

GetCmdList returns an array of all the available commands which are currently supported by this cli

func (*SendOptions) GetCommand

func (s *SendOptions) GetCommand(arg string) *cobra.Command

GetCommand generates a cobra command which will be added as a child command to the send command, it also defines all the , required parameters that all the subcommands supports

func (*SendOptions) Parse

func (s *SendOptions) Parse()

Parse further verifies the request body and initiates all the required functions like file reader which will return a Media object which provides the functionality to read and store binary data of a file

func (*SendOptions) Run

func (s *SendOptions) Run()

Run executes the commands by uploading the file in case of media message and then sending the message to the user, if any error it will print

func (*SendOptions) Validate

func (s *SendOptions) Validate()

Validate will verify if any required field is empty, if the required filed is not provided it will exit.

Jump to

Keyboard shortcuts

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