8000 fix some spelling problems by staskobzar · Pull Request #3 · staskobzar/goagi · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix some spelling problems #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@



Simple library that helps to build AGI sctipts or FastAGI servers with Go.
Simple library that helps to build AGI scripts or FastAGI servers with Go.
```go
import "github.com/staskobzar/goagi"
```
Expand All @@ -21,7 +21,7 @@ API documentation [link is here](docs/api.md).
AGI object is created with ```New``` [method](docs/api.md#func-new) with three arguments:
- Reader [interface](docs/api.md#type-reader)
- Writer [interface](docs/api.md#type-response)
- Debuger [interface](docs/api.md#type-debugger)
- Debugger [interface](docs/api.md#type-debugger)

Debugger interface is required only for debugging and usually ```nil```. See below for more details.

Expand Down
7 changes: 6 additions & 1 deletion agi.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ Parameters:
- Writer that implements Write method

- Debugger that allows to deep library debugging. Nil for production.

*/
func New(r Reader, w Writer, dbg Debugger) (*AGI, error) {
agi := &AGI{
Expand All @@ -81,6 +80,11 @@ func New(r Reader, w Writer, dbg Debugger) (*AGI, error) {
return agi, nil
}

func (agi *AGI) Close() {
agi.env = nil
agi.arg = nil
}

// Env returns AGI environment variable by key
func (agi *AGI) Env(key string) string {
agi.dbg("[>] Env for %q", key)
Expand Down Expand Up @@ -149,6 +153,7 @@ func (agi *AGI) read() (resp string, code int, err error) {
resp = builder.String()
if codeMatch, ok := matchCode(line); ok {
code = codeMatch
builder.Reset()
return
}

Expand Down
18 changes: 11 additions & 7 deletions command.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ func (agi *AGI) Answer() (Response, error) {
}

// AsyncAGIBreak Interrupts Async AGI
//
// Interrupts expected flow of Async AGI commands and returns control
//
// to previous source (typically, the PBX dialplan).
func (agi *AGI) AsyncAGIBreak() (Response, error) {
return agi.execute("ASYNCAGI BREAK\n")
Expand Down Expand Up @@ -62,7 +64,6 @@ Example:
agi.ControlStreamFile("prompt_en", "19", "3000", "#", "0", "#", "1600")
agi.ControlStreamFile("prompt_en", "")
agi.ControlStreamFile("prompt_en", "19", "", "", "", "#", "1600")

*/
func (agi *AGI) ControlStreamFile(filename, digits string, args ...string) (Response, error) {
cmd := fmt.Sprintf("CONTROL STREAM FILE %s %q", filename, digits)
Expand All @@ -80,6 +81,7 @@ func (agi *AGI) ControlStreamFile(filename, digits string, args ...string) (Resp
}

// DatabaseDel deletes an entry in the Asterisk database for a given family and key.
//
// Returns status and error if fails.
func (agi *AGI) DatabaseDel(family, key string) (Response, error) {
cmd := fmt.Sprintf("DATABASE DEL %s %s\n", family, key)
Expand All @@ -93,8 +95,9 @@ func (agi *AGI) DatabaseDelTree(family, keytree string) (Response, error) {
}

// DatabaseGet Retrieves an entry in the Asterisk database for a given family and key.
// Returns value as string or error if failed or value not set
// Response.Value() for result
//
// Returns value as string or error if failed or value not set
// Response.Value() for result
func (agi *AGI) DatabaseGet(family, key string) (Response, error) {
cmd := fmt.Sprintf("DATABASE GET %s %s\n", family, key)
return agi.execute(cmd)
Expand All @@ -115,7 +118,7 @@ func (agi *AGI) Exec(app, opts string) (Response, error) {

/*
GetData Stream the given file, and receive DTMF data.
Note: when timeout is 0 then Asterisk will use 6 secods.
Note: when timeout is 0 then Asterisk will use 6 seconds.
Note: Asterisk has strange way to handle get data response.
Contrary to other responses, where result has numeric value,
here asterisk puts DTMF to sent by user to result and this value
Expand Down Expand Up @@ -155,6 +158,7 @@ func (agi *AGI) GetFullVariable(name, channel string) (Response, error) {
}

// GetOption Stream file, prompt for DTMF, with timeout.
//
// Behaves similar to STREAM FILE but used with a timeout option.
// Returns digit pressed, offset and error
func (agi *AGI) GetOption(filename, digits string, timeout int32) (Response, error) {
Expand Down Expand Up @@ -220,7 +224,7 @@ despite the lack of dtmf digits or reaching timeout.
silence is the number of seconds of silence that are permitted before the
recording is terminated, regardless of the escape_digits or timeout arguments

If interupted by DTMF, digits will be available in Response.Data()
If interrupted by DTMF, digits will be available in Response.Data()
*/
func (agi *AGI) RecordFile(file, format, escDigits string,
timeout, offset int, beep bool, silence int) (Response, error) {
Expand Down Expand Up @@ -256,8 +260,8 @@ func (agi *AGI) RecordFile(file, format, escDigits string,

// SayAlpha says a given character string, returning early if any of the given
// DTMF digits are received on the channel.
func (agi *AGI) SayAlpha(number, escDigits string) (Response, error) {
cmd := fmt.Sprintf("SAY ALPHA %s %q\n", number, escDigits)
func (agi *AGI) SayAlpha(line, escDigits string) (Response, error) {
cmd := fmt.Sprintf("SAY ALPHA %s %q\n", line, escDigits)
return agi.execute(cmd)
}

Expand Down
10 changes: 5 additions & 5 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import "github.com/staskobzar/goagi"
- [func (agi *AGI) ReceiveText(timeout int) (Response, error)](<#func-agi-receivetext>)
- [func (agi *AGI) RecordFile(file, format, escDigits string,
timeout, offset int, beep bool, silence int) (Response, error)](<#func-agi-recordfile>)
- [func (agi *AGI) SayAlpha(number, escDigits string) (Response, error)](<#func-agi-sayalpha>)
- [func (agi *AGI) SayAlpha(line, escDigits string) (Response, error)](<#func-agi-sayalpha>)
- [func (agi *AGI) SayDate(date, escDigits string) (Response, error)](<#func-agi-saydate>)
- [func (agi *AGI) SayDatetime(time, escDigits, format, timezone string) (Response, error)](<#func-agi-saydatetime>)
- [func (agi *AGI) SayDigits(number, escDigits string) (Response, error)](<#func-agi-saydigits>)
Expand Down Expand Up @@ -226,7 +226,7 @@ Exec executes application with given options\.
func (agi *AGI) GetData(file string, timeout, maxdigit int) (Response, error)
```

GetData Stream the given file\, and receive DTMF data\. Note: when timeout is 0 then Asterisk will use 6 secods\. Note: Asterisk has strange way to handle get data response\. Contrary to other responses\, where result has numeric value\, here asterisk puts DTMF to sent by user to result and this value may contain "\#" and "\*"\.
GetData Stream the given file\, and receive DTMF data\. Note: when timeout is 0 then Asterisk will use 6 seconds\. Note: Asterisk has strange way to handle get data response\. Contrary to other responses\, where result has numeric value\, here asterisk puts DTMF to sent by user to result and this value may contain "\#" and "\*"\.

To get DTMF sent by user use Response\.Data\(\)

Expand Down Expand Up @@ -311,12 +311,12 @@ silence is the number of seconds of silence allowed before the function returns

silence is the number of seconds of silence that are permitted before the recording is terminated\, regardless of the escape\_digits or timeout arguments

If interupted by DTMF\, digits will be available in Response\.Data\(\)
If interrupted by DTMF\, digits will be available in Response\.Data\(\)

### func \(\*AGI\) [SayAlpha](<https://github.com/staskobzar/goagi/blob/master/command.go#L259>)

```go
func (agi *AGI) SayAlpha(number, escDigits string) (Response, error)
func (agi *AGI) SayAlpha(line, escDigits string) (Response, error)
```

SayAlpha says a given character string\, returning early if any of the given DTMF digits are received on the channel\.
Expand Down Expand Up @@ -501,7 +501,7 @@ type Error struct {
func (e *Error) Error() string
```

Error messge for the Error object
Error message for the Error object

### func \(\*Error\) [Msg](<https://github.com/staskobzar/goagi/blob/master/error.go#L16>)

Expand Down
2 changes: 1 addition & 1 deletion error.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func (e *Error) Msg(msg string, args ...interface{}) error {
return e
}

// Error messge for the Error object
// Error message for the Error object
func (e *Error) Error() string {
return fmt.Sprintf("%s: %s", e.s, e.e)
}
0