agi

package
v0.0.0-...-e23add2 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2020 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Asterisk Gateway Interface support

Usage:

a := agi.NewAgi()
r := a.Answer()
checkErr(r.Err)
...
r = a.Noop("Hello New Chan")
...
r = a.SayAlpha("Hi")
...
r, status := a.ChannelStatus()
...
r.Hangup()

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Agi

type Agi struct {
	Env map[string]string // AGI environment variables
	// contains filtered or unexported fields
}

main agi struct

func NewAgi

func NewAgi() *Agi

factory function

func (*Agi) Answer

func (a *Agi) Answer() *Resp

answer channel

func (*Agi) ChannelStatus

func (a *Agi) ChannelStatus() (*Resp, int)

return channel status

func (*Agi) DBDel

func (a *Agi) DBDel(familiy, key string) *Resp

delete key from DB

func (*Agi) DBDelTree

func (a *Agi) DBDelTree(family string) *Resp

delete DB family

func (*Agi) DBGet

func (a *Agi) DBGet(family, key string) (*Resp, string)

get value from DB

func (*Agi) DBPut

func (a *Agi) DBPut(family, key, val string) *Resp

save value to DB

func (*Agi) Exec

func (a *Agi) Exec(cmd Cmd, args ...string) *Resp

basic command execute

func (*Agi) GetVariable

func (a *Agi) GetVariable(name string) (*Resp, string)

get channel variable

func (*Agi) Hangup

func (a *Agi) Hangup() *Resp

handup channel

func (*Agi) Noop

func (a *Agi) Noop(args ...string) *Resp

NOOP

func (*Agi) SayAlpha

func (a *Agi) SayAlpha(str string) *Resp

say letters

func (*Agi) SayDateTime

func (a *Agi) SayDateTime(unixtime int64, format string) *Resp

say datetime

func (*Agi) SayDigits

func (a *Agi) SayDigits(num int) *Resp

say digits

func (*Agi) SendText

func (a *Agi) SendText(text string) *Resp

send text to channel, if support

func (*Agi) SetContext

func (a *Agi) SetContext(ctx string) *Resp

set channel context

func (*Agi) SetExtension

func (a *Agi) SetExtension(ext string) *Resp

set channel extension

func (*Agi) SetPripority

func (a *Agi) SetPripority(pr string) *Resp

set channel priority for exten

func (*Agi) SetVariable

func (a *Agi) SetVariable(name, val string) *Resp

set channel variable

func (*Agi) WaitForDigit

func (a *Agi) WaitForDigit(wait int) (*Resp, int)

wait for digit on channel, timeout in ms

type Cmd

type Cmd string

AGI command

const (
	Answer        Cmd = "ANSWER"
	Noop          Cmd = "NOOP"
	Hangup        Cmd = "HANGUP"
	ChannelStatus Cmd = "CHANNEL STATUS"
	SayAlpha      Cmd = "SAY ALPHA"
	SayDigits     Cmd = "SAY DIGITS"
	SayNumber     Cmd = "SAY NUMBER"
	SayDate       Cmd = "SAY DATE"
	SayTime       Cmd = "SAY TIME"
	SayDateTime   Cmd = "SAY DATETIME"
	WaitForDigit  Cmd = "WAIT FOR DIGIT"
	GetVariable   Cmd = "GET VARIABLE"
	SetVariable   Cmd = "SET VARIABLE"
	SetCallerId   Cmd = "SET CALLERID"
	SetContext    Cmd = "SET CONTEXT"
	SetExtension  Cmd = "SET EXTENSION"
	SetPripority  Cmd = "SET PRIORITY"
	SendText      Cmd = "SEND TEXT"
	DBDel         Cmd = "DATABASE DEL"
	DBDelTree     Cmd = "DATABASE DELTREE"
	DBGet         Cmd = "DATABASE GET"
	DBPut         Cmd = "DATABASE PUT"
)

supported commands

type Resp

type Resp struct {
	Payload string // response body
	Code    int    // response code
	Err     error  // error if exist
}

response struct

func (Resp) String

func (r Resp) String() string

Jump to

Keyboard shortcuts

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