santas_twilio_helper 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +26 -0
- data/Rakefile +2 -0
- data/bin/santa +5 -0
- data/bin/santa_help +5 -0
- data/lib/santas_twilio_helper.rb +2 -0
- data/lib/santas_twilio_helper/cli/application.rb +116 -0
- data/lib/santas_twilio_helper/cli/config.rb +1 -0
- data/lib/santas_twilio_helper/version.rb +3 -0
- data/messages.json +35 -0
- data/santarc.json +2 -0
- data/santas_twilio_helper.gemspec +28 -0
- metadata +145 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c7790931121ce72f888a7ca0f9ae76cc95e128d7
|
4
|
+
data.tar.gz: b63b8dde7644f213f96fda2d8fa3ba85b422a325
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f8dcab7c3dd0aec62efed0fe5319aa78b89bc8c5949613777d0a04945a27050b0455d40defd2f5b48975808b404211deb3da54465705fc89a3bbdea0ea721d96
|
7
|
+
data.tar.gz: e27d5ba78df06789a49dc19edb789c0580d513573ecd3c0ba813f7c7f10d360a34f26ac34006a8c0f69ff6cb2b7deff84d6fbe6445d99614b390e470e734d8db
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Jarod Reyes
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# Santas Twilio Helper
|
2
|
+
|
3
|
+
This is a command-line tool that uses the command `santa` to interact with Santa's helpers in the north pole. This allows the festive parent to surprise their child by having Santa's elves send messages. This was built using Twilio's REST API.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
To install the `santa` command-line tool type:
|
8
|
+
|
9
|
+
$ gem install santas_twilio_helper
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
Type `santa help` to see the full list of commands. When you are in a private place without little ones around, type `santa begin` to kick off the setup of the tool.
|
14
|
+
|
15
|
+
-- `begin` registers one child name, adds a phone number and stores your zipcode for Dec. 25 fun. This is all stored locally on your machine in santarc.json.
|
16
|
+
-- `ping` sends a random msg from the northpole. (eg: messages.json)
|
17
|
+
-- `telegraph` allows you to send a custom message from the northpole.
|
18
|
+
-- `add_child` allows you to add another child name.
|
19
|
+
|
20
|
+
## Contributing
|
21
|
+
|
22
|
+
1. Fork it ( https://github.com/jarodreyes/santas_twilio_helper/fork )
|
23
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
24
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
25
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
26
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/santa
ADDED
data/bin/santa_help
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'paint'
|
3
|
+
require 'json'
|
4
|
+
require 'twilio-ruby'
|
5
|
+
|
6
|
+
module SantasTwilioHelper
|
7
|
+
module Cli
|
8
|
+
class Application < Thor
|
9
|
+
|
10
|
+
# Class constants
|
11
|
+
@@twilio_number = ENV['TWILIO_NUMBER']
|
12
|
+
@@client = Twilio::REST::Client.new ENV['TWILIO_ACCOUNT_SID'], ENV['TWILIO_AUTH_TOKEN']
|
13
|
+
|
14
|
+
include Thor::Actions
|
15
|
+
|
16
|
+
desc 'begin', 'Register yourself as one of Santas helpers'
|
17
|
+
def begin
|
18
|
+
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]}")
|
19
|
+
santa_helper = ask("Parent Name: ")
|
20
|
+
|
21
|
+
children = []
|
22
|
+
say("Great Gumdrops. We also need your child's name to verify they are on Santa's list. ")
|
23
|
+
child = ask("Child Name: ")
|
24
|
+
children.push(child)
|
25
|
+
|
26
|
+
say("Fantastic. You can always add more children by running add_child later.")
|
27
|
+
say("Next I need to know your telephone number so Santa's helpers can get in touch with you.")
|
28
|
+
telephone = ask("#{Paint['Telephone Number: ', :red]}")
|
29
|
+
|
30
|
+
say("The last thing I need is your city so we can verify we have the correct location for #{child}.")
|
31
|
+
zip_code = ask("#{Paint['Zip Code: ', :blue]}")
|
32
|
+
|
33
|
+
data = {
|
34
|
+
'santa_helper' => santa_helper,
|
35
|
+
'children' => children,
|
36
|
+
'telephone' => telephone,
|
37
|
+
'zip_code'=> zip_code
|
38
|
+
}
|
39
|
+
|
40
|
+
write_file(data)
|
41
|
+
|
42
|
+
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"]}")
|
43
|
+
end
|
44
|
+
|
45
|
+
no_commands {
|
46
|
+
def write_file(data_hash)
|
47
|
+
create_file "santarc.json", "// Your Santas Helper configuration.\n #{data_hash.to_json}", :force => true
|
48
|
+
end
|
49
|
+
|
50
|
+
def sendMessage(msg)
|
51
|
+
file = File.read('santarc.json')
|
52
|
+
data_hash = JSON.parse(file)
|
53
|
+
phone = data_hash['telephone']
|
54
|
+
children = english_join(data_hash['children'])
|
55
|
+
msg = "Hi #{children}. #{msg} - the elves"
|
56
|
+
message = @@client.account.messages.create(
|
57
|
+
:from => @@twilio_number,
|
58
|
+
:to => phone,
|
59
|
+
:body => msg
|
60
|
+
)
|
61
|
+
puts "message sent: #{msg}"
|
62
|
+
end
|
63
|
+
|
64
|
+
def english_join(array = nil)
|
65
|
+
return array.to_s if array.nil? or array.length <= 1
|
66
|
+
array[0..-2].join(", ") + " and " + array[-1]
|
67
|
+
end
|
68
|
+
}
|
69
|
+
|
70
|
+
desc 'add_child NAME', 'Add child to Santas registry'
|
71
|
+
def add_child(name)
|
72
|
+
file = File.read('santarc.json')
|
73
|
+
data_hash = JSON.parse(file)
|
74
|
+
children = data_hash['children']
|
75
|
+
children.push name
|
76
|
+
data_hash['children'] = children
|
77
|
+
puts data_hash
|
78
|
+
|
79
|
+
write_file(data_hash)
|
80
|
+
puts "Added #{name} to children"
|
81
|
+
end
|
82
|
+
|
83
|
+
desc 'ping', 'See where Santa is right now'
|
84
|
+
def ping
|
85
|
+
file = File.read('messages.json')
|
86
|
+
messages = JSON.parse(file)
|
87
|
+
santaMs = messages['SANTA_SNIPPETS']
|
88
|
+
a = rand(0..(santaMs.length-1))
|
89
|
+
msg = santaMs[a]
|
90
|
+
puts "sending message..."
|
91
|
+
sendMessage(msg)
|
92
|
+
end
|
93
|
+
|
94
|
+
desc 'telegraph MSG', "Send a text message as Santa's helper."
|
95
|
+
|
96
|
+
# Longer description when `santa help telegraph` is called.
|
97
|
+
long_desc <<-LONGDESC
|
98
|
+
`santa telegraph` will send any message to the phone number you entered on setup.
|
99
|
+
|
100
|
+
"You can optionally specify a second parameter, which will insert a time delay (in seconds) so that your messages can be sent while you or the phone are within eyesight of your little ones."
|
101
|
+
|
102
|
+
#{Paint["> $ santa telegraph 'Santa was wondering if Anna likes red things?' --delay 200", "#55C4C2"]}
|
103
|
+
LONGDESC
|
104
|
+
|
105
|
+
option :delay, :type => :numeric, :default => 0
|
106
|
+
def telegraph(message)
|
107
|
+
puts "delay: #{options[:delay]}" if options[:delay]
|
108
|
+
sleep(options[:delay])
|
109
|
+
puts Paint["sending message as SMS...", :red]
|
110
|
+
sendMessage(message)
|
111
|
+
puts "#{Paint["Santa has approved that communication and we'll forward to the appropriate phone soon. -the elves", :white]}"
|
112
|
+
end
|
113
|
+
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
@@children = Jarod""
|
data/messages.json
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
{"CITY_SNIPPETS": [
|
2
|
+
"Looks like Santa is in route to ",
|
3
|
+
"Santa is en route to ",
|
4
|
+
"Santa is on his way to ",
|
5
|
+
"Santa is landing in ",
|
6
|
+
"Santa is delivering gifts in ",
|
7
|
+
"Santa is eating some cookies in ",
|
8
|
+
"Santa is drinking some egg nog in ",
|
9
|
+
"Santa is sipping some hot cocoa right now in ",
|
10
|
+
"Santa is driving the reindeers to",
|
11
|
+
"Santa stopped to feed the reindeers in",
|
12
|
+
"Santa had to straighten the sled. He's currently over",
|
13
|
+
"Santa is right above"
|
14
|
+
],
|
15
|
+
"GIFT_SNIPPETS": [
|
16
|
+
"He is excited to bring gifts to",
|
17
|
+
"He can't wait for "
|
18
|
+
],
|
19
|
+
"SANTA_SNIPPETS" : [
|
20
|
+
"We're currently in Oregon getting some wood to bring back to the northpole for all of the toys.",
|
21
|
+
"Thanks for checking in. We're still working away here in the north pole!",
|
22
|
+
"One of the elves just invented a new toy. Excited to share it with you.",
|
23
|
+
"Just saw Santa's list, are you being good today?",
|
24
|
+
"Just got back from helping Santa carry his dinner in. He eats a lot this time of year!",
|
25
|
+
"Just eating dessert. In the northpole we eat dessert for all 3 meals!",
|
26
|
+
"Later this afternoon Santa's security is doing trial runs for his visit to New York. Santa has a lot of fans there!",
|
27
|
+
"Was just checking on the Sleigh. It's ready to fly!",
|
28
|
+
"Mrs. Santa just told me to ask you to leave out less cookies than you did last year. Apparently Santa Claus loves your cookies far too much.",
|
29
|
+
"Was just out in the stables checking up on Dasher, he had a cold last week. He's all smiles now!",
|
30
|
+
"Was just out in the stables with Rudolph. He loves to have his nose pet. Such a weird reindeer!",
|
31
|
+
"Was just playing candy-cane fetch with Prancer.",
|
32
|
+
"Feeding the reindeer. brb",
|
33
|
+
"It always feels like winter in the Northpole. Just thought you should snow."
|
34
|
+
]
|
35
|
+
}
|
data/santarc.json
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'santas_twilio_helper/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "santas_twilio_helper"
|
8
|
+
spec.version = SantasTwilioHelper::VERSION
|
9
|
+
spec.authors = ["Jarod Reyes"]
|
10
|
+
spec.email = ["jreyes@twilio.com"]
|
11
|
+
spec.summary = 'all the tools santas little helper might need. Powered by Twilio.'
|
12
|
+
spec.description = 'All the tools Santas Helper might need. Send MMS, check Santas progress, register childs name, etc.'
|
13
|
+
spec.homepage = "https://github.com/jarodreyes/star-trek-twilio"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency 'thor', '~> 0.18'
|
22
|
+
spec.add_dependency 'paint'
|
23
|
+
spec.add_dependency 'json'
|
24
|
+
spec.add_dependency 'twilio-ruby', '~> 3.11'
|
25
|
+
|
26
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
27
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,145 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: santas_twilio_helper
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jarod Reyes
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-12-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: thor
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.18'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.18'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: paint
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: json
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: twilio-ruby
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.11'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.11'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: bundler
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.7'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.7'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rake
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '10.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '10.0'
|
97
|
+
description: All the tools Santas Helper might need. Send MMS, check Santas progress,
|
98
|
+
register childs name, etc.
|
99
|
+
email:
|
100
|
+
- jreyes@twilio.com
|
101
|
+
executables:
|
102
|
+
- santa
|
103
|
+
- santa_help
|
104
|
+
extensions: []
|
105
|
+
extra_rdoc_files: []
|
106
|
+
files:
|
107
|
+
- ".gitignore"
|
108
|
+
- Gemfile
|
109
|
+
- LICENSE.txt
|
110
|
+
- README.md
|
111
|
+
- Rakefile
|
112
|
+
- bin/santa
|
113
|
+
- bin/santa_help
|
114
|
+
- lib/santas_twilio_helper.rb
|
115
|
+
- lib/santas_twilio_helper/cli/application.rb
|
116
|
+
- lib/santas_twilio_helper/cli/config.rb
|
117
|
+
- lib/santas_twilio_helper/version.rb
|
118
|
+
- messages.json
|
119
|
+
- santarc.json
|
120
|
+
- santas_twilio_helper.gemspec
|
121
|
+
homepage: https://github.com/jarodreyes/star-trek-twilio
|
122
|
+
licenses:
|
123
|
+
- MIT
|
124
|
+
metadata: {}
|
125
|
+
post_install_message:
|
126
|
+
rdoc_options: []
|
127
|
+
require_paths:
|
128
|
+
- lib
|
129
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
130
|
+
requirements:
|
131
|
+
- - ">="
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
requirements: []
|
140
|
+
rubyforge_project:
|
141
|
+
rubygems_version: 2.4.2
|
142
|
+
signing_key:
|
143
|
+
specification_version: 4
|
144
|
+
summary: all the tools santas little helper might need. Powered by Twilio.
|
145
|
+
test_files: []
|