redial-ruby-agi 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ChangeLog +44 -0
- data/LICENSE +222 -0
- data/README.md +25 -0
- data/Rakefile +20 -0
- data/VERSION +1 -0
- data/examples/call_log.rb +18 -0
- data/lib/ruby-agi.rb +5 -0
- data/lib/ruby-agi/agi.rb +891 -0
- data/lib/ruby-agi/asterisk_variable.rb +242 -0
- data/lib/ruby-agi/command.rb +911 -0
- data/lib/ruby-agi/error.rb +48 -0
- data/lib/ruby-agi/return_status.rb +31 -0
- data/lib/ruby-agi/rs/answer.rb +68 -0
- data/lib/ruby-agi/rs/channel_status.rb +127 -0
- data/lib/ruby-agi/rs/exec.rb +69 -0
- data/lib/ruby-agi/rs/get_variable.rb +76 -0
- data/lib/ruby-agi/rs/hangup.rb +76 -0
- data/lib/ruby-agi/rs/noop.rb +68 -0
- data/lib/ruby-agi/rs/receive_char.rb +112 -0
- data/lib/ruby-agi/rs/receive_text.rb +73 -0
- data/lib/ruby-agi/rs/record_file.rb +184 -0
- data/lib/ruby-agi/rs/result.rb +47 -0
- data/lib/ruby-agi/rs/return_status.rb +98 -0
- data/lib/ruby-agi/rs/say_digits.rb +85 -0
- data/lib/ruby-agi/rs/say_number.rb +88 -0
- data/lib/ruby-agi/rs/say_phonetic.rb +88 -0
- data/lib/ruby-agi/rs/say_time.rb +90 -0
- data/lib/ruby-agi/rs/send_image.rb +83 -0
- data/lib/ruby-agi/rs/send_text.rb +83 -0
- data/lib/ruby-agi/rs/set_auto_hangup.rb +69 -0
- data/lib/ruby-agi/rs/set_caller_id.rb +72 -0
- data/lib/ruby-agi/rs/set_context.rb +71 -0
- data/lib/ruby-agi/rs/set_extension.rb +72 -0
- data/lib/ruby-agi/rs/set_music.rb +71 -0
- data/lib/ruby-agi/rs/set_priority.rb +69 -0
- data/lib/ruby-agi/rs/set_variable.rb +76 -0
- data/lib/ruby-agi/rs/stream_file.rb +138 -0
- data/lib/ruby-agi/rs/tdd_mode.rb +95 -0
- data/lib/ruby-agi/rs/verbose.rb +73 -0
- data/lib/ruby-agi/rs/wait_for_digit.rb +90 -0
- data/lib/ruby-agi/rs/wait_for_digits.rb +88 -0
- data/ruby-agi.gemspec +51 -0
- data/test/unit.rb +37 -0
- metadata +94 -0
@@ -0,0 +1,98 @@
|
|
1
|
+
#
|
2
|
+
# File: return_status.rb
|
3
|
+
#
|
4
|
+
# ruby-agi: Ruby Language API for Asterisk
|
5
|
+
#
|
6
|
+
# Copyright (C) <2005> Mohammad Khan <info@beeplove.com>
|
7
|
+
#
|
8
|
+
# This program is free software; you can redistribute it and/or modify
|
9
|
+
# it under the terms of the GNU General Public License as published by
|
10
|
+
# the Free Software Foundation; either version 2 of the License, or
|
11
|
+
# (at your option) any later version.
|
12
|
+
#
|
13
|
+
# This program is distributed in the hope that it will be useful,
|
14
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16
|
+
# GNU General Public License for more details.
|
17
|
+
#
|
18
|
+
# You should have received a copy of the GNU General Public License
|
19
|
+
# along with this program; if not, write to the Free Software
|
20
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
21
|
+
#
|
22
|
+
|
23
|
+
|
24
|
+
# every method of this class would return string or boolean
|
25
|
+
# methods of command class usually return ReturnStatus object
|
26
|
+
|
27
|
+
|
28
|
+
class ReturnStatus
|
29
|
+
|
30
|
+
def initialize(command, message)
|
31
|
+
@command = command.to_s.strip
|
32
|
+
@message = message.to_s.strip
|
33
|
+
end
|
34
|
+
|
35
|
+
public
|
36
|
+
def command
|
37
|
+
return @command
|
38
|
+
end
|
39
|
+
|
40
|
+
public
|
41
|
+
def message
|
42
|
+
return @message
|
43
|
+
end
|
44
|
+
|
45
|
+
public
|
46
|
+
def return_code
|
47
|
+
if @return_code.nil?
|
48
|
+
str = message.split(' ')
|
49
|
+
@return_code = str[0].to_s.strip
|
50
|
+
end
|
51
|
+
|
52
|
+
return @return_code
|
53
|
+
end
|
54
|
+
|
55
|
+
public
|
56
|
+
def result
|
57
|
+
if @result.nil?
|
58
|
+
str = message.split(' ')
|
59
|
+
@result = str[1].split('=')[1].to_s.strip
|
60
|
+
end
|
61
|
+
|
62
|
+
return @result
|
63
|
+
end
|
64
|
+
|
65
|
+
=begin
|
66
|
+
public
|
67
|
+
def result
|
68
|
+
if @result.nil?
|
69
|
+
str = message.split(' ')
|
70
|
+
@result = Result.new(str[1].split('=')[1].to_s.strip)
|
71
|
+
end
|
72
|
+
|
73
|
+
return @result.to_s
|
74
|
+
end
|
75
|
+
=end
|
76
|
+
|
77
|
+
public
|
78
|
+
def to_s
|
79
|
+
return command + ' >> ' + message
|
80
|
+
end
|
81
|
+
|
82
|
+
public
|
83
|
+
def command_error?
|
84
|
+
if @is_command_error.nil?
|
85
|
+
if (result.empty? or (not (return_code == '200')))
|
86
|
+
@is_command_error = true
|
87
|
+
else
|
88
|
+
@is_command_error = false
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
return @is_command_error
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
96
|
+
|
97
|
+
class Answer < ReturnStatus
|
98
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
#
|
2
|
+
# File: say_digits.rb
|
3
|
+
#
|
4
|
+
# ruby-agi: Ruby Language API for Asterisk
|
5
|
+
#
|
6
|
+
# Copyright (C) <2006> Mohammad Khan <info@beeplove.com>
|
7
|
+
#
|
8
|
+
# This program is free software; you can redistribute it and/or modify
|
9
|
+
# it under the terms of the GNU General Public License as published by
|
10
|
+
# the Free Software Foundation; either version 2 of the License, or
|
11
|
+
# (at your option) any later version.
|
12
|
+
#
|
13
|
+
# This program is distributed in the hope that it will be useful,
|
14
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16
|
+
# GNU General Public License for more details.
|
17
|
+
#
|
18
|
+
# You should have received a copy of the GNU General Public License
|
19
|
+
# along with this program; if not, write to the Free Software
|
20
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
21
|
+
#
|
22
|
+
|
23
|
+
require 'ruby-agi/rs/return_status'
|
24
|
+
|
25
|
+
# Say a given digit string, returning early if any of the given DTMF digits are received on the channel.
|
26
|
+
#
|
27
|
+
# Command Reference: SAY DIGITS <number> <escape digits>
|
28
|
+
#
|
29
|
+
# failure: 200 result=-1
|
30
|
+
# success: 200 result=0
|
31
|
+
# digit pressed: 200 result=<digit>
|
32
|
+
# <digit> is the ascii code for the digit pressed.
|
33
|
+
#
|
34
|
+
|
35
|
+
|
36
|
+
class ReturnStatus
|
37
|
+
end
|
38
|
+
|
39
|
+
class SayDigits < ReturnStatus
|
40
|
+
|
41
|
+
def initialize(command, response)
|
42
|
+
super(command, response)
|
43
|
+
end
|
44
|
+
|
45
|
+
def success?
|
46
|
+
if @is_success.nil?
|
47
|
+
if result == '0'
|
48
|
+
@is_success = true
|
49
|
+
else
|
50
|
+
@is_success = false
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
return @is_success
|
55
|
+
end
|
56
|
+
|
57
|
+
def failure?
|
58
|
+
if @is_failure.nil?
|
59
|
+
if result == '-1'
|
60
|
+
@is_failure = true
|
61
|
+
else
|
62
|
+
@is_failure = false
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
return @is_failure
|
67
|
+
end
|
68
|
+
|
69
|
+
def digit
|
70
|
+
if @digit.nil?
|
71
|
+
@digit = result.to_i.chr
|
72
|
+
end
|
73
|
+
|
74
|
+
return @digit
|
75
|
+
end
|
76
|
+
|
77
|
+
def error?
|
78
|
+
return command_error?
|
79
|
+
end
|
80
|
+
|
81
|
+
def response
|
82
|
+
return message
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
#
|
2
|
+
# File: say_number.rb
|
3
|
+
#
|
4
|
+
# ruby-agi: Ruby Language API for Asterisk
|
5
|
+
#
|
6
|
+
# Copyright (C) <2006> Mohammad Khan <info@beeplove.com>
|
7
|
+
#
|
8
|
+
# This program is free software; you can redistribute it and/or modify
|
9
|
+
# it under the terms of the GNU General Public License as published by
|
10
|
+
# the Free Software Foundation; either version 2 of the License, or
|
11
|
+
# (at your option) any later version.
|
12
|
+
#
|
13
|
+
# This program is distributed in the hope that it will be useful,
|
14
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16
|
+
# GNU General Public License for more details.
|
17
|
+
#
|
18
|
+
# You should have received a copy of the GNU General Public License
|
19
|
+
# along with this program; if not, write to the Free Software
|
20
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
21
|
+
#
|
22
|
+
|
23
|
+
require 'ruby-agi/rs/return_status'
|
24
|
+
|
25
|
+
# Say a given number, returning early if any of the given DTMF digits are received on the channel.
|
26
|
+
#
|
27
|
+
# Command Reference: SAY NUMBER <number> <escape digits>
|
28
|
+
#
|
29
|
+
# - number : number to announce
|
30
|
+
# - escape_digit : if pressed, return from program
|
31
|
+
#
|
32
|
+
# failure: 200 result=-1
|
33
|
+
# success: 200 result=0
|
34
|
+
# digit pressed: 200 result=<digit>
|
35
|
+
#<digit> is the ascii code for the digit pressed.
|
36
|
+
#
|
37
|
+
|
38
|
+
|
39
|
+
class ReturnStatus
|
40
|
+
end
|
41
|
+
|
42
|
+
class SayNumber < ReturnStatus
|
43
|
+
|
44
|
+
def initialize(command, response)
|
45
|
+
super(command, response)
|
46
|
+
end
|
47
|
+
|
48
|
+
def success?
|
49
|
+
if @is_success.nil?
|
50
|
+
if result == '0'
|
51
|
+
@is_success = true
|
52
|
+
else
|
53
|
+
@is_success = false
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
return @is_success
|
58
|
+
end
|
59
|
+
|
60
|
+
def failure?
|
61
|
+
if @is_failure.nil?
|
62
|
+
if result == '-1'
|
63
|
+
@is_failure = true
|
64
|
+
else
|
65
|
+
@is_failure = false
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
return @is_failure
|
70
|
+
end
|
71
|
+
|
72
|
+
def digit
|
73
|
+
if @digit.nil?
|
74
|
+
@digit = result.to_i.chr
|
75
|
+
end
|
76
|
+
|
77
|
+
return @digit
|
78
|
+
end
|
79
|
+
|
80
|
+
def error?
|
81
|
+
return command_error?
|
82
|
+
end
|
83
|
+
|
84
|
+
def response
|
85
|
+
return message
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
#
|
2
|
+
# File: say_phonetic.rb
|
3
|
+
#
|
4
|
+
# ruby-agi: Ruby Language API for Asterisk
|
5
|
+
#
|
6
|
+
# Copyright (C) <2006> Mohammad Khan <info@beeplove.com>
|
7
|
+
#
|
8
|
+
# This program is free software; you can redistribute it and/or modify
|
9
|
+
# it under the terms of the GNU General Public License as published by
|
10
|
+
# the Free Software Foundation; either version 2 of the License, or
|
11
|
+
# (at your option) any later version.
|
12
|
+
#
|
13
|
+
# This program is distributed in the hope that it will be useful,
|
14
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16
|
+
# GNU General Public License for more details.
|
17
|
+
#
|
18
|
+
# You should have received a copy of the GNU General Public License
|
19
|
+
# along with this program; if not, write to the Free Software
|
20
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
21
|
+
#
|
22
|
+
|
23
|
+
require 'ruby-agi/rs/return_status'
|
24
|
+
|
25
|
+
#
|
26
|
+
# Say a given character string with phonetics, returning early if any of the given DTMF digits are received on the channel.
|
27
|
+
#
|
28
|
+
# Command Reference: SAY PHONETIC <string> <escape digits>
|
29
|
+
#
|
30
|
+
# - string : character string to announce
|
31
|
+
# - escape_digit : digit to be pressed to escape from program
|
32
|
+
#
|
33
|
+
# failure: 200 result=-1
|
34
|
+
# success: 200 result=0
|
35
|
+
# digit pressed: 200 result=<digit>
|
36
|
+
# <digit> is the ascii code for the digit pressed.
|
37
|
+
#
|
38
|
+
|
39
|
+
class ReturnStatus
|
40
|
+
end
|
41
|
+
|
42
|
+
class SayPhonetic < ReturnStatus
|
43
|
+
|
44
|
+
def initialize(command, response)
|
45
|
+
super(command, response)
|
46
|
+
end
|
47
|
+
|
48
|
+
def success?
|
49
|
+
if @is_success.nil?
|
50
|
+
if result == '0'
|
51
|
+
@is_success = true
|
52
|
+
else
|
53
|
+
@is_success = false
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
return @is_success
|
58
|
+
end
|
59
|
+
|
60
|
+
def failure?
|
61
|
+
if @is_failure.nil?
|
62
|
+
if result == '-1'
|
63
|
+
@is_failure = true
|
64
|
+
else
|
65
|
+
@is_failure = false
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
return @is_failure
|
70
|
+
end
|
71
|
+
|
72
|
+
def digit
|
73
|
+
if @digit.nil?
|
74
|
+
@digit = result.to_i.chr
|
75
|
+
end
|
76
|
+
|
77
|
+
return @digit
|
78
|
+
end
|
79
|
+
|
80
|
+
def error?
|
81
|
+
return command_error?
|
82
|
+
end
|
83
|
+
|
84
|
+
def response
|
85
|
+
return message
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
#
|
2
|
+
# File: say_time.rb
|
3
|
+
#
|
4
|
+
# ruby-agi: Ruby Language API for Asterisk
|
5
|
+
#
|
6
|
+
# Copyright (C) <2006> Mohammad Khan <info@beeplove.com>
|
7
|
+
#
|
8
|
+
# This program is free software; you can redistribute it and/or modify
|
9
|
+
# it under the terms of the GNU General Public License as published by
|
10
|
+
# the Free Software Foundation; either version 2 of the License, or
|
11
|
+
# (at your option) any later version.
|
12
|
+
#
|
13
|
+
# This program is distributed in the hope that it will be useful,
|
14
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16
|
+
# GNU General Public License for more details.
|
17
|
+
#
|
18
|
+
# You should have received a copy of the GNU General Public License
|
19
|
+
# along with this program; if not, write to the Free Software
|
20
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
21
|
+
#
|
22
|
+
|
23
|
+
require 'ruby-agi/rs/return_status'
|
24
|
+
|
25
|
+
#
|
26
|
+
# Say a given time, returning early if any of the given DTMF digits are received on the channel.
|
27
|
+
#
|
28
|
+
# Command Reference: SAY TIME <time> <escape digits>
|
29
|
+
#
|
30
|
+
# - time : number of seconds elapsed since 00:00:00 on January 1, 1970, Coordinated Universal Time (UTC).
|
31
|
+
# - escape_digits : digit to be pressed to escape from the program
|
32
|
+
#
|
33
|
+
# failure: 200 result=-1
|
34
|
+
# success: 200 result=0
|
35
|
+
# digit pressed: 200 result=<digit>
|
36
|
+
# <digit> is the ascii code for the digit pressed.
|
37
|
+
#
|
38
|
+
#
|
39
|
+
|
40
|
+
|
41
|
+
class ReturnStatus
|
42
|
+
end
|
43
|
+
|
44
|
+
class SayTime < ReturnStatus
|
45
|
+
|
46
|
+
def initialize(command, response)
|
47
|
+
super(command, response)
|
48
|
+
end
|
49
|
+
|
50
|
+
def success?
|
51
|
+
if @is_success.nil?
|
52
|
+
if result == '0'
|
53
|
+
@is_success = true
|
54
|
+
else
|
55
|
+
@is_success = false
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
return @is_success
|
60
|
+
end
|
61
|
+
|
62
|
+
def failure?
|
63
|
+
if @is_failure.nil?
|
64
|
+
if result == '-1'
|
65
|
+
@is_failure = true
|
66
|
+
else
|
67
|
+
@is_failure = false
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
return @is_failure
|
72
|
+
end
|
73
|
+
|
74
|
+
def digit
|
75
|
+
if @digit.nil?
|
76
|
+
@digit = result.to_i.chr
|
77
|
+
end
|
78
|
+
|
79
|
+
return @digit
|
80
|
+
end
|
81
|
+
|
82
|
+
def error?
|
83
|
+
return command_error?
|
84
|
+
end
|
85
|
+
|
86
|
+
def response
|
87
|
+
return message
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|