incognito 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +18 -16
- data/incognito.gemspec +4 -2
- data/lib/incognito/cli/sms_command.rb +12 -3
- data/lib/incognito/sms.rb +1 -1
- data/lib/incognito/sms_server.rb +39 -6
- data/lib/incognito/version.rb +1 -1
- metadata +36 -9
- data/Gemfile.lock +0 -49
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cf867cf2efa3e0c8796ed06f3950cf45cc784c082bf08ee969cbbdf861fdd893
|
4
|
+
data.tar.gz: a70911e7f06f126adcfb6f0a11ae8070fea7a436ed3ee0af81f0f353422aa043
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c3c3d6d2c7fed34afff39fcc61994e3f31e8d4ac8c3fd288bb4010a960fcd7ec2c34b99242de1f81285b50405ff9bc33deb9720152b80a30bce99732645bf038
|
7
|
+
data.tar.gz: 480a305dd7cfbe606d5ec3c37c6f944f1ebf94003323adef271e5e9efcb5f0fb96359387cc32a362f74abd365cfa77ace5779a04f73ae8024ba19d393d17c176
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -1,38 +1,40 @@
|
|
1
1
|
# Incognito
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
3
|
+
Send and Receive SMS messages from your terminal.
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
9
|
-
Add this line to your application's Gemfile:
|
10
7
|
|
11
|
-
|
12
|
-
gem 'incognito'
|
13
|
-
```
|
8
|
+
Install it from https://rubygems.org:
|
14
9
|
|
15
|
-
|
10
|
+
$ gem install incognito
|
16
11
|
|
17
|
-
|
12
|
+
Create an account at [twilio](https://www.twilio.com)
|
18
13
|
|
19
|
-
|
14
|
+
Configure the following settings in your shell profile.
|
20
15
|
|
21
|
-
$
|
16
|
+
$ export TWILIO_SID="MYSID"
|
17
|
+
$ export TWILIO_TOKEN="MYTOKEN"
|
18
|
+
$ export TWILIO_NUMBER="MYNUMBER"
|
22
19
|
|
23
20
|
## Usage
|
24
21
|
|
25
|
-
|
22
|
+
To see the help:
|
23
|
+
|
24
|
+
$ incognito help
|
25
|
+
|
26
|
+
To send an SMS to a specific phone #:
|
27
|
+
|
28
|
+
$ incognito sms message +18005557777 "hello stranger!"
|
26
29
|
|
27
|
-
|
30
|
+
To send and receive SMS:
|
28
31
|
|
29
|
-
|
32
|
+
$ incognito sms server # follow the onscreen instructions
|
30
33
|
|
31
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
34
|
|
33
35
|
## Contributing
|
34
36
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
37
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/mokhan/incognito.
|
36
38
|
|
37
39
|
## License
|
38
40
|
|
data/incognito.gemspec
CHANGED
@@ -22,9 +22,11 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.require_paths = ["lib"]
|
23
23
|
|
24
24
|
spec.add_dependency "dotenv", "~> 2.2"
|
25
|
-
spec.add_dependency "
|
26
|
-
spec.add_dependency "
|
25
|
+
spec.add_dependency "ngrok-tunnel", "~> 2.1"
|
26
|
+
spec.add_dependency "puma", "~> 3.11"
|
27
27
|
spec.add_dependency "sinatra", "~> 2.0"
|
28
|
+
spec.add_dependency "thor", "~> 0.20"
|
29
|
+
spec.add_dependency "twilio-ruby", "~> 5.8"
|
28
30
|
spec.add_development_dependency "bundler", "~> 1.16"
|
29
31
|
spec.add_development_dependency "rake", "~> 10.0"
|
30
32
|
spec.add_development_dependency "minitest", "~> 5.0"
|
@@ -1,6 +1,11 @@
|
|
1
1
|
module Incognito
|
2
2
|
module CLI
|
3
3
|
class SMSCommand < Thor
|
4
|
+
class_option :sid, desc: "Twilio SID. ENV['TWILIO_SID']", default: ENV['TWILIO_SID']
|
5
|
+
class_option :token, desc: "Twilio token. ENV['TWILIO_TOKEN']", default: ENV['TWILIO_TOKEN']
|
6
|
+
class_option :from_number, desc: "Twilio phone number. ENV['TWILIO_NUMBER']", default: ENV['TWILIO_NUMBER']
|
7
|
+
class_option :debug, default: false, required: false
|
8
|
+
|
4
9
|
desc 'message <PHONE_NUMBER> <MESSAGE>', "Send an SMS to the phone number. (+18005557777)"
|
5
10
|
def message(phone_number, message)
|
6
11
|
say "Sending `#{message}` to #{phone_number}"
|
@@ -20,14 +25,18 @@ module Incognito
|
|
20
25
|
desc 'server', "Start a server"
|
21
26
|
def server
|
22
27
|
require 'incognito/sms_server'
|
23
|
-
|
24
|
-
SmsServer.
|
28
|
+
SmsServer.set :shell, self
|
29
|
+
SmsServer.boot_up!
|
25
30
|
end
|
26
31
|
|
27
32
|
private
|
28
33
|
|
29
34
|
def sms
|
30
|
-
@sms ||= Sms.new
|
35
|
+
@sms ||= Sms.new(
|
36
|
+
sid: options[:sid],
|
37
|
+
token: options[:token],
|
38
|
+
phone_number: options[:from_number]
|
39
|
+
)
|
31
40
|
end
|
32
41
|
end
|
33
42
|
end
|
data/lib/incognito/sms.rb
CHANGED
data/lib/incognito/sms_server.rb
CHANGED
@@ -1,26 +1,59 @@
|
|
1
1
|
require 'sinatra'
|
2
2
|
require 'sinatra/base'
|
3
|
+
require 'ngrok/tunnel'
|
3
4
|
|
4
5
|
class SmsServer < Sinatra::Base
|
6
|
+
PORT=ENV.fetch("PORT", 4567)
|
5
7
|
configure do
|
6
8
|
disable :logging
|
7
|
-
set
|
9
|
+
set :server, :puma
|
10
|
+
set :shell, $shell
|
11
|
+
set :port, PORT
|
8
12
|
end
|
9
13
|
|
10
14
|
get '/' do
|
11
15
|
content_type 'text/xml'
|
12
16
|
Incognito.logger.debug(params.inspect)
|
13
17
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
if
|
18
|
+
shell.say "To: #{params["To"]}", :green
|
19
|
+
shell.say "From: #{params["From"]}", :green
|
20
|
+
shell.say "Message: #{params["Body"]}", :green
|
21
|
+
if shell.yes? "Reply?"
|
18
22
|
Twilio::TwiML::MessagingResponse.new do |response|
|
19
|
-
response.message(body:
|
23
|
+
response.message(body: shell.ask("Response:"))
|
20
24
|
end.to_s
|
21
25
|
else
|
22
26
|
Twilio::TwiML::MessagingResponse.new do |response|
|
23
27
|
end.to_s
|
24
28
|
end
|
25
29
|
end
|
30
|
+
|
31
|
+
def self.boot_up!
|
32
|
+
Ngrok::Tunnel.start(addr: "localhost:#{PORT}")
|
33
|
+
puts "***" * 10
|
34
|
+
banner = <<-BANNER
|
35
|
+
Configure your webhook URL
|
36
|
+
For Twilio to know where to look, you need to configure your Twilio phone number
|
37
|
+
to call your webhook URL whenever a new message comes in.
|
38
|
+
|
39
|
+
1. Log into twilio.com and go to the Numbers page in the Console.
|
40
|
+
(https://www.twilio.com/console/phone-numbers/incoming)
|
41
|
+
2. Click on your SMS-enabled phone number.
|
42
|
+
3. Find the Messaging section. The default “CONFIGURE WITH” is what you’ll need: "Webhooks/TwiML."
|
43
|
+
4. In the “A MESSAGE COMES IN” section, select "Webhook" and paste in the URL you want to use:
|
44
|
+
#{Ngrok::Tunnel.ngrok_url_https}
|
45
|
+
5. Set the HTTP verb to GET.
|
46
|
+
|
47
|
+
|
48
|
+
BANNER
|
49
|
+
puts banner
|
50
|
+
puts "***" * 10
|
51
|
+
run!
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def shell
|
57
|
+
settings.shell
|
58
|
+
end
|
26
59
|
end
|
data/lib/incognito/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: incognito
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- mokha
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-04-
|
11
|
+
date: 2018-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dotenv
|
@@ -25,33 +25,33 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '2.2'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: ngrok-tunnel
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '2.1'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '2.1'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: puma
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '3.11'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '3.11'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: sinatra
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,6 +66,34 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '2.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: thor
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.20'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.20'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: twilio-ruby
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '5.8'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '5.8'
|
69
97
|
- !ruby/object:Gem::Dependency
|
70
98
|
name: bundler
|
71
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -119,7 +147,6 @@ files:
|
|
119
147
|
- ".gitignore"
|
120
148
|
- ".travis.yml"
|
121
149
|
- Gemfile
|
122
|
-
- Gemfile.lock
|
123
150
|
- LICENSE.txt
|
124
151
|
- README.md
|
125
152
|
- Rakefile
|
data/Gemfile.lock
DELETED
@@ -1,49 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
incognito (0.1.1)
|
5
|
-
dotenv (~> 2.2)
|
6
|
-
sinatra (~> 2.0)
|
7
|
-
thor (~> 0.20)
|
8
|
-
twilio-ruby (~> 5.8)
|
9
|
-
|
10
|
-
GEM
|
11
|
-
remote: https://rubygems.org/
|
12
|
-
specs:
|
13
|
-
dotenv (2.2.2)
|
14
|
-
faraday (0.14.0)
|
15
|
-
multipart-post (>= 1.2, < 3)
|
16
|
-
jwt (2.1.0)
|
17
|
-
mini_portile2 (2.3.0)
|
18
|
-
minitest (5.11.3)
|
19
|
-
multipart-post (2.0.0)
|
20
|
-
mustermann (1.0.2)
|
21
|
-
nokogiri (1.8.2)
|
22
|
-
mini_portile2 (~> 2.3.0)
|
23
|
-
rack (2.0.4)
|
24
|
-
rack-protection (2.0.1)
|
25
|
-
rack
|
26
|
-
rake (10.5.0)
|
27
|
-
sinatra (2.0.1)
|
28
|
-
mustermann (~> 1.0)
|
29
|
-
rack (~> 2.0)
|
30
|
-
rack-protection (= 2.0.1)
|
31
|
-
tilt (~> 2.0)
|
32
|
-
thor (0.20.0)
|
33
|
-
tilt (2.0.8)
|
34
|
-
twilio-ruby (5.8.0)
|
35
|
-
faraday (~> 0.9)
|
36
|
-
jwt (>= 1.5, <= 2.5)
|
37
|
-
nokogiri (>= 1.6, < 2.0)
|
38
|
-
|
39
|
-
PLATFORMS
|
40
|
-
ruby
|
41
|
-
|
42
|
-
DEPENDENCIES
|
43
|
-
bundler (~> 1.16)
|
44
|
-
incognito!
|
45
|
-
minitest (~> 5.0)
|
46
|
-
rake (~> 10.0)
|
47
|
-
|
48
|
-
BUNDLED WITH
|
49
|
-
1.16.1
|