Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
alvagi
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
alvagi
Commits
ec81511f
Commit
ec81511f
authored
Feb 17, 2015
by
sergey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add set- and say- functions
parent
e0d0fa50
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
123 additions
and
13 deletions
+123
-13
context.js
lib/context.js
+47
-7
index.js
test/index.js
+76
-6
No files found.
lib/context.js
View file @
ec81511f
...
@@ -109,6 +109,30 @@ Context.prototype.getFullVariable = function (variable, channel, cb) {
...
@@ -109,6 +109,30 @@ Context.prototype.getFullVariable = function (variable, channel, cb) {
this
.
send
(
'
GET FULL VARIABLE
'
+
variable
+
'
'
+
channel
+
'
\n
'
,
cb
||
function
()
{
});
this
.
send
(
'
GET FULL VARIABLE
'
+
variable
+
'
'
+
channel
+
'
\n
'
,
cb
||
function
()
{
});
};
};
Context
.
prototype
.
setAutoHangup
=
function
(
seconds
,
cb
)
{
this
.
send
(
'
SET AUTOHANGUP
'
+
seconds
+
'
\n
'
,
cb
||
function
()
{
});
};
Context
.
prototype
.
setCallerID
=
function
(
number
,
cb
)
{
this
.
send
(
'
SET CALLERID
'
+
number
+
'
\n
'
,
cb
||
function
()
{
});
};
Context
.
prototype
.
setContext
=
function
(
context
,
cb
)
{
this
.
send
(
'
SET CONTEXT
'
+
context
+
'
\n
'
,
cb
||
function
()
{
});
};
Context
.
prototype
.
setExtension
=
function
(
extension
,
cb
)
{
this
.
send
(
'
SET EXTENSION
'
+
extension
+
'
\n
'
,
cb
||
function
()
{
});
};
Context
.
prototype
.
setPriority
=
function
(
priority
,
cb
)
{
this
.
send
(
'
SET PRIORITY
'
+
priority
+
'
\n
'
,
cb
||
function
()
{
});
};
Context
.
prototype
.
setMusic
=
function
(
musicclass
,
cb
)
{
this
.
send
(
'
SET MUSIC
'
+
musicclass
+
'
\n
'
,
cb
||
function
()
{
});
};
Context
.
prototype
.
setVariable
=
function
(
name
,
value
,
cb
)
{
Context
.
prototype
.
setVariable
=
function
(
name
,
value
,
cb
)
{
this
.
send
(
'
SET VARIABLE
'
+
name
+
'
'
+
value
+
'
\n
'
,
cb
||
function
()
{
});
this
.
send
(
'
SET VARIABLE
'
+
name
+
'
'
+
value
+
'
\n
'
,
cb
||
function
()
{
});
};
};
...
@@ -132,19 +156,35 @@ Context.prototype.recordFile = function (filename, format, escape_digits, timeou
...
@@ -132,19 +156,35 @@ Context.prototype.recordFile = function (filename, format, escape_digits, timeou
this
.
send
(
'
RECORD FILE
'
+
str
+
'
\n
'
,
cb
||
function
()
{
});
this
.
send
(
'
RECORD FILE
'
+
str
+
'
\n
'
,
cb
||
function
()
{
});
};
};
Context
.
prototype
.
sayNumber
=
function
(
number
,
escape_digits
,
cb
)
{
Context
.
prototype
.
sayNumber
=
function
(
number
,
escape_digits
,
cb
)
{
this
.
send
(
'
SAY NUMBER
'
+
number
+
'
"
'
+
escape_digits
+
'
"
'
+
'
\n
'
,
cb
||
function
()
{
});
this
.
send
(
'
SAY NUMBER
'
+
number
+
'
"
'
+
escape_digits
+
'
"
'
+
'
\n
'
,
cb
||
function
()
{
});
};
};
Context
.
prototype
.
sayDigits
=
function
(
digits
,
escape_digits
,
cb
)
{
Context
.
prototype
.
sayAlpha
=
function
(
number
,
escape_digits
,
cb
)
{
this
.
send
(
'
SAY ALPHA
'
+
number
+
'
"
'
+
escape_digits
+
'
"
'
+
'
\n
'
,
cb
||
function
()
{
});
};
Context
.
prototype
.
sayDate
=
function
(
seconds
,
escape_digits
,
cb
)
{
//seconds since 1.01.1970
this
.
send
(
'
SAY DATE
'
+
seconds
+
'
"
'
+
escape_digits
+
'
"
'
+
'
\n
'
,
cb
||
function
()
{
});
};
Context
.
prototype
.
sayTime
=
function
(
seconds
,
escape_digits
,
cb
)
{
//seconds since 1.01.1970
this
.
send
(
'
SAY TIME
'
+
seconds
+
'
"
'
+
escape_digits
+
'
"
'
+
'
\n
'
,
cb
||
function
()
{
});
};
Context
.
prototype
.
sayDateTime
=
function
(
seconds
,
escape_digits
,
format
,
timezone
,
cb
)
{
//seconds since 1.01.1970
this
.
send
(
'
SAY DATETIME
'
+
seconds
+
'
"
'
+
escape_digits
+
'
"
'
+
format
+
'
'
+
timezone
+
'
\n
'
,
cb
||
function
()
{
});
};
Context
.
prototype
.
sayDigits
=
function
(
digits
,
escape_digits
,
cb
)
{
this
.
send
(
'
SAY DIGITS
'
+
digits
+
'
"
'
+
escape_digits
+
'
"
'
+
'
\n
'
,
cb
||
function
()
{
});
this
.
send
(
'
SAY DIGITS
'
+
digits
+
'
"
'
+
escape_digits
+
'
"
'
+
'
\n
'
,
cb
||
function
()
{
});
};
};
Context
.
prototype
.
sayPhonetic
=
function
(
string
,
escape_digits
,
cb
)
{
Context
.
prototype
.
sayPhonetic
=
function
(
string
,
escape_digits
,
cb
)
{
this
.
send
(
'
SAY PHONETIC
'
+
string
+
'
"
'
+
escape_digits
+
'
"
'
+
'
\n
'
,
cb
||
function
()
{
});
this
.
send
(
'
SAY PHONETIC
'
+
string
+
'
"
'
+
escape_digits
+
'
"
'
+
'
\n
'
,
cb
||
function
()
{
});
};
};
Context
.
prototype
.
streamFile
=
function
(
filename
,
acceptDigits
,
cb
)
{
Context
.
prototype
.
streamFile
=
function
(
filename
,
acceptDigits
,
cb
)
{
if
(
typeof
acceptDigits
===
'
function
'
)
{
if
(
typeof
acceptDigits
===
'
function
'
)
{
cb
=
acceptDigits
;
cb
=
acceptDigits
;
acceptDigits
=
"
1234567890#*
"
;
acceptDigits
=
"
1234567890#*
"
;
...
@@ -152,7 +192,7 @@ Context.prototype.streamFile = function(filename, acceptDigits, cb) {
...
@@ -152,7 +192,7 @@ Context.prototype.streamFile = function(filename, acceptDigits, cb) {
this
.
send
(
'
STREAM FILE "
'
+
filename
+
'
" "
'
+
acceptDigits
+
'
"
\n
'
,
cb
);
this
.
send
(
'
STREAM FILE "
'
+
filename
+
'
" "
'
+
acceptDigits
+
'
"
\n
'
,
cb
);
};
};
Context
.
prototype
.
waitForDigit
=
function
(
timeout
,
cb
)
{
Context
.
prototype
.
waitForDigit
=
function
(
timeout
,
cb
)
{
if
(
typeof
timeout
===
'
function
'
)
{
if
(
typeof
timeout
===
'
function
'
)
{
cb
=
timeout
;
cb
=
timeout
;
//default to 2 second timeout
//default to 2 second timeout
...
@@ -161,11 +201,11 @@ Context.prototype.waitForDigit = function(timeout, cb) {
...
@@ -161,11 +201,11 @@ Context.prototype.waitForDigit = function(timeout, cb) {
this
.
send
(
'
WAIT FOR DIGIT
'
+
timeout
+
'
\n
'
,
cb
);
this
.
send
(
'
WAIT FOR DIGIT
'
+
timeout
+
'
\n
'
,
cb
);
};
};
Context
.
prototype
.
hangup
=
function
(
cb
)
{
Context
.
prototype
.
hangup
=
function
(
cb
)
{
this
.
send
(
'
HANGUP
\n
'
,
cb
);
this
.
send
(
'
HANGUP
\n
'
,
cb
);
};
};
Context
.
prototype
.
end
=
function
()
{
Context
.
prototype
.
end
=
function
()
{
this
.
stream
.
end
();
this
.
stream
.
end
();
};
};
...
...
test/index.js
View file @
ec81511f
...
@@ -153,6 +153,48 @@ describe('Context', function() {
...
@@ -153,6 +153,48 @@ describe('Context', function() {
});
});
});
});
describe
(
'
setAutoHangup
'
,
function
()
{
it
(
'
sends correct command
'
,
function
()
{
this
.
context
.
setAutoHangup
(
10
);
expect
(
this
.
context
.
sent
.
join
(
''
)).
to
.
eql
(
'
SET AUTOHANGUP 10
\n
'
);
});
});
describe
(
'
setCallerID
'
,
function
()
{
it
(
'
sends correct command
'
,
function
()
{
this
.
context
.
setCallerID
(
'
246
'
);
expect
(
this
.
context
.
sent
.
join
(
''
)).
to
.
eql
(
'
SET CALLERID 246
\n
'
);
});
});
describe
(
'
setContext
'
,
function
()
{
it
(
'
sends correct command
'
,
function
()
{
this
.
context
.
setContext
(
'
outbound
'
);
expect
(
this
.
context
.
sent
.
join
(
''
)).
to
.
eql
(
'
SET CONTEXT outbound
\n
'
);
});
});
describe
(
'
setExtension
'
,
function
()
{
it
(
'
sends correct command
'
,
function
()
{
this
.
context
.
setExtension
(
'
245
'
);
expect
(
this
.
context
.
sent
.
join
(
''
)).
to
.
eql
(
'
SET EXTENSION 245
\n
'
);
});
});
describe
(
'
setPriority
'
,
function
()
{
it
(
'
sends correct command
'
,
function
()
{
this
.
context
.
setPriority
(
'
2
'
);
expect
(
this
.
context
.
sent
.
join
(
''
)).
to
.
eql
(
'
SET PRIORITY 2
\n
'
);
});
});
describe
(
'
setMusic
'
,
function
()
{
it
(
'
sends correct command
'
,
function
()
{
this
.
context
.
setMusic
(
'
default
'
);
expect
(
this
.
context
.
sent
.
join
(
''
)).
to
.
eql
(
'
SET MUSIC default
\n
'
);
});
});
describe
(
'
channelStatus
'
,
function
()
{
describe
(
'
channelStatus
'
,
function
()
{
it
(
'
sends correct command
'
,
function
()
{
it
(
'
sends correct command
'
,
function
()
{
this
.
context
.
channelStatus
(
'
test
'
);
this
.
context
.
channelStatus
(
'
test
'
);
...
@@ -186,7 +228,7 @@ describe('Context', function() {
...
@@ -186,7 +228,7 @@ describe('Context', function() {
});
});
describe
(
'
stream file
'
,
function
()
{
describe
(
'
stream file
'
,
function
()
{
it
(
'
sends
'
,
function
()
{
it
(
'
sends
'
,
function
()
{
this
.
context
.
streamFile
(
'
test
'
,
'
1234567890#*
'
,
function
()
{});
this
.
context
.
streamFile
(
'
test
'
,
'
1234567890#*
'
,
function
()
{});
expect
(
this
.
context
.
sent
.
join
(
''
)).
to
.
eql
(
'
STREAM FILE "test" "1234567890#*"
\n
'
);
expect
(
this
.
context
.
sent
.
join
(
''
)).
to
.
eql
(
'
STREAM FILE "test" "1234567890#*"
\n
'
);
});
});
...
@@ -199,21 +241,49 @@ describe('Context', function() {
...
@@ -199,21 +241,49 @@ describe('Context', function() {
});
});
describe
(
'
record file
'
,
function
()
{
describe
(
'
record file
'
,
function
()
{
it
(
'
record
'
,
function
()
{
it
(
'
record
'
,
function
()
{
this
.
context
.
recordFile
(
'
test
'
,
'
wav
'
,
'
#
'
,
10
,
function
()
{});
this
.
context
.
recordFile
(
'
test
'
,
'
wav
'
,
'
#
'
,
10
,
function
()
{});
expect
(
this
.
context
.
sent
.
join
(
''
)).
to
.
eql
(
'
RECORD FILE "test" wav # 10000 0 1 2
\n
'
);
expect
(
this
.
context
.
sent
.
join
(
''
)).
to
.
eql
(
'
RECORD FILE "test" wav # 10000 0 1 2
\n
'
);
});
});
});
});
describe
(
'
say number
'
,
function
()
{
describe
(
'
say number
'
,
function
()
{
it
(
'
say number
'
,
function
()
{
it
(
'
say number
'
,
function
()
{
this
.
context
.
sayNumber
(
'
1234
'
,
'
#
'
,
function
()
{});
this
.
context
.
sayNumber
(
'
1234
'
,
'
#
'
,
function
()
{});
expect
(
this
.
context
.
sent
.
join
(
''
)).
to
.
eql
(
'
SAY NUMBER 1234 "#"
\n
'
);
expect
(
this
.
context
.
sent
.
join
(
''
)).
to
.
eql
(
'
SAY NUMBER 1234 "#"
\n
'
);
});
});
});
});
describe
(
'
say alpha
'
,
function
()
{
it
(
'
say alpha
'
,
function
()
{
this
.
context
.
sayAlpha
(
'
1234
'
,
'
#
'
,
function
()
{});
expect
(
this
.
context
.
sent
.
join
(
''
)).
to
.
eql
(
'
SAY ALPHA 1234 "#"
\n
'
);
});
});
describe
(
'
say date
'
,
function
()
{
it
(
'
say date
'
,
function
()
{
this
.
context
.
sayDate
(
'
1234
'
,
'
#
'
,
function
()
{});
expect
(
this
.
context
.
sent
.
join
(
''
)).
to
.
eql
(
'
SAY DATE 1234 "#"
\n
'
);
});
});
describe
(
'
say time
'
,
function
()
{
it
(
'
say time
'
,
function
()
{
this
.
context
.
sayTime
(
'
1234
'
,
'
#
'
,
function
()
{});
expect
(
this
.
context
.
sent
.
join
(
''
)).
to
.
eql
(
'
SAY TIME 1234 "#"
\n
'
);
});
});
describe
(
'
say datetime
'
,
function
()
{
it
(
'
say datetime
'
,
function
()
{
this
.
context
.
sayDateTime
(
'
1234
'
,
'
#
'
,
'
Y
'
,
'
DST
'
,
function
()
{});
expect
(
this
.
context
.
sent
.
join
(
''
)).
to
.
eql
(
'
SAY DATETIME 1234 "#" Y DST
\n
'
);
});
});
describe
(
'
say phonetic
'
,
function
()
{
describe
(
'
say phonetic
'
,
function
()
{
it
(
'
say phonetic
'
,
function
()
{
it
(
'
say phonetic
'
,
function
()
{
this
.
context
.
sayPhonetic
(
'
1234ABCD
'
,
'
#
'
,
function
()
{});
this
.
context
.
sayPhonetic
(
'
1234ABCD
'
,
'
#
'
,
function
()
{});
expect
(
this
.
context
.
sent
.
join
(
''
)).
to
.
eql
(
'
SAY PHONETIC 1234ABCD "#"
\n
'
);
expect
(
this
.
context
.
sent
.
join
(
''
)).
to
.
eql
(
'
SAY PHONETIC 1234ABCD "#"
\n
'
);
});
});
...
@@ -227,13 +297,13 @@ describe('Context', function() {
...
@@ -227,13 +297,13 @@ describe('Context', function() {
});
});
describe
(
'
say digits
'
,
function
()
{
describe
(
'
say digits
'
,
function
()
{
it
(
'
say digits
'
,
function
()
{
it
(
'
say digits
'
,
function
()
{
this
.
context
.
sayDigits
(
'
1234
'
,
'
#
'
,
function
()
{});
this
.
context
.
sayDigits
(
'
1234
'
,
'
#
'
,
function
()
{});
expect
(
this
.
context
.
sent
.
join
(
''
)).
to
.
eql
(
'
SAY DIGITS 1234 "#"
\n
'
);
expect
(
this
.
context
.
sent
.
join
(
''
)).
to
.
eql
(
'
SAY DIGITS 1234 "#"
\n
'
);
});
});
});
});
describe
(
'
waitForDigit
'
,
function
()
{
describe
(
'
waitForDigit
'
,
function
()
{
it
(
'
sends with default timeout
'
,
function
()
{
it
(
'
sends with default timeout
'
,
function
()
{
this
.
context
.
waitForDigit
(
function
()
{});
this
.
context
.
waitForDigit
(
function
()
{});
expect
(
this
.
context
.
sent
.
join
(
''
)).
to
.
eql
(
'
WAIT FOR DIGIT 5000
\n
'
);
expect
(
this
.
context
.
sent
.
join
(
''
)).
to
.
eql
(
'
WAIT FOR DIGIT 5000
\n
'
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment