class Lita::Handlers::TwilioTexter
Public Instance Methods
client()
click to toggle source
# File lib/lita/handlers/twilio_texter.rb, line 14 def client @_client ||= Twilio::REST::Client.new( ENV.fetch('TWILIO_ACCOUNT_SID'), ENV.fetch('TWILIO_AUTH_TOKEN') ) end
send_from_number()
click to toggle source
# File lib/lita/handlers/twilio_texter.rb, line 21 def send_from_number client.incoming_phone_numbers.page.first.phone_number end
send_text(message)
click to toggle source
# File lib/lita/handlers/twilio_texter.rb, line 25 def send_text(message) _, to, body = message.match_data.to_a results = send_twilio_sms(to: to, body: body) message.reply "Sent message to #{to}" end
send_twilio_sms(to:, body:)
click to toggle source
# File lib/lita/handlers/twilio_texter.rb, line 32 def send_twilio_sms(to:, body:) response = client.api.account.messages.create( from: send_from_number, to: to, body: body ) end