fluent-plugin-twilio 0.1.0 → 0.1.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.
- checksums.yaml +4 -4
- data/README.md +3 -2
- data/fluent-plugin-twilio.gemspec +2 -2
- data/lib/fluent/plugin/out_twilio.rb +8 -6
- data/test/plugin/test_out_twilio.rb +10 -6
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d5aa5893f94bfe4afa13ce42005c1f477e613062
|
4
|
+
data.tar.gz: 83a5030461b30d6fc6e73bfb515797c2b7bc2a74
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 07a4d2af57f8be03d75f5c9d14ab42836966a4a0dc24ef6a7672322042a71d027976a4fbf2d2c16c9ea7e0e4685353440ed08ac2deeed1c7958a31b4dcd8fd46
|
7
|
+
data.tar.gz: 61e6189432ea454c063d750ede5ed5bafed2f30fd57354ad41dfe08f5ab2ea36c48ffe7e22df712d6c7033efc96c9d880f3830c91bb18c90916e80b2fcf0d5f9
|
data/README.md
CHANGED
@@ -31,8 +31,8 @@ $ sudo td-agent-gem install fluent-plugin-twilio
|
|
31
31
|
### Message Format
|
32
32
|
`````
|
33
33
|
fluent_logger.post('notify.call', {
|
34
|
-
:
|
35
|
-
:
|
34
|
+
:number => '+8109012345678', # Required if default_number is brank
|
35
|
+
:message => 'Hello World!' # Required if default_message is brank
|
36
36
|
})
|
37
37
|
`````
|
38
38
|
|
@@ -56,6 +56,7 @@ fluent_logger.post('notify.call', {
|
|
56
56
|
# Set defaults of making outbound call.
|
57
57
|
# To call multiple phone at the same time, list them with comma like below.
|
58
58
|
default_number +819012345678,+818012345678 # Optional
|
59
|
+
default_message "call from fluentd." # Optional
|
59
60
|
|
60
61
|
# Set log level to prevent info error
|
61
62
|
@log_level warn
|
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "fluent-plugin-twilio"
|
6
|
-
s.version = "0.1.
|
6
|
+
s.version = "0.1.1"
|
7
7
|
s.authors = ["Kentaro Yoshida"]
|
8
8
|
s.email = ["y.ken.studio@gmail.com"]
|
9
9
|
s.homepage = "https://github.com/y-ken/fluent-plugin-twilio"
|
@@ -18,5 +18,5 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.add_development_dependency "rake"
|
19
19
|
s.add_development_dependency "test-unit", ">= 3.1.0"
|
20
20
|
s.add_runtime_dependency "fluentd", ">= 0.14.15", "< 2"
|
21
|
-
s.add_runtime_dependency "twilio-ruby"
|
21
|
+
s.add_runtime_dependency "twilio-ruby", "~> 5.5.0"
|
22
22
|
end
|
@@ -11,6 +11,7 @@ class Fluent::Plugin::TwilioOutput < Fluent::Plugin::Output
|
|
11
11
|
config_param :from_number, :string, default: ''
|
12
12
|
config_param :default_number, :string, default: ''
|
13
13
|
config_param :default_voice, :string, default: 'woman'
|
14
|
+
config_param :default_message, :string, default: nil
|
14
15
|
config_param :language, :string, default: 'ja-jp'
|
15
16
|
|
16
17
|
VOICE_MAP = ['man', 'woman']
|
@@ -24,23 +25,24 @@ class Fluent::Plugin::TwilioOutput < Fluent::Plugin::Output
|
|
24
25
|
es.each do |time,record|
|
25
26
|
number = record['number'].nil? ? @default_number : record['number']
|
26
27
|
@voice = VOICE_MAP.include?(record['voice']) ? record['voice'] : @default_voice
|
27
|
-
|
28
|
+
message = record['message'] || @default_message
|
29
|
+
call(number, message)
|
28
30
|
end
|
29
31
|
end
|
30
32
|
|
31
33
|
def call(number, message)
|
32
|
-
response = Twilio::TwiML::
|
33
|
-
r.
|
34
|
+
response = Twilio::TwiML::VoiceResponse.new do |r|
|
35
|
+
r.say(message, voice: @voice, language: @language)
|
34
36
|
end
|
35
|
-
xml = response.
|
37
|
+
xml = response.to_s.sub(/<[^>]+?>/, '')
|
36
38
|
url = "http://twimlets.com/echo?Twiml=#{URI.escape(xml)}"
|
37
39
|
log.info "twilio: generateing twiml: #{xml}"
|
38
40
|
|
39
41
|
client = Twilio::REST::Client.new(@account_sid, @auth_token)
|
40
|
-
account = client.account
|
42
|
+
account = client.api.account
|
41
43
|
number.gsub(' ', '').split(',').each do |to_number|
|
42
44
|
begin
|
43
|
-
account.calls.create(
|
45
|
+
account.calls.create(from: @from_number, to: to_number, url: url)
|
44
46
|
rescue => e
|
45
47
|
log.error "twilio: Error: #{e.message}"
|
46
48
|
end
|
@@ -20,26 +20,30 @@ class TwilioOutputTest < Test::Unit::TestCase
|
|
20
20
|
d = create_driver('')
|
21
21
|
}
|
22
22
|
d = create_driver %[
|
23
|
-
account_sid
|
24
|
-
auth_token
|
25
|
-
from_number
|
23
|
+
account_sid TWILIO_ACCOUNT_SID
|
24
|
+
auth_token TWILIO_AUTH_TOKEN
|
25
|
+
from_number +8112345678
|
26
|
+
default_message test_message
|
26
27
|
]
|
27
28
|
assert_equal 'TWILIO_ACCOUNT_SID', d.instance.account_sid
|
28
29
|
assert_equal 'TWILIO_AUTH_TOKEN', d.instance.auth_token
|
29
30
|
assert_equal '+8112345678', d.instance.from_number
|
31
|
+
assert_equal 'test_message', d.instance.default_message
|
30
32
|
end
|
31
33
|
|
32
34
|
def test_configure_multinumber
|
33
35
|
d = create_driver %[
|
34
|
-
account_sid
|
35
|
-
auth_token
|
36
|
-
from_number
|
36
|
+
account_sid TWILIO_ACCOUNT_SID
|
37
|
+
auth_token TWILIO_AUTH_TOKEN
|
38
|
+
from_number +8112345678
|
37
39
|
default_number +81123456789,+811234567890
|
40
|
+
default_message test_message
|
38
41
|
]
|
39
42
|
assert_equal 'TWILIO_ACCOUNT_SID', d.instance.account_sid
|
40
43
|
assert_equal 'TWILIO_AUTH_TOKEN', d.instance.auth_token
|
41
44
|
assert_equal '+8112345678', d.instance.from_number
|
42
45
|
assert_equal '+81123456789,+811234567890', d.instance.default_number
|
46
|
+
assert_equal 'test_message', d.instance.default_message
|
43
47
|
end
|
44
48
|
|
45
49
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-twilio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kentaro Yoshida
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-12-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -62,16 +62,16 @@ dependencies:
|
|
62
62
|
name: twilio-ruby
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|
64
64
|
requirements:
|
65
|
-
- - "
|
65
|
+
- - "~>"
|
66
66
|
- !ruby/object:Gem::Version
|
67
|
-
version:
|
67
|
+
version: 5.5.0
|
68
68
|
type: :runtime
|
69
69
|
prerelease: false
|
70
70
|
version_requirements: !ruby/object:Gem::Requirement
|
71
71
|
requirements:
|
72
|
-
- - "
|
72
|
+
- - "~>"
|
73
73
|
- !ruby/object:Gem::Version
|
74
|
-
version:
|
74
|
+
version: 5.5.0
|
75
75
|
description:
|
76
76
|
email:
|
77
77
|
- y.ken.studio@gmail.com
|