lib/fluent/plugin/out_twilio.rb in fluent-plugin-twilio-0.0.1 vs lib/fluent/plugin/out_twilio.rb in fluent-plugin-twilio-0.0.2
- old
+ new
@@ -6,12 +6,17 @@
config_param :from_number, :string, :default => ''
config_param :default_number, :string, :default => ''
config_param :default_voice, :string, :default => 'woman'
config_param :language, :string, :default => 'ja-jp'
- VOICE_MAP = ['woman']
+ VOICE_MAP = ['man', 'woman']
+ # Define `log` method for v0.10.42 or earlier
+ unless method_defined?(:log)
+ define_method("log") { $log }
+ end
+
def initialize
super
require 'uri'
require 'twilio-ruby'
end
@@ -35,17 +40,19 @@
response = Twilio::TwiML::Response.new do |r|
r.Say message, :voice => @voice, :language => @language
end
xml = response.text.sub(/<[^>]+?>/, '')
url = "http://twimlets.com/echo?Twiml=#{URI.escape(xml)}"
- $log.info "twilio: generateing twiml: #{xml}"
+ log.info "twilio: generateing twiml: #{xml}"
client = Twilio::REST::Client.new(@account_sid, @auth_token)
account = client.account
- begin
- call = account.calls.create({:from => @from_number, :to => number, :url => url})
- rescue => e
- $log.error "twilio: Error: #{e.message}"
+ number.gsub(' ', '').split(',').each do |to_number|
+ begin
+ call = account.calls.create({:from => @from_number, :to => to_number, :url => url})
+ rescue => e
+ log.error "twilio: Error: #{e.message}"
+ end
end
end
end