Class: SantasTwilioHelper::Cli::Application
- Inherits:
-
Thor
- Object
- Thor
- SantasTwilioHelper::Cli::Application
- Includes:
- Thor::Actions
- Defined in:
- lib/santas_twilio_helper/cli/application.rb
Constant Summary collapse
- @@twilio_number =
Class constants
ENV['TWILIO_NUMBER']
- @@client =
Twilio::REST::Client.new ENV['TWILIO_ACCOUNT_SID'], ENV['TWILIO_AUTH_TOKEN']
Instance Method Summary collapse
Instance Method Details
#add_child(name) ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/santas_twilio_helper/cli/application.rb', line 71 def add_child(name) file = File.read('santarc.json') data_hash = JSON.parse(file) children = data_hash['children'] children.push name data_hash['children'] = children puts data_hash write_file(data_hash) puts "Added #{name} to children" end |
#begin ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/santas_twilio_helper/cli/application.rb', line 17 def begin say("#{Paint["Hi I'm one of Santa's Twilio Elves, and I'm about to deputize you as an ambassador to Santa. To get started I need your name.", :red]}") santa_helper = ask("Parent Name: ") children = [] say("Great Gumdrops. We also need your child's name to verify they are on Santa's list. ") child = ask("Child Name: ") children.push(child) say("Fantastic. You can always add more children by running add_child later.") say("Next I need to know your telephone number so Santa's helpers can get in touch with you.") telephone = ask("#{Paint['Telephone Number: ', :red]}") say("The last thing I need is your city so we can verify we have the correct location for #{child}.") zip_code = ask("#{Paint['Zip Code: ', :blue]}") data = { 'santa_helper' => santa_helper, 'children' => children, 'telephone' => telephone, 'zip_code'=> zip_code } write_file(data) say("#{Paint["Okay you're off to the races. You can type `santa help` at any time to see the list of available commands.", "#55C4C2"]}") end |
#ping ⇒ Object
84 85 86 87 88 89 90 91 92 |
# File 'lib/santas_twilio_helper/cli/application.rb', line 84 def ping file = File.read('messages.json') = JSON.parse(file) santaMs = ['SANTA_SNIPPETS'] a = rand(0..(santaMs.length-1)) msg = santaMs[a] puts "sending message..." sendMessage(msg) end |
#telegraph(message) ⇒ Object
106 107 108 109 110 111 112 |
# File 'lib/santas_twilio_helper/cli/application.rb', line 106 def telegraph() puts "delay: #{[:delay]}" if [:delay] sleep([:delay]) puts Paint["sending message as SMS...", :red] sendMessage() puts "#{Paint["Santa has approved that communication and we'll forward to the appropriate phone soon. -the elves", :white]}" end |