tinderbot 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +25 -0
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +98 -0
- data/Rakefile +6 -0
- data/bin/tinderbot +5 -0
- data/lib/tinderbot/cli/application.rb +106 -0
- data/lib/tinderbot/facebook.rb +22 -0
- data/lib/tinderbot/tinder/bot.rb +20 -0
- data/lib/tinderbot/tinder/client.rb +69 -0
- data/lib/tinderbot/version.rb +3 -0
- data/lib/tinderbot.rb +7 -0
- data/spec/fixtures/recommended_users.json +12 -0
- data/spec/fixtures/updates.json +3 -0
- data/spec/fixtures/user.json +3 -0
- data/spec/spec_helper.rb +7 -0
- data/spec/tinder/bot_spec.rb +41 -0
- data/spec/tinder/client_spec.rb +118 -0
- data/tinderbot.gemspec +30 -0
- metadata +183 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 00e856dd541aa48de6a2e9fc02d33dbfc9d55a65
|
4
|
+
data.tar.gz: b059da4facf4db2ff64b80067d45f5f9642b4cf1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7181c4ac6fb5ab568fbd525a1b535003e25d66072685424d9eb340eab84c392aa557eb8de9f08a129fd349f301ed1a99c1dbb339625143212d5c0e03d33f25c7
|
7
|
+
data.tar.gz: 5ab43184640e78d9b5e849323fe0935fe3ba3b83f25fc4e9cf1bc15fbf7424a4478fba109552602ea4b3679931dcdf226d823aa572a4959cc5aa765961b7fcb0
|
data/.gitignore
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
*.log
|
23
|
+
mkmf.log
|
24
|
+
.idea
|
25
|
+
facebook_credentials.pstore
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Jeremy Venezia
|
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,98 @@
|
|
1
|
+
# Tinderbot
|
2
|
+
|
3
|
+
[](https://travis-ci.org/jvenezia/tinderbot)
|
4
|
+
|
5
|
+
Tinderbot is a ruby wrapper for the Tinder API.
|
6
|
+
|
7
|
+
It also contains a bot which automatically like recommended people.
|
8
|
+
|
9
|
+
It can be used in ruby, or in command line.
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
Add this line to your application's Gemfile:
|
14
|
+
|
15
|
+
gem 'tinderbot'
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install tinderbot
|
20
|
+
|
21
|
+
|
22
|
+
## Getting your facebook authentication token
|
23
|
+
|
24
|
+
You'll need to supply a facebook authentication token and an associated facebook id.
|
25
|
+
|
26
|
+
You can get those manually by getting to this link:
|
27
|
+
https://www.facebook.com/dialog/oauth?client_id=464891386855067&redirect_uri=https://www.facebook.com/connect/login_success.html&scope=basic_info,email,public_profile,user_about_me,user_activities,user_birthday,user_education_history,user_friends,user_interests,user_likes,user_location,user_photos,user_relationship_details&response_type=token
|
28
|
+
Sign in, then pick up your authentication token from the **access_token** param in the url.
|
29
|
+
Get your facebook user id with this [online tool](http://findmyfacebookid.com/) by providing your profile url.
|
30
|
+
|
31
|
+
Tinderbot also provides a script to get your facebook credentials.
|
32
|
+
```ruby
|
33
|
+
facebook_email = 'your facebook email'
|
34
|
+
facebook_password = 'your facebook password'
|
35
|
+
|
36
|
+
facebook_authentication_token, facebook_user_id = Tinderbot::Facebook.get_credentials(facebook_email, facebook_password)
|
37
|
+
```
|
38
|
+
|
39
|
+
## Usage
|
40
|
+
### Authenticating
|
41
|
+
|
42
|
+
Once you get your credentials, you can sign in to Tinder.
|
43
|
+
```ruby
|
44
|
+
facebook_authentication_token = 'your facebook authentication token'
|
45
|
+
facebook_user_id = 'your facebook user id'
|
46
|
+
|
47
|
+
tinder_client = Tinderbot::Tinder::Client.new
|
48
|
+
tinder_authentication_token = tinder_client.get_authentication_token(facebook_authentication_token, facebook_user_id)
|
49
|
+
tinder_client.sign_in tinder_authentication_token
|
50
|
+
```
|
51
|
+
|
52
|
+
### Interacting with the Tinder API
|
53
|
+
```ruby
|
54
|
+
tinder_client.me
|
55
|
+
tinder_client.user(user_id)
|
56
|
+
tinder_client.updates
|
57
|
+
tinder_client.recommended_users
|
58
|
+
tinder_client.like(user_id)
|
59
|
+
tinder_client.like_all(user_ids)
|
60
|
+
tinder_client.dislike(user_id)
|
61
|
+
tinder_client.dislike_all(user_ids)
|
62
|
+
tinder_client.send_message(user_id, message)
|
63
|
+
```
|
64
|
+
|
65
|
+
### Using the bot
|
66
|
+
Tinderbot provides a simple bot which automatically likes all recommended people. It stops when there is no more recommended people.
|
67
|
+
```ruby
|
68
|
+
tinder_bot = Tinderbot::Tinder::Bot.new tinder_client
|
69
|
+
tinder_bot.like_recommended_people
|
70
|
+
```
|
71
|
+
|
72
|
+
### Using the command line tool
|
73
|
+
You can interact with Tinderbot with command lines.
|
74
|
+
```
|
75
|
+
> tinderbot
|
76
|
+
Commands:
|
77
|
+
tinderbot autolike # Automatically like recommended people. Stops when there is no more people to like.
|
78
|
+
tinderbot dislike USER_ID # Dislike user.
|
79
|
+
tinderbot help [COMMAND] # Describe available commands or one specific command
|
80
|
+
tinderbot like USER_ID # Like user.
|
81
|
+
tinderbot me # Get your profile data.
|
82
|
+
tinderbot recommended # Get recommended users.
|
83
|
+
tinderbot send USER_ID MESSAGE # Sends message to user
|
84
|
+
tinderbot updates # Get updates
|
85
|
+
tinderbot user USER_ID # Get user profile data.
|
86
|
+
```
|
87
|
+
|
88
|
+
## Contributing
|
89
|
+
Feel free to contribute !
|
90
|
+
|
91
|
+
1. Fork it ( https://github.com/jvenezia/tinderbot/fork )
|
92
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
93
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
94
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
95
|
+
5. Create a new Pull Request
|
96
|
+
|
97
|
+
## Licence
|
98
|
+
Released under the MIT License, which can be found in `LICENSE.txt`.
|
data/Rakefile
ADDED
data/bin/tinderbot
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
require 'pstore'
|
2
|
+
|
3
|
+
module Tinderbot
|
4
|
+
module Cli
|
5
|
+
class Application < Thor
|
6
|
+
FACEBOOK_CREDENTIALS_FILE = 'facebook_credentials.pstore'
|
7
|
+
|
8
|
+
desc 'me', 'Get your profile data.'
|
9
|
+
def me
|
10
|
+
tinder_client = sign_in
|
11
|
+
puts tinder_client.me
|
12
|
+
end
|
13
|
+
|
14
|
+
desc 'user USER_ID', 'Get user profile data.'
|
15
|
+
def user(user_id)
|
16
|
+
tinder_client = sign_in
|
17
|
+
puts tinder_client.user user_id
|
18
|
+
end
|
19
|
+
|
20
|
+
desc 'updates', 'Get updates'
|
21
|
+
def updates
|
22
|
+
tinder_client = sign_in
|
23
|
+
puts tinder_client.updates
|
24
|
+
end
|
25
|
+
|
26
|
+
desc 'recommended', 'Get recommended users.'
|
27
|
+
def recommended
|
28
|
+
tinder_client = sign_in
|
29
|
+
puts tinder_client.recommended_users
|
30
|
+
end
|
31
|
+
|
32
|
+
desc 'like USER_ID', 'Like user.'
|
33
|
+
def like(user_id)
|
34
|
+
tinder_client = sign_in
|
35
|
+
puts tinder_client.like user_id
|
36
|
+
end
|
37
|
+
|
38
|
+
desc 'dislike USER_ID', 'Dislike user.'
|
39
|
+
def dislike(user_id)
|
40
|
+
tinder_client = sign_in
|
41
|
+
puts tinder_client.dislike user_id
|
42
|
+
end
|
43
|
+
|
44
|
+
desc 'send USER_ID MESSAGE', 'Sends message to user'
|
45
|
+
def send(user_id, message)
|
46
|
+
tinder_client = sign_in
|
47
|
+
puts tinder_client.send_message user_id, message
|
48
|
+
end
|
49
|
+
|
50
|
+
desc 'autolike', 'Automatically like recommended people. Stops when there is no more people to like.'
|
51
|
+
def autolike
|
52
|
+
tinder_client = sign_in
|
53
|
+
|
54
|
+
puts 'Starting likes...'
|
55
|
+
tinder_bot = Tinderbot::Tinder::Bot.new tinder_client
|
56
|
+
tinder_bot.like_recommended_people
|
57
|
+
end
|
58
|
+
|
59
|
+
private
|
60
|
+
|
61
|
+
def sign_in
|
62
|
+
puts 'Connecting to tinder...'
|
63
|
+
tinder_client = Tinderbot::Tinder::Client.new
|
64
|
+
store = PStore.new(FACEBOOK_CREDENTIALS_FILE)
|
65
|
+
facebook_authentication_token, facebook_user_id = get_last_facebook_credentials(store)
|
66
|
+
tinder_authentication_token = get_tinder_authentication_token(store, tinder_client, facebook_authentication_token, facebook_user_id)
|
67
|
+
tinder_client.sign_in tinder_authentication_token
|
68
|
+
tinder_client
|
69
|
+
end
|
70
|
+
|
71
|
+
def get_tinder_authentication_token(store, tinder_client, facebook_authentication_token, facebook_user_id)
|
72
|
+
tinder_authentication_token = tinder_client.get_authentication_token(facebook_authentication_token, facebook_user_id)
|
73
|
+
unless tinder_authentication_token
|
74
|
+
facebook_authentication_token, facebook_user_id = get_facebook_credentials
|
75
|
+
store_facebook_credentials(store, facebook_authentication_token, facebook_user_id)
|
76
|
+
tinder_authentication_token = tinder_client.get_authentication_token(facebook_authentication_token, facebook_user_id)
|
77
|
+
end
|
78
|
+
tinder_authentication_token
|
79
|
+
end
|
80
|
+
|
81
|
+
def get_facebook_credentials
|
82
|
+
puts 'Enter your facebook credentials.'
|
83
|
+
facebook_email = ask('Email:')
|
84
|
+
facebook_password = ask('Password (typing will be hidden):', echo: false)
|
85
|
+
puts "\n"
|
86
|
+
|
87
|
+
puts 'Getting your facebook authentication token...'
|
88
|
+
facebook_authentication_token, facebook_user_id = Tinderbot::Facebook.get_credentials(facebook_email, facebook_password)
|
89
|
+
return facebook_authentication_token, facebook_user_id
|
90
|
+
end
|
91
|
+
|
92
|
+
def get_last_facebook_credentials(store)
|
93
|
+
facebook_authentication_token = store.transaction { store[:facebook_authentication_token] }
|
94
|
+
facebook_user_id = store.transaction { store[:facebook_user_id] }
|
95
|
+
return facebook_authentication_token, facebook_user_id
|
96
|
+
end
|
97
|
+
|
98
|
+
def store_facebook_credentials(store, facebook_authentication_token, facebook_user_id)
|
99
|
+
store.transaction do
|
100
|
+
store[:facebook_authentication_token] = facebook_authentication_token
|
101
|
+
store[:facebook_user_id] = facebook_user_id
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Tinderbot
|
2
|
+
class Facebook
|
3
|
+
FACEBOOK_AUTHENTICATION_TOKEN_URL = 'https://www.facebook.com/dialog/oauth?client_id=464891386855067&redirect_uri=https://www.facebook.com/connect/login_success.html&scope=basic_info,email,public_profile,user_about_me,user_activities,user_birthday,user_education_history,user_friends,user_interests,user_likes,user_location,user_photos,user_relationship_details&response_type=token'
|
4
|
+
|
5
|
+
def self.get_credentials(facebook_email, facebook_password)
|
6
|
+
browser = Watir::Browser.new
|
7
|
+
browser.goto FACEBOOK_AUTHENTICATION_TOKEN_URL
|
8
|
+
browser.text_field(id: 'email').when_present.set facebook_email
|
9
|
+
browser.text_field(id: 'pass').when_present.set facebook_password
|
10
|
+
browser.button(name: 'login').when_present.click
|
11
|
+
|
12
|
+
facebook_authentication_token = /#access_token=(.*)&expires_in/.match(browser.url).captures[0]
|
13
|
+
|
14
|
+
browser.goto 'https://www.facebook.com/'
|
15
|
+
browser.link(title: 'Journal').when_present.click
|
16
|
+
facebook_user_id = /fbid=(.*)&set/.match(browser.link(class: 'profilePicThumb').when_present.href).captures[0]
|
17
|
+
|
18
|
+
browser.close
|
19
|
+
return facebook_authentication_token, facebook_user_id
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Tinderbot
|
2
|
+
module Tinder
|
3
|
+
class Bot
|
4
|
+
attr_accessor :client
|
5
|
+
|
6
|
+
def initialize(client)
|
7
|
+
@client = client
|
8
|
+
end
|
9
|
+
|
10
|
+
def like_recommended_people
|
11
|
+
recommended_people = @client.recommended_users
|
12
|
+
while recommended_people
|
13
|
+
recommended_people_ids = recommended_people.map {|r| r['_id']}
|
14
|
+
@client.like_all recommended_people_ids
|
15
|
+
recommended_people = @client.recommended_users
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
module Tinderbot
|
2
|
+
module Tinder
|
3
|
+
class Client
|
4
|
+
TINDER_API_URL = 'https://api.gotinder.com'
|
5
|
+
CONNECTION_USER_AGENT = 'Tinder/3.0.4 (iPhone; iOS 7.1; Scale/2.00)'
|
6
|
+
|
7
|
+
attr_accessor :connection
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
build_connection
|
11
|
+
end
|
12
|
+
|
13
|
+
def get_authentication_token(facebook_authentication_token, facebook_user_id)
|
14
|
+
JSON.parse(@connection.post('/auth', {facebook_token: facebook_authentication_token, facebook_id: facebook_user_id}).body)['token']
|
15
|
+
end
|
16
|
+
|
17
|
+
def sign_in(authentication_token)
|
18
|
+
@connection.token_auth(authentication_token)
|
19
|
+
@connection.headers['X-Auth-Token'] = authentication_token
|
20
|
+
end
|
21
|
+
|
22
|
+
def me
|
23
|
+
JSON.parse(@connection.get('profile').body)
|
24
|
+
end
|
25
|
+
|
26
|
+
def user(user_id)
|
27
|
+
JSON.parse(@connection.get("user/#{user_id}").body)
|
28
|
+
end
|
29
|
+
|
30
|
+
def updates
|
31
|
+
JSON.parse(@connection.get('updates').body)
|
32
|
+
end
|
33
|
+
|
34
|
+
def recommended_users
|
35
|
+
JSON.parse(@connection.post('user/recs').body)['results']
|
36
|
+
end
|
37
|
+
|
38
|
+
def like(user_id)
|
39
|
+
@connection.get "like/#{user_id}"
|
40
|
+
end
|
41
|
+
|
42
|
+
def like_all(user_ids)
|
43
|
+
user_ids.each { |user_id| like user_id }
|
44
|
+
end
|
45
|
+
|
46
|
+
def dislike(user_id)
|
47
|
+
@connection.get "pass/#{user_id}"
|
48
|
+
end
|
49
|
+
|
50
|
+
def dislike_all(user_ids)
|
51
|
+
user_ids.each { |user_id| dislike user_id }
|
52
|
+
end
|
53
|
+
|
54
|
+
def send_message(user_id, message)
|
55
|
+
@connection.post("user/matches/#{user_id}", {message: message})
|
56
|
+
end
|
57
|
+
|
58
|
+
protected
|
59
|
+
|
60
|
+
def build_connection
|
61
|
+
@connection = Faraday.new(url: TINDER_API_URL) do |faraday|
|
62
|
+
faraday.request :json
|
63
|
+
faraday.adapter Faraday.default_adapter
|
64
|
+
end
|
65
|
+
@connection.headers[:user_agent] = CONNECTION_USER_AGENT
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
data/lib/tinderbot.rb
ADDED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Tinderbot::Tinder::Bot do
|
4
|
+
let(:tinder_client) { Tinderbot::Tinder::Client.new }
|
5
|
+
let(:tinder_bot) { Tinderbot::Tinder::Bot.new(tinder_client) }
|
6
|
+
|
7
|
+
describe 'client' do
|
8
|
+
it { expect(tinder_bot.client).to eq tinder_client }
|
9
|
+
end
|
10
|
+
|
11
|
+
describe '.like_recommended_people' do
|
12
|
+
let(:recommended_people_results) { JSON.parse(open('spec/fixtures/recommended_users.json').read)['results'] }
|
13
|
+
|
14
|
+
context 'there is no recommended people' do
|
15
|
+
before { expect_any_instance_of(Tinderbot::Tinder::Client).to receive(:recommended_users).and_return(nil) }
|
16
|
+
|
17
|
+
before { expect_any_instance_of(Tinderbot::Tinder::Client).not_to receive(:like_all) }
|
18
|
+
|
19
|
+
it { tinder_bot.like_recommended_people }
|
20
|
+
end
|
21
|
+
|
22
|
+
context 'there is one set of recommended people' do
|
23
|
+
before { expect_any_instance_of(Tinderbot::Tinder::Client).to receive(:recommended_users).and_return(recommended_people_results) }
|
24
|
+
before { expect_any_instance_of(Tinderbot::Tinder::Client).to receive(:recommended_users).and_return(nil) }
|
25
|
+
|
26
|
+
before { expect_any_instance_of(Tinderbot::Tinder::Client).not_to receive(:like_all).with(recommended_people_results.map { |r| r['_id'] }).exactly(1).times }
|
27
|
+
|
28
|
+
it { tinder_bot.like_recommended_people }
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'there is two sets of recommended people' do
|
32
|
+
before { expect_any_instance_of(Tinderbot::Tinder::Client).to receive(:recommended_users).and_return(recommended_people_results) }
|
33
|
+
before { expect_any_instance_of(Tinderbot::Tinder::Client).to receive(:recommended_users).and_return(recommended_people_results) }
|
34
|
+
before { expect_any_instance_of(Tinderbot::Tinder::Client).to receive(:recommended_users).and_return(nil) }
|
35
|
+
|
36
|
+
before { expect_any_instance_of(Tinderbot::Tinder::Client).not_to receive(:like_all).with(recommended_people_results.map { |r| r['_id'] }).exactly(2).times }
|
37
|
+
|
38
|
+
it { tinder_bot.like_recommended_people }
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,118 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Tinderbot::Tinder::Client do
|
4
|
+
let(:tinder_client) { Tinderbot::Tinder::Client.new }
|
5
|
+
let(:connection) { tinder_client.connection }
|
6
|
+
|
7
|
+
describe '.connection' do
|
8
|
+
it { expect(connection).to be_a(Faraday::Connection) }
|
9
|
+
it { expect("#{connection.url_prefix.scheme}://#{connection.url_prefix.host}").to eq(Tinderbot::Tinder::Client::TINDER_API_URL) }
|
10
|
+
it { expect(connection.headers[:user_agent]).to eq(Tinderbot::Tinder::Client::CONNECTION_USER_AGENT) }
|
11
|
+
end
|
12
|
+
|
13
|
+
describe '.me' do
|
14
|
+
let(:user_response) { open('spec/fixtures/recommended_users.json').read }
|
15
|
+
|
16
|
+
before { expect(connection).to receive(:get).with('profile').and_return(connection) }
|
17
|
+
before { expect(connection).to receive(:body).and_return(user_response) }
|
18
|
+
|
19
|
+
subject { tinder_client.me }
|
20
|
+
|
21
|
+
it { should eq JSON.parse(user_response) }
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '.user' do
|
25
|
+
let(:user_id) { 'user_id' }
|
26
|
+
let(:user_response) { open('spec/fixtures/user.json').read }
|
27
|
+
|
28
|
+
before { expect(connection).to receive(:get).with("user/#{user_id}").and_return(connection) }
|
29
|
+
before { expect(connection).to receive(:body).and_return(user_response) }
|
30
|
+
|
31
|
+
subject { tinder_client.user user_id }
|
32
|
+
|
33
|
+
it { should eq JSON.parse(user_response) }
|
34
|
+
end
|
35
|
+
|
36
|
+
describe '.updates' do
|
37
|
+
let(:updates_response) { open('spec/fixtures/updates.json').read }
|
38
|
+
|
39
|
+
before { expect(connection).to receive(:get).with('updates').and_return(connection) }
|
40
|
+
before { expect(connection).to receive(:body).and_return(updates_response) }
|
41
|
+
|
42
|
+
subject { tinder_client.updates }
|
43
|
+
|
44
|
+
it { should eq JSON.parse(updates_response) }
|
45
|
+
end
|
46
|
+
|
47
|
+
describe '.recommended_users' do
|
48
|
+
let(:recommended_people_response) { open('spec/fixtures/recommended_users.json').read }
|
49
|
+
|
50
|
+
before { expect(connection).to receive(:post).with('user/recs').and_return(connection) }
|
51
|
+
before { expect(connection).to receive(:body).and_return(recommended_people_response) }
|
52
|
+
|
53
|
+
subject { tinder_client.recommended_users }
|
54
|
+
|
55
|
+
it { should eq JSON.parse(recommended_people_response)['results'] }
|
56
|
+
end
|
57
|
+
|
58
|
+
describe '.like' do
|
59
|
+
let(:user_id) { 'user_id' }
|
60
|
+
|
61
|
+
before { expect(connection).to receive(:get).with("like/#{user_id}") }
|
62
|
+
|
63
|
+
it { tinder_client.like user_id }
|
64
|
+
end
|
65
|
+
|
66
|
+
describe '.like_all' do
|
67
|
+
context 'there is no people' do
|
68
|
+
let(:people_ids) { [] }
|
69
|
+
|
70
|
+
before { expect_any_instance_of(Tinderbot::Tinder::Client).not_to receive(:like) }
|
71
|
+
|
72
|
+
it { tinder_client.like_all people_ids }
|
73
|
+
end
|
74
|
+
|
75
|
+
context 'there two people' do
|
76
|
+
let(:people_ids) { %w(user_1_id user_2_id) }
|
77
|
+
|
78
|
+
before { people_ids.each { |user_id| expect_any_instance_of(Tinderbot::Tinder::Client).to receive(:like).with(user_id) } }
|
79
|
+
|
80
|
+
it { tinder_client.like_all people_ids }
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
describe '.dislike' do
|
85
|
+
let(:user_id) { 'user_id' }
|
86
|
+
|
87
|
+
before { expect(connection).to receive(:get).with("pass/#{user_id}") }
|
88
|
+
|
89
|
+
it { tinder_client.dislike user_id }
|
90
|
+
end
|
91
|
+
|
92
|
+
describe '.dislike_all' do
|
93
|
+
context 'there is no people' do
|
94
|
+
let(:people_ids) { [] }
|
95
|
+
|
96
|
+
before { expect_any_instance_of(Tinderbot::Tinder::Client).not_to receive(:dislike) }
|
97
|
+
|
98
|
+
it { tinder_client.dislike_all people_ids }
|
99
|
+
end
|
100
|
+
|
101
|
+
context 'there two people' do
|
102
|
+
let(:people_ids) { %w(user_1_id user_2_id) }
|
103
|
+
|
104
|
+
before { people_ids.each { |user_id| expect_any_instance_of(Tinderbot::Tinder::Client).to receive(:dislike).with(user_id) } }
|
105
|
+
|
106
|
+
it { tinder_client.dislike_all people_ids }
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
describe '.send_message' do
|
111
|
+
let(:user_id) { 'user_id' }
|
112
|
+
let(:message) { 'message' }
|
113
|
+
|
114
|
+
before { expect(connection).to receive(:post).with("user/matches/#{user_id}", {message: message}) }
|
115
|
+
|
116
|
+
it { tinder_client.send_message user_id, message }
|
117
|
+
end
|
118
|
+
end
|
data/tinderbot.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'tinderbot/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'tinderbot'
|
8
|
+
spec.version = Tinderbot::VERSION
|
9
|
+
spec.authors = ['Jeremy Venezia']
|
10
|
+
spec.email = ['veneziajeremy@gmail.com']
|
11
|
+
spec.summary = %q{Ruby wrapper for the Tinder API and automatic liker bot.}
|
12
|
+
spec.description = %q{Ruby wrapper for the Tinder API and automatic liker bot. }
|
13
|
+
spec.homepage = 'https://github.com/jvenezia/tinderbot'
|
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_development_dependency 'bundler', '~> 1.6'
|
22
|
+
spec.add_development_dependency 'rake', '~> 10.3'
|
23
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
24
|
+
|
25
|
+
spec.add_dependency 'thor', '~> 0'
|
26
|
+
spec.add_dependency 'faraday', '~> 0'
|
27
|
+
spec.add_dependency 'faraday_middleware', '~> 0'
|
28
|
+
spec.add_dependency 'watir-webdriver', '~> 0'
|
29
|
+
spec.add_dependency 'json', '~> 1.8'
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,183 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: tinderbot
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.4
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jeremy Venezia
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-08-24 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: thor
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: faraday
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: faraday_middleware
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: watir-webdriver
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: json
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '1.8'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '1.8'
|
125
|
+
description: 'Ruby wrapper for the Tinder API and automatic liker bot. '
|
126
|
+
email:
|
127
|
+
- veneziajeremy@gmail.com
|
128
|
+
executables:
|
129
|
+
- tinderbot
|
130
|
+
extensions: []
|
131
|
+
extra_rdoc_files: []
|
132
|
+
files:
|
133
|
+
- ".gitignore"
|
134
|
+
- ".travis.yml"
|
135
|
+
- Gemfile
|
136
|
+
- LICENSE.txt
|
137
|
+
- README.md
|
138
|
+
- Rakefile
|
139
|
+
- bin/tinderbot
|
140
|
+
- lib/tinderbot.rb
|
141
|
+
- lib/tinderbot/cli/application.rb
|
142
|
+
- lib/tinderbot/facebook.rb
|
143
|
+
- lib/tinderbot/tinder/bot.rb
|
144
|
+
- lib/tinderbot/tinder/client.rb
|
145
|
+
- lib/tinderbot/version.rb
|
146
|
+
- spec/fixtures/recommended_users.json
|
147
|
+
- spec/fixtures/updates.json
|
148
|
+
- spec/fixtures/user.json
|
149
|
+
- spec/spec_helper.rb
|
150
|
+
- spec/tinder/bot_spec.rb
|
151
|
+
- spec/tinder/client_spec.rb
|
152
|
+
- tinderbot.gemspec
|
153
|
+
homepage: https://github.com/jvenezia/tinderbot
|
154
|
+
licenses:
|
155
|
+
- MIT
|
156
|
+
metadata: {}
|
157
|
+
post_install_message:
|
158
|
+
rdoc_options: []
|
159
|
+
require_paths:
|
160
|
+
- lib
|
161
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
162
|
+
requirements:
|
163
|
+
- - ">="
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: '0'
|
166
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
167
|
+
requirements:
|
168
|
+
- - ">="
|
169
|
+
- !ruby/object:Gem::Version
|
170
|
+
version: '0'
|
171
|
+
requirements: []
|
172
|
+
rubyforge_project:
|
173
|
+
rubygems_version: 2.2.2
|
174
|
+
signing_key:
|
175
|
+
specification_version: 4
|
176
|
+
summary: Ruby wrapper for the Tinder API and automatic liker bot.
|
177
|
+
test_files:
|
178
|
+
- spec/fixtures/recommended_users.json
|
179
|
+
- spec/fixtures/updates.json
|
180
|
+
- spec/fixtures/user.json
|
181
|
+
- spec/spec_helper.rb
|
182
|
+
- spec/tinder/bot_spec.rb
|
183
|
+
- spec/tinder/client_spec.rb
|