ruby-unfollow 0.0.5
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/.document +5 -0
- data/Gemfile +15 -0
- data/Gemfile.lock +64 -0
- data/LICENSE +25 -0
- data/README.rdoc +20 -0
- data/Rakefile +51 -0
- data/VERSION +1 -0
- data/bin/ruby-unfollow +109 -0
- data/lib/ruby-unfollow.rb +253 -0
- data/lib/ruby-unfollow/color.rb +8 -0
- data/ruby-unfollow.gemspec +63 -0
- metadata +127 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: b96f7a18e27638f83bd1e64baa96bae13e0bbad3
|
|
4
|
+
data.tar.gz: a6795233d5cb394a55fed0044c8181e42a3c5183
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: ada6058ab93e308840fde62d63742e00e6bd71fab9028b1b7fb5992d04b0e5da3d7e5d6c54e34cb40affec6a829c3263e7cdf16305a08edaee72af03facd0008
|
|
7
|
+
data.tar.gz: c5ba35c86c3b4c192fcb4a1a1fc727636555c5b0b25f22fdb076d90f60df3cd0e5ac675427e2c51cbc8701cf0e5c3396c8901ce9bff2c926eeaba7889b2226b2
|
data/.document
ADDED
data/Gemfile
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
source "http://rubygems.org"
|
|
2
|
+
# Add dependencies required to use your gem here.
|
|
3
|
+
# Example:
|
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
|
5
|
+
|
|
6
|
+
# Add dependencies to develop your gem here.
|
|
7
|
+
# Include everything needed to run rake, tests, features, etc.
|
|
8
|
+
gem "twitter_oauth", ">= 0.4.94"
|
|
9
|
+
gem "json", ">= 1.7.6"
|
|
10
|
+
|
|
11
|
+
group :development do
|
|
12
|
+
gem "rdoc", "~> 3.12"
|
|
13
|
+
gem "bundler", "~> 1.0"
|
|
14
|
+
gem "jeweler", "~> 2.0.1"
|
|
15
|
+
end
|
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
GEM
|
|
2
|
+
remote: http://rubygems.org/
|
|
3
|
+
specs:
|
|
4
|
+
addressable (2.3.6)
|
|
5
|
+
builder (3.2.2)
|
|
6
|
+
descendants_tracker (0.0.4)
|
|
7
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
|
8
|
+
faraday (0.9.0)
|
|
9
|
+
multipart-post (>= 1.2, < 3)
|
|
10
|
+
git (1.2.8)
|
|
11
|
+
github_api (0.12.1)
|
|
12
|
+
addressable (~> 2.3)
|
|
13
|
+
descendants_tracker (~> 0.0.4)
|
|
14
|
+
faraday (~> 0.8, < 0.10)
|
|
15
|
+
hashie (>= 3.2)
|
|
16
|
+
multi_json (>= 1.7.5, < 2.0)
|
|
17
|
+
nokogiri (~> 1.6.3)
|
|
18
|
+
oauth2
|
|
19
|
+
hashie (3.3.1)
|
|
20
|
+
highline (1.6.21)
|
|
21
|
+
jeweler (2.0.1)
|
|
22
|
+
builder
|
|
23
|
+
bundler (>= 1.0)
|
|
24
|
+
git (>= 1.2.5)
|
|
25
|
+
github_api
|
|
26
|
+
highline (>= 1.6.15)
|
|
27
|
+
nokogiri (>= 1.5.10)
|
|
28
|
+
rake
|
|
29
|
+
rdoc
|
|
30
|
+
json (1.8.1)
|
|
31
|
+
jwt (1.0.0)
|
|
32
|
+
mime-types (2.4.1)
|
|
33
|
+
mini_portile (0.6.0)
|
|
34
|
+
multi_json (1.10.1)
|
|
35
|
+
multi_xml (0.5.5)
|
|
36
|
+
multipart-post (2.0.0)
|
|
37
|
+
nokogiri (1.6.3.1)
|
|
38
|
+
mini_portile (= 0.6.0)
|
|
39
|
+
oauth (0.4.7)
|
|
40
|
+
oauth2 (1.0.0)
|
|
41
|
+
faraday (>= 0.8, < 0.10)
|
|
42
|
+
jwt (~> 1.0)
|
|
43
|
+
multi_json (~> 1.3)
|
|
44
|
+
multi_xml (~> 0.5)
|
|
45
|
+
rack (~> 1.2)
|
|
46
|
+
rack (1.5.2)
|
|
47
|
+
rake (10.3.2)
|
|
48
|
+
rdoc (3.12.2)
|
|
49
|
+
json (~> 1.4)
|
|
50
|
+
thread_safe (0.3.4)
|
|
51
|
+
twitter_oauth (0.4.94)
|
|
52
|
+
json (>= 1.8.0)
|
|
53
|
+
mime-types (>= 1.16)
|
|
54
|
+
oauth (>= 0.4.7)
|
|
55
|
+
|
|
56
|
+
PLATFORMS
|
|
57
|
+
ruby
|
|
58
|
+
|
|
59
|
+
DEPENDENCIES
|
|
60
|
+
bundler (~> 1.0)
|
|
61
|
+
jeweler (~> 2.0.1)
|
|
62
|
+
json (>= 1.7.6)
|
|
63
|
+
rdoc (~> 3.12)
|
|
64
|
+
twitter_oauth (>= 0.4.94)
|
data/LICENSE
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
This is free and unencumbered software released into the public domain.
|
|
2
|
+
|
|
3
|
+
Anyone is free to copy, modify, publish, use, compile, sell, or
|
|
4
|
+
distribute this software, either in source code form or as a compiled
|
|
5
|
+
binary, for any purpose, commercial or non-commercial, and by any
|
|
6
|
+
means.
|
|
7
|
+
|
|
8
|
+
In jurisdictions that recognize copyright laws, the author or authors
|
|
9
|
+
of this software dedicate any and all copyright interest in the
|
|
10
|
+
software to the public domain. We make this dedication for the benefit
|
|
11
|
+
of the public at large and to the detriment of our heirs and
|
|
12
|
+
successors. We intend this dedication to be an overt act of
|
|
13
|
+
relinquishment in perpetuity of all present and future rights to this
|
|
14
|
+
software under copyright law.
|
|
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 NONINFRINGEMENT.
|
|
19
|
+
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
20
|
+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
21
|
+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
22
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
|
23
|
+
|
|
24
|
+
For more information, please refer to <http://unlicense.org>
|
|
25
|
+
|
data/README.rdoc
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
= ruby-unfollow
|
|
2
|
+
|
|
3
|
+
Automatically find unfollower and inactive user to unfollow
|
|
4
|
+
|
|
5
|
+
== Contributing to ruby-unfollow
|
|
6
|
+
|
|
7
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
|
8
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
|
9
|
+
* Fork the project.
|
|
10
|
+
* Start a feature/bugfix branch.
|
|
11
|
+
* Commit and push until you are happy with your contribution.
|
|
12
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
|
13
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
|
14
|
+
|
|
15
|
+
== Copyleft
|
|
16
|
+
|
|
17
|
+
2014 TheZ3ro [io@thezero.org]
|
|
18
|
+
|
|
19
|
+
See LICENSE.txt for further details.
|
|
20
|
+
|
data/Rakefile
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'rubygems'
|
|
4
|
+
require 'bundler'
|
|
5
|
+
begin
|
|
6
|
+
Bundler.setup(:default, :development)
|
|
7
|
+
rescue Bundler::BundlerError => e
|
|
8
|
+
$stderr.puts e.message
|
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
|
10
|
+
exit e.status_code
|
|
11
|
+
end
|
|
12
|
+
require 'rake'
|
|
13
|
+
|
|
14
|
+
require 'jeweler'
|
|
15
|
+
Jeweler::Tasks.new do |gem|
|
|
16
|
+
# gem is a Gem::Specification... see http://guides.rubygems.org/specification-reference/ for more options
|
|
17
|
+
gem.name = "ruby-unfollow"
|
|
18
|
+
gem.version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
|
19
|
+
gem.homepage = "https://github.com/thez3ro/ruby-unfollow"
|
|
20
|
+
gem.license = "Unlicense"
|
|
21
|
+
gem.summary = %Q{Automatically find unfollower and inactive user to unfollow}
|
|
22
|
+
gem.email = "io@thezero.org"
|
|
23
|
+
gem.authors = ["thez3ro"]
|
|
24
|
+
# dependencies defined in Gemfile
|
|
25
|
+
end
|
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
|
27
|
+
|
|
28
|
+
require 'rake/testtask'
|
|
29
|
+
Rake::TestTask.new(:test) do |test|
|
|
30
|
+
test.libs << 'lib' << 'test'
|
|
31
|
+
test.pattern = 'test/**/test_*.rb'
|
|
32
|
+
test.verbose = true
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
desc "Code coverage detail"
|
|
36
|
+
task :simplecov do
|
|
37
|
+
ENV['COVERAGE'] = "true"
|
|
38
|
+
Rake::Task['test'].execute
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
task :default => :test
|
|
42
|
+
|
|
43
|
+
require 'rdoc/task'
|
|
44
|
+
Rake::RDocTask.new do |rdoc|
|
|
45
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
|
46
|
+
|
|
47
|
+
rdoc.rdoc_dir = 'rdoc'
|
|
48
|
+
rdoc.title = "ruby-unfollow #{version}"
|
|
49
|
+
rdoc.rdoc_files.include('README*')
|
|
50
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
|
51
|
+
end
|
data/VERSION
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0.0.5
|
data/bin/ruby-unfollow
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
#Dir.chdir(File.split(__FILE__)[0])
|
|
4
|
+
#$LOAD_PATH << './'
|
|
5
|
+
|
|
6
|
+
require 'optparse'
|
|
7
|
+
require 'ruby-unfollow'
|
|
8
|
+
|
|
9
|
+
begin
|
|
10
|
+
options = OpenStruct.new
|
|
11
|
+
options.type = :all
|
|
12
|
+
options.unfollow = false
|
|
13
|
+
options.max_days = 15
|
|
14
|
+
options.list = 10
|
|
15
|
+
options.file = ""
|
|
16
|
+
|
|
17
|
+
opt_parser = OptionParser.new do |opts|
|
|
18
|
+
opts.banner = "Usage: ruby-unfollow [options]"
|
|
19
|
+
|
|
20
|
+
opts.separator ""
|
|
21
|
+
opts.separator "Specific options:"
|
|
22
|
+
|
|
23
|
+
opts.on("-s","--show TYPE", [:inactive, :unfollower, :and, :or, :all],
|
|
24
|
+
"Select follower type to show (inactive, unfollower, and, or, all)",
|
|
25
|
+
"and = inactive and unfollower","or = inactive or unfollower") do |t|
|
|
26
|
+
options.type = t
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
opts.on("-d","--day [DAY]", Float, "Select inactive days limit (default: 15 days)") do |d|
|
|
30
|
+
options.max_days = d
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
opts.on("-l", "--list [N]", Integer, "List users N by N (default: 10 users)") do |l|
|
|
34
|
+
options.list = l
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
opts.on("-F", "--file [FILE]", String, "Save follower to file") do |f|
|
|
38
|
+
options.file = f
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
opts.on("-u", "--[no-]unfollow", "Automatic unfollow") do |u|
|
|
42
|
+
options.unfollow = u
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
opts.separator ""
|
|
46
|
+
opts.separator "Common options:"
|
|
47
|
+
|
|
48
|
+
opts.on_tail("-h", "--help", "Show this message") do
|
|
49
|
+
puts opts
|
|
50
|
+
exit
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
opts.on_tail("--version", "Show version") do
|
|
54
|
+
puts OptparseExample::Version.join('.')
|
|
55
|
+
exit
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
opt_parser.parse!(ARGV)
|
|
60
|
+
|
|
61
|
+
un = Unfollow::Unfollow.new(options)
|
|
62
|
+
|
|
63
|
+
if un.client.authorized? then
|
|
64
|
+
info=un.client.info()
|
|
65
|
+
un.username=info["screen_name"]
|
|
66
|
+
|
|
67
|
+
if un.exist_save? then
|
|
68
|
+
file_conf=JSON.parse(File.read("#{Dir.home}/.ruby-unfollow/unfollow.json"))
|
|
69
|
+
following=file_conf["following"]
|
|
70
|
+
follower=file_conf["follower"]
|
|
71
|
+
non_follower=file_conf["non_follower"]
|
|
72
|
+
|
|
73
|
+
# debug ahahah
|
|
74
|
+
#puts following.count.to_s+" "+info["friends_count"].to_s+" "+follower.count.to_s+" "+info["followers_count"].to_s
|
|
75
|
+
if following.count != info["friends_count"] || follower.count != info["followers_count"] then
|
|
76
|
+
follower,following,non_follower=un.get_unfollow()
|
|
77
|
+
end
|
|
78
|
+
else
|
|
79
|
+
follower,following,non_follower=un.get_unfollow()
|
|
80
|
+
end
|
|
81
|
+
puts "Stats: "+un.username.green
|
|
82
|
+
puts "Following: "+following.count.to_s
|
|
83
|
+
puts "Follower: "+follower.count.to_s
|
|
84
|
+
puts "Unfollower: "+non_follower.count.to_s+"\n\n"
|
|
85
|
+
puts "Alert! ".red+"If you have a lot of follower this can take "+"LOT".red+" of time\n"
|
|
86
|
+
|
|
87
|
+
if un.options.type == :unfollower then
|
|
88
|
+
if un.options.list != nil && un.options.list != false then
|
|
89
|
+
un.non_follower_list(non_follower,un.options.list)
|
|
90
|
+
else
|
|
91
|
+
un.non_follower(non_follower)
|
|
92
|
+
end
|
|
93
|
+
elsif un.options.type == :inactive then
|
|
94
|
+
un.inactive(follower)
|
|
95
|
+
elsif un.options.type == :and then
|
|
96
|
+
un.non_follower(non_follower,:and)
|
|
97
|
+
elsif un.options.type == :or then
|
|
98
|
+
un.or_follower(following,non_follower)
|
|
99
|
+
elsif un.options.type == :all then
|
|
100
|
+
un.following(following,non_follower)
|
|
101
|
+
end
|
|
102
|
+
else
|
|
103
|
+
puts "Auth Error:".red+" authorized? "+un.client.authorized?.to_s
|
|
104
|
+
un = Unfollow.new(arg)
|
|
105
|
+
puts "Please restart this program!"
|
|
106
|
+
end
|
|
107
|
+
#rescue => e
|
|
108
|
+
# puts "Alert! ".red+e.message.to_s
|
|
109
|
+
end
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
require 'net/http'
|
|
2
|
+
require 'json'
|
|
3
|
+
require 'twitter_oauth'
|
|
4
|
+
require 'ostruct'
|
|
5
|
+
require 'time'
|
|
6
|
+
|
|
7
|
+
begin
|
|
8
|
+
require 'colorize'
|
|
9
|
+
rescue Exception => e
|
|
10
|
+
require 'ruby-unfollow/color'
|
|
11
|
+
puts "Alert:".brown+" colorize gem don't found, fallback to ruby-unfollow/color"
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
module Unfollow
|
|
15
|
+
|
|
16
|
+
VERSION="0.0.5"
|
|
17
|
+
|
|
18
|
+
class Unfollow
|
|
19
|
+
attr_accessor :username, :client, :options
|
|
20
|
+
@username = ""
|
|
21
|
+
@options = OpenStruct.new
|
|
22
|
+
|
|
23
|
+
def d_ago(t1,d=nil)
|
|
24
|
+
t2=Time.now()
|
|
25
|
+
day_since=(t1-t2).abs/3600/24
|
|
26
|
+
if d != nil then
|
|
27
|
+
if day_since>d then
|
|
28
|
+
return true
|
|
29
|
+
else
|
|
30
|
+
return false
|
|
31
|
+
end
|
|
32
|
+
else
|
|
33
|
+
return day_since.round
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def save_unfollow(data)
|
|
38
|
+
File.open("#{Dir.home}/.ruby-unfollow/unfollow.json", "w+") {|f| f.write(data.to_json) }
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def exist_save?
|
|
42
|
+
if File.exist?("#{Dir.home}/.ruby-unfollow/unfollow.json") then
|
|
43
|
+
return true
|
|
44
|
+
else
|
|
45
|
+
return false
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def get_unfollow()
|
|
50
|
+
following=@client.friends_ids()["ids"]
|
|
51
|
+
follower=@client.followers_ids()["ids"]
|
|
52
|
+
non_follower=[]
|
|
53
|
+
following.each do |id|
|
|
54
|
+
if !(follower.include? id) then
|
|
55
|
+
#puts id
|
|
56
|
+
non_follower.push(id)
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
data={}
|
|
61
|
+
data["follower"] = follower
|
|
62
|
+
data["following"] = following
|
|
63
|
+
data["non_follower"] = non_follower
|
|
64
|
+
save_unfollow(data)
|
|
65
|
+
return follower,following,non_follower
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def non_follower_list(non_follower,l)
|
|
69
|
+
i=0
|
|
70
|
+
c=true
|
|
71
|
+
puts "Here is your "+l.to_s+" oldest unfollower: "
|
|
72
|
+
while i<non_follower.count && c==true
|
|
73
|
+
i+=l
|
|
74
|
+
non_follower[-i,l].reverse_each do |id|
|
|
75
|
+
u=@client.show(id)
|
|
76
|
+
if u["screen_name"] != nil && u["status"] != nil then
|
|
77
|
+
t1=Time.parse(u["status"]["created_at"])
|
|
78
|
+
|
|
79
|
+
if d_ago(t1,@options.max_days) then # last tweet > 15 days ago
|
|
80
|
+
puts "@"+u["screen_name"].red+"\t\t "+t1.to_s+"\t "+d_ago(t1).to_s.red
|
|
81
|
+
else
|
|
82
|
+
puts "@"+u["screen_name"].red+"\t\t "+t1.to_s+"\t "+d_ago(t1).to_s
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
puts "Print next "+l.to_s+" follower? (yes/no*)"
|
|
87
|
+
c = gets.chomp
|
|
88
|
+
if c == 'yes' then
|
|
89
|
+
c=true
|
|
90
|
+
else
|
|
91
|
+
c=false
|
|
92
|
+
puts "Bye~"
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def non_follower(non_follower,a=nil)
|
|
98
|
+
non_follower.reverse_each do |id|
|
|
99
|
+
u=@client.show(id)
|
|
100
|
+
if u["screen_name"] != nil then
|
|
101
|
+
if u["status"] != nil then
|
|
102
|
+
t1=Time.parse(u["status"]["created_at"])
|
|
103
|
+
|
|
104
|
+
if d_ago(t1,@options.max_days) then # last tweet > 15 days ago
|
|
105
|
+
puts "@"+u["screen_name"].red+"|"+t1.to_s+"|"+d_ago(t1).to_s.red+"|inactive"
|
|
106
|
+
file_save(@options.file,"@"+u["screen_name"]+"|"+t1.to_s+"|"+d_ago(t1).to_s+"|inactive")
|
|
107
|
+
else
|
|
108
|
+
if a != :and then
|
|
109
|
+
puts "@"+u["screen_name"].red+"|"+t1.to_s+"|"+d_ago(t1).to_s+"|non_follower"
|
|
110
|
+
file_save(@options.file,"@"+u["screen_name"]+"|"+t1.to_s+"|"+d_ago(t1).to_s+"|non_follower")
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
else
|
|
114
|
+
puts "@"+u["screen_name"].red+"|"+"Never".red+"|"+"Never".red
|
|
115
|
+
file_save(@options.file,"@"+u["screen_name"]+"|"+t1.to_s+"|"+d_ago(t1).to_s+"|inactive")
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
def inactive(follower)
|
|
122
|
+
follower.reverse_each do |id|
|
|
123
|
+
u=@client.show(id)
|
|
124
|
+
if u["screen_name"] != nil && u["status"] != nil then
|
|
125
|
+
t1=Time.parse(u["status"]["created_at"])
|
|
126
|
+
|
|
127
|
+
if d_ago(t1,@options.max_days) then # last tweet > 15 days ago
|
|
128
|
+
puts "@"+u["screen_name"]+"|"+t1.to_s+"|"+d_ago(t1).to_s.red
|
|
129
|
+
file_save(@options.file,"@"+u["screen_name"]+"|"+t1.to_s+"|"+d_ago(t1).to_s+"|inactive")
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
def or_follower(following,non_follower)
|
|
136
|
+
following.reverse_each do |id|
|
|
137
|
+
u=@client.show(id)
|
|
138
|
+
if u["screen_name"] != nil && u["status"] != nil then
|
|
139
|
+
t1=Time.parse(u["status"]["created_at"])
|
|
140
|
+
if non_follower.include?(id) then
|
|
141
|
+
puts "@"+u["screen_name"].red+"|"+t1.to_s+"|"+d_ago(t1).to_s
|
|
142
|
+
file_save(@options.file,"@"+u["screen_name"]+"|"+t1.to_s+"|"+d_ago(t1).to_s+"|non_follower")
|
|
143
|
+
else
|
|
144
|
+
if d_ago(t1,@options.max_days) then # last tweet > 15 days ago
|
|
145
|
+
puts "@"+u["screen_name"]+"|"+t1.to_s+"|"+d_ago(t1).to_s.red
|
|
146
|
+
file_save(@options.file,"@"+u["screen_name"]+"|"+t1.to_s+"|"+d_ago(t1).to_s+"|inactive")
|
|
147
|
+
end
|
|
148
|
+
end
|
|
149
|
+
end
|
|
150
|
+
end
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
def following(following,non_follower)
|
|
154
|
+
following.reverse_each do |id|
|
|
155
|
+
u=@client.show(id)
|
|
156
|
+
if u["screen_name"] != nil && u["status"] != nil then
|
|
157
|
+
t1=Time.parse(u["status"]["created_at"])
|
|
158
|
+
t=""
|
|
159
|
+
a=0
|
|
160
|
+
if d_ago(t1,@options.max_days) then # last tweet > 15 days ago
|
|
161
|
+
t=d_ago(t1).to_s.red
|
|
162
|
+
a=1
|
|
163
|
+
else
|
|
164
|
+
t=d_ago(t1).to_s
|
|
165
|
+
end
|
|
166
|
+
if non_follower.include?(id) then
|
|
167
|
+
puts "@"+u["screen_name"].red+"|"+t1.to_s+"|"+t
|
|
168
|
+
if a ==1 then
|
|
169
|
+
file_save(@options.file,"@"+u["screen_name"]+"|"+t1.to_s+"|"+d_ago(t1).to_s+"|non_follower,inactive")
|
|
170
|
+
else
|
|
171
|
+
file_save(@options.file,"@"+u["screen_name"]+"|"+t1.to_s+"|"+d_ago(t1).to_s+"|non_follower")
|
|
172
|
+
end
|
|
173
|
+
else
|
|
174
|
+
puts "@"+u["screen_name"]+"|"+t1.to_s+"|"+t
|
|
175
|
+
if a ==1 then
|
|
176
|
+
file_save(@options.file,"@"+u["screen_name"]+"|"+t1.to_s+"|"+d_ago(t1).to_s+"|inactive")
|
|
177
|
+
end
|
|
178
|
+
end
|
|
179
|
+
end
|
|
180
|
+
end
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
def file_save(file,str)
|
|
184
|
+
if file != nil then
|
|
185
|
+
if file != '' then
|
|
186
|
+
if File.exist?(file) then
|
|
187
|
+
File.open(file, "a+") {|f| f.write(str+"\n") }
|
|
188
|
+
else
|
|
189
|
+
FileUtils.mkdir_p(file)
|
|
190
|
+
File.open(file, "w") {|f| f.write(str+"\n") }
|
|
191
|
+
end
|
|
192
|
+
end
|
|
193
|
+
else
|
|
194
|
+
raise "File is nil"
|
|
195
|
+
end
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
def initialize(o)
|
|
199
|
+
@options = o
|
|
200
|
+
|
|
201
|
+
if File.exist?("/etc/ruby-unfollow.json") then
|
|
202
|
+
conf=JSON.parse(File.read("/etc/ruby-unfollow.json"))
|
|
203
|
+
|
|
204
|
+
@client = TwitterOAuth::Client.new(
|
|
205
|
+
:consumer_key => "XegcON7xJ0ONDc16BijevA",
|
|
206
|
+
:consumer_secret => "ktFOJy92lgDKHkQhvUPmU3JM9oBI19UfhyeuUwhfVho",
|
|
207
|
+
:token => conf["token"],
|
|
208
|
+
:secret => conf["secret"]
|
|
209
|
+
)
|
|
210
|
+
elsif File.exist?("#{Dir.home}/.ruby-unfollow/conf.json") then
|
|
211
|
+
conf=JSON.parse(File.read("#{Dir.home}/.ruby-unfollow/conf.json"))
|
|
212
|
+
|
|
213
|
+
@client = TwitterOAuth::Client.new(
|
|
214
|
+
:consumer_key => "XegcON7xJ0ONDc16BijevA",
|
|
215
|
+
:consumer_secret => "ktFOJy92lgDKHkQhvUPmU3JM9oBI19UfhyeuUwhfVho",
|
|
216
|
+
:token => conf["token"],
|
|
217
|
+
:secret => conf["secret"]
|
|
218
|
+
)
|
|
219
|
+
else
|
|
220
|
+
@client = TwitterOAuth::Client.new(
|
|
221
|
+
:consumer_key => "XegcON7xJ0ONDc16BijevA",
|
|
222
|
+
:consumer_secret => "ktFOJy92lgDKHkQhvUPmU3JM9oBI19UfhyeuUwhfVho"
|
|
223
|
+
)
|
|
224
|
+
|
|
225
|
+
request_token = @client.authentication_request_token(
|
|
226
|
+
:oauth_callback => 'oob'
|
|
227
|
+
)
|
|
228
|
+
|
|
229
|
+
puts request_token.authorize_url
|
|
230
|
+
|
|
231
|
+
print 'Please visit the URL and enter the code: '
|
|
232
|
+
code = gets.strip
|
|
233
|
+
|
|
234
|
+
access_token = @client.authorize(
|
|
235
|
+
request_token.token,
|
|
236
|
+
request_token.secret,
|
|
237
|
+
:oauth_verifier => code
|
|
238
|
+
)
|
|
239
|
+
|
|
240
|
+
if @client.authorized? then
|
|
241
|
+
conf = {:token => access_token.token, :secret => access_token.secret}
|
|
242
|
+
begin
|
|
243
|
+
File.open("/etc/ruby-unfollow.json", "w+") {|f| f.write(conf.to_json) }
|
|
244
|
+
rescue
|
|
245
|
+
FileUtils.mkdir_p("#{Dir.home}/.ruby-unfollow")
|
|
246
|
+
File.open("#{Dir.home}/.ruby-unfollow/conf.json", "w+") {|f| f.write(conf.to_json) }
|
|
247
|
+
end
|
|
248
|
+
end
|
|
249
|
+
end
|
|
250
|
+
end # initialize()
|
|
251
|
+
|
|
252
|
+
end # class Unfollow
|
|
253
|
+
end # module
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
class String
|
|
2
|
+
def black; "\033[30m#{self}\033[0m" end
|
|
3
|
+
def red; "\033[31m#{self}\033[0m" end
|
|
4
|
+
def green; "\033[32m#{self}\033[0m" end
|
|
5
|
+
def brown; "\033[33m#{self}\033[0m" end
|
|
6
|
+
def blue; "\033[34m#{self}\033[0m" end
|
|
7
|
+
def bold; "\033[1m#{self}\033[22m" end
|
|
8
|
+
end
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# Generated by jeweler
|
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
|
4
|
+
# -*- encoding: utf-8 -*-
|
|
5
|
+
# stub: ruby-unfollow 0.0.5 ruby lib
|
|
6
|
+
|
|
7
|
+
Gem::Specification.new do |s|
|
|
8
|
+
s.name = "ruby-unfollow"
|
|
9
|
+
s.version = "0.0.5"
|
|
10
|
+
|
|
11
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
12
|
+
s.require_paths = ["lib"]
|
|
13
|
+
s.authors = ["thez3ro"]
|
|
14
|
+
s.date = "2014-10-17"
|
|
15
|
+
s.email = "io@thezero.org"
|
|
16
|
+
s.executables = ["ruby-unfollow"]
|
|
17
|
+
s.extra_rdoc_files = [
|
|
18
|
+
"LICENSE",
|
|
19
|
+
"README.rdoc"
|
|
20
|
+
]
|
|
21
|
+
s.files = [
|
|
22
|
+
".document",
|
|
23
|
+
"Gemfile",
|
|
24
|
+
"Gemfile.lock",
|
|
25
|
+
"LICENSE",
|
|
26
|
+
"README.rdoc",
|
|
27
|
+
"Rakefile",
|
|
28
|
+
"VERSION",
|
|
29
|
+
"bin/ruby-unfollow",
|
|
30
|
+
"lib/ruby-unfollow.rb",
|
|
31
|
+
"lib/ruby-unfollow/color.rb",
|
|
32
|
+
"ruby-unfollow.gemspec"
|
|
33
|
+
]
|
|
34
|
+
s.homepage = "https://github.com/thez3ro/ruby-unfollow"
|
|
35
|
+
s.licenses = ["Unlicense"]
|
|
36
|
+
s.rubygems_version = "2.2.2"
|
|
37
|
+
s.summary = "Automatically find unfollower and inactive user to unfollow"
|
|
38
|
+
|
|
39
|
+
if s.respond_to? :specification_version then
|
|
40
|
+
s.specification_version = 4
|
|
41
|
+
|
|
42
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
|
43
|
+
s.add_runtime_dependency(%q<twitter_oauth>, [">= 0.4.94"])
|
|
44
|
+
s.add_runtime_dependency(%q<json>, [">= 1.7.6"])
|
|
45
|
+
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
|
46
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0"])
|
|
47
|
+
s.add_development_dependency(%q<jeweler>, ["~> 2.0.1"])
|
|
48
|
+
else
|
|
49
|
+
s.add_dependency(%q<twitter_oauth>, [">= 0.4.94"])
|
|
50
|
+
s.add_dependency(%q<json>, [">= 1.7.6"])
|
|
51
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
|
52
|
+
s.add_dependency(%q<bundler>, ["~> 1.0"])
|
|
53
|
+
s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
|
|
54
|
+
end
|
|
55
|
+
else
|
|
56
|
+
s.add_dependency(%q<twitter_oauth>, [">= 0.4.94"])
|
|
57
|
+
s.add_dependency(%q<json>, [">= 1.7.6"])
|
|
58
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
|
59
|
+
s.add_dependency(%q<bundler>, ["~> 1.0"])
|
|
60
|
+
s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
metadata
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: ruby-unfollow
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.5
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- thez3ro
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2014-10-17 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: twitter_oauth
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - '>='
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: 0.4.94
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - '>='
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: 0.4.94
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: json
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - '>='
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: 1.7.6
|
|
34
|
+
type: :runtime
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - '>='
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: 1.7.6
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: rdoc
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - ~>
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '3.12'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - ~>
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '3.12'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: bundler
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - ~>
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '1.0'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - ~>
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '1.0'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: jeweler
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - ~>
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: 2.0.1
|
|
76
|
+
type: :development
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - ~>
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: 2.0.1
|
|
83
|
+
description:
|
|
84
|
+
email: io@thezero.org
|
|
85
|
+
executables:
|
|
86
|
+
- ruby-unfollow
|
|
87
|
+
extensions: []
|
|
88
|
+
extra_rdoc_files:
|
|
89
|
+
- LICENSE
|
|
90
|
+
- README.rdoc
|
|
91
|
+
files:
|
|
92
|
+
- .document
|
|
93
|
+
- Gemfile
|
|
94
|
+
- Gemfile.lock
|
|
95
|
+
- LICENSE
|
|
96
|
+
- README.rdoc
|
|
97
|
+
- Rakefile
|
|
98
|
+
- VERSION
|
|
99
|
+
- bin/ruby-unfollow
|
|
100
|
+
- lib/ruby-unfollow.rb
|
|
101
|
+
- lib/ruby-unfollow/color.rb
|
|
102
|
+
- ruby-unfollow.gemspec
|
|
103
|
+
homepage: https://github.com/thez3ro/ruby-unfollow
|
|
104
|
+
licenses:
|
|
105
|
+
- Unlicense
|
|
106
|
+
metadata: {}
|
|
107
|
+
post_install_message:
|
|
108
|
+
rdoc_options: []
|
|
109
|
+
require_paths:
|
|
110
|
+
- lib
|
|
111
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
112
|
+
requirements:
|
|
113
|
+
- - '>='
|
|
114
|
+
- !ruby/object:Gem::Version
|
|
115
|
+
version: '0'
|
|
116
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
117
|
+
requirements:
|
|
118
|
+
- - '>='
|
|
119
|
+
- !ruby/object:Gem::Version
|
|
120
|
+
version: '0'
|
|
121
|
+
requirements: []
|
|
122
|
+
rubyforge_project:
|
|
123
|
+
rubygems_version: 2.2.2
|
|
124
|
+
signing_key:
|
|
125
|
+
specification_version: 4
|
|
126
|
+
summary: Automatically find unfollower and inactive user to unfollow
|
|
127
|
+
test_files: []
|