okc_bot 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 11f11ab321599339e088f46f39fb9a7d0b88476f
4
+ data.tar.gz: ba03ab20dbbc17ece4f9760bd02f1184631b40ef
5
+ SHA512:
6
+ metadata.gz: ed00ae805ed8fd6d99f7f879f2f367634d0e3fd66da55ed6ddc916bcec2ee22b24151acb9e54295f15f75aad622d197135a708df04d6cb56ca221558ca3993d5
7
+ data.tar.gz: e7c6d79241c7244f8f833880c4abf5062507f49bdec2010b3e0275f8fbf89a4e3363808d59ceb4e7364740aa5a18dfc2bf68811f39b5cb31b6b8e9d782a3e2de
Binary file
@@ -0,0 +1,6 @@
1
+ .env
2
+ workflow.rb
3
+ *.js
4
+ okcupid4.rb
5
+ .DS_STORE
6
+ *.gem
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem "watir-webdriver"
4
+ gem "watir-scroll"
5
+ gem "webdriver-user-agent"
6
+ gem "chromedriver-helper"
7
+ gem 'redis'
8
+ gem 'chronic'
9
+ gem 'time-lord'
10
+ gem 'dotenv'
@@ -0,0 +1,55 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ archive-zip (0.7.0)
5
+ io-like (~> 0.3.0)
6
+ childprocess (0.5.6)
7
+ ffi (~> 1.0, >= 1.0.11)
8
+ chromedriver-helper (1.0.0)
9
+ archive-zip (~> 0.7.0)
10
+ nokogiri (~> 1.6)
11
+ chronic (0.10.2)
12
+ dotenv (2.0.2)
13
+ facets (3.0.0)
14
+ ffi (1.9.10)
15
+ io-like (0.3.0)
16
+ json (1.8.3)
17
+ mini_portile (0.6.2)
18
+ multi_json (1.11.2)
19
+ nokogiri (1.6.6.2)
20
+ mini_portile (~> 0.6.0)
21
+ psych (2.0.15)
22
+ redis (3.2.1)
23
+ rubyzip (1.1.7)
24
+ selenium-webdriver (2.47.1)
25
+ childprocess (~> 0.5)
26
+ multi_json (~> 1.0)
27
+ rubyzip (~> 1.0)
28
+ websocket (~> 1.0)
29
+ time-lord (1.0.1)
30
+ watir-scroll (0.1.0)
31
+ watir-webdriver
32
+ watir-webdriver (0.8.0)
33
+ selenium-webdriver (>= 2.46.2)
34
+ webdriver-user-agent (7.3)
35
+ facets
36
+ json
37
+ psych
38
+ selenium-webdriver
39
+ websocket (1.2.2)
40
+
41
+ PLATFORMS
42
+ ruby
43
+
44
+ DEPENDENCIES
45
+ chromedriver-helper
46
+ chronic
47
+ dotenv
48
+ redis
49
+ time-lord
50
+ watir-scroll
51
+ watir-webdriver
52
+ webdriver-user-agent
53
+
54
+ BUNDLED WITH
55
+ 1.10.5
@@ -0,0 +1,44 @@
1
+ # OKCleanup
2
+ Clean up your OKCupid inbox!
3
+
4
+ Are you getting too many okcupid messages to deal with? Now you can easily bulk delete in batches.
5
+
6
+ ## Requirements
7
+ - chromedriver
8
+ - phantomjs
9
+ - ruby (tested only in ruby 1.9.3-p194)
10
+
11
+ ## Installation
12
+ 1. Clone to your computer
13
+ `git clone http://github.com/prokizzle/okcleanup ~/okcleanup`
14
+ 1. Install the headless browsers
15
+ `brew install chromedriver phantomjs`
16
+ 1. Install required gems
17
+ `bundle install`
18
+
19
+ ## Usage
20
+ - run `ruby bin/okcleanup`
21
+ - select one of the options
22
+
23
+ ## Available cleanup options
24
+
25
+ ### Match messages
26
+ This deletes all messages that say "It's a match!"
27
+
28
+ ### Replied messages
29
+ Deletes all threads that you have replied to
30
+
31
+ ### Missed IMs
32
+ Deletes all missed instant message notification from your messages inbox
33
+
34
+ ### No photo
35
+ Deletes all messages from people without photos. This includes people who did not post a photo and people who have closed or disabled their accounts.
36
+
37
+ ### Delete all
38
+ Deletes every message from the inbox (or tries to). It asks for confirmation first.
39
+
40
+ ### Delete last page
41
+ Deletes only the final page of your messages, aka the oldest messages in your inbox.
42
+
43
+ ## Known Issues
44
+ PhantomJS pretty much doesn't work right or consistently. I should probably spoof the user agent and try again.
@@ -0,0 +1,2 @@
1
+ #!/bin/ruby
2
+ require_relative ''../lib/okc_bot'
Binary file
@@ -0,0 +1,12 @@
1
+ require_relative "okc_bot/version"
2
+ require 'watir-webdriver'
3
+ require 'watir-scroll'
4
+ require 'webdriver-user-agent'
5
+
6
+ module OkcBot
7
+
8
+ Dir[File.dirname(__FILE__) + '/okc_bot/*.rb'].each do |file|
9
+ require file
10
+ end
11
+
12
+ end
@@ -0,0 +1,113 @@
1
+ module OkcBot
2
+
3
+ class Browser
4
+ attr_reader :browser, :driver, :base_url
5
+
6
+ def initialize(args)
7
+ @username = args[:username]
8
+ @password = args[:password]
9
+ @driver = args[:driver].to_sym
10
+ @browser = Watir::Browser.new driver
11
+ @base_url = "http://www.okcupid.com"
12
+ end
13
+
14
+
15
+ private
16
+
17
+ def visit(page)
18
+ begin
19
+ @browser.goto "#{@base_url}/#{page}"
20
+ rescue Errno::ECONNREFUSED
21
+ puts "Webdriver reconnecting..."
22
+ @browser = Watir::Browser.new $driver.to_sym
23
+ login
24
+ @browser.goto "#{@base_url}/#{page}"
25
+ end
26
+ end
27
+
28
+ def logged_in?
29
+ # return @browser.h1(:id => 'home_heading').exists?
30
+ return true
31
+ end
32
+
33
+ public
34
+
35
+ def save_session
36
+ @browser.cookies.to_a
37
+ end
38
+
39
+ def load_session(saved_cookies)
40
+ @browser.goto("https://okcupid.com")
41
+ @browser.cookies.clear
42
+ saved_cookies.each do |saved_cookie|
43
+ @browser.cookies.add(saved_cookie[:name], saved_cookie[:value])
44
+ end
45
+ @browser.goto("https://okcupid.com")
46
+ end
47
+
48
+
49
+ def load_more_messages
50
+ @before = @browser.spans(:class => "previewline").to_a.size
51
+ @browser.scroll.to :bottom
52
+ sleep 1
53
+ @after = @browser.spans(:class => "previewline").to_a.size
54
+ end
55
+
56
+ def no_new_messages_found
57
+ @before == @after
58
+ end
59
+
60
+ def load_entire_page
61
+ load_more_messages
62
+ unless no_new_messages_found
63
+ load_entire_page
64
+ else
65
+ @browser.scroll.to :top
66
+ end
67
+ end
68
+
69
+ # randomized delays between actions minimizes bot detection
70
+ def login
71
+ @browser.goto("http://www.okcupid.com")
72
+ @browser.link(:text => "Sign in").click
73
+ sleep (1..3).to_a.sample.to_i
74
+ @browser.text_field(:id => 'login_username').set(@username)
75
+ sleep (1..3).to_a.sample.to_i
76
+ @browser.text_field(:id => 'login_password').set(@password)
77
+ sleep (1..3).to_a.sample.to_i
78
+ @browser.button(:id => 'sign_in_button').click
79
+ sleep (1..3).to_a.sample.to_i
80
+
81
+ return logged_in?
82
+ end
83
+
84
+
85
+ def visit_messages_page
86
+ visit "messages"
87
+ load_entire_page
88
+
89
+ end
90
+
91
+ def visit_quickmatch_page
92
+ visit "quickmatch"
93
+ end
94
+
95
+ def visit_im_history_page
96
+ visit "imhistory"
97
+ end
98
+
99
+ def visit_sent_messages_page
100
+ visit "messages?folder=2"
101
+ end
102
+
103
+ def visit_match_page
104
+ visit "match"
105
+ end
106
+
107
+ def logout
108
+ @browser.close
109
+ end
110
+
111
+ end
112
+
113
+ end
@@ -0,0 +1,16 @@
1
+ module OkcBot
2
+
3
+ class Main
4
+ attr_reader :auth
5
+
6
+ def initialize()
7
+ @auth = Browser.new(username: @username, password: @password, driver: @driver)
8
+ @auth.login
9
+ end
10
+
11
+ def exit
12
+ @auth.logout
13
+ end
14
+
15
+ end
16
+ end
@@ -0,0 +1,3 @@
1
+ module OkcBot
2
+ VERSION = "0.9.0"
3
+ end
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'okc_bot/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "okc_bot"
8
+ spec.version = OkcBot::VERSION
9
+ spec.authors = ["Nick Prokesch"]
10
+ spec.email = ["nick@prokes.ch"]
11
+ spec.summary = %q{A library for building okcupid bots}
12
+ spec.description = %q{Allows users to build bots that use okcupid}
13
+ spec.homepage = "http://nick.prokes.ch"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.require_paths = ["lib"]
18
+
19
+ spec.add_dependency "dotenv", "~> 2.0"
20
+ spec.add_dependency "watir-webdriver", "~> 0.8"
21
+ spec.add_dependency "webdriver-user-agent", "~> 7.3"
22
+ spec.add_dependency "watir-scroll", "~> 0.1"
23
+ end
metadata ADDED
@@ -0,0 +1,112 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: okc_bot
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.0
5
+ platform: ruby
6
+ authors:
7
+ - Nick Prokesch
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-08-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: dotenv
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: watir-webdriver
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.8'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.8'
41
+ - !ruby/object:Gem::Dependency
42
+ name: webdriver-user-agent
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '7.3'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '7.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: watir-scroll
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.1'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.1'
69
+ description: Allows users to build bots that use okcupid
70
+ email:
71
+ - nick@prokes.ch
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".DS_Store"
77
+ - ".gitignore"
78
+ - Gemfile
79
+ - Gemfile.lock
80
+ - README.md
81
+ - bin/okc_bot
82
+ - lib/.DS_Store
83
+ - lib/okc_bot.rb
84
+ - lib/okc_bot/browser.rb
85
+ - lib/okc_bot/main.rb
86
+ - lib/okc_bot/version.rb
87
+ - okc_bot.gemspec
88
+ homepage: http://nick.prokes.ch
89
+ licenses:
90
+ - MIT
91
+ metadata: {}
92
+ post_install_message:
93
+ rdoc_options: []
94
+ require_paths:
95
+ - lib
96
+ required_ruby_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ required_rubygems_version: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
106
+ requirements: []
107
+ rubyforge_project:
108
+ rubygems_version: 2.4.8
109
+ signing_key:
110
+ specification_version: 4
111
+ summary: A library for building okcupid bots
112
+ test_files: []