reddit_bot 1.1.6 → 1.1.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2755905b475ba61672aece5ce430f31a391fd314
4
- data.tar.gz: a7e4323f4030e6277c26e5d0601636b3ed2eaaf8
3
+ metadata.gz: 71f09acd949afcc9d5273d40debc6742c0e778e0
4
+ data.tar.gz: e9e53d49bc24c2d6167fc7a570929201fb35ff60
5
5
  SHA512:
6
- metadata.gz: f071f2c06e1fb887e2dfd1f6ee02ee2f12848bec73006393b45a2fda6ac8c03e08f0412ba3eb6fe2f69d2d7aacd2fd8f06141d655153fb4f35797097bc47746a
7
- data.tar.gz: a6a91942b6c51a109af10b0618f9cb42406bd53e2534b4c3ec93b5e77a579bfe92646464d03a5052ad33792ce65beff0b2fcd6616835acc44442e6bf392f47e8
6
+ metadata.gz: c4e13c65fa267c7e519ac853d0299e592a12ebeb33673dd6c86b4be33d2b7bc2b37ea2006d10482a171b1c9e815c073a067b473c7c6e868e9ad3891623584b3b
7
+ data.tar.gz: fb589f11556b81e21e8e5489acabe486b4b2f9e2e64477b7d9c5837aa0d999cd8a95ffe7154fb1861f9480044ee5ae41baf0ede7f5bd5b95d101d507f3ac7890
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ secrets
2
+ secrets.yaml
data/README.md CHANGED
@@ -27,7 +27,7 @@ The [examples folder](examples) includes:
27
27
  * yayornay -- bot that flairs posts according to voting in top level comments
28
28
  * largeimagesreview -- useful script for [subreddit /r/largeimages](https://reddit.com/r/largeimages/top)
29
29
  It calculates quality of x-posts from different subreddits based on mods activity (remove/approve).
30
- For example, this shows that it would be ok to ignore /r/pics from now:
30
+ For example, this showed that it would be ok to ignore /r/pics from now:
31
31
 
32
32
  pics Total: 98 Quality: 19%
33
33
  wallpapers Total: 69 Quality: 52%
@@ -40,6 +40,22 @@ The [examples folder](examples) includes:
40
40
  carporn Total: 11 Quality: 45%
41
41
  InfrastructurePorn Total: 9 Quality: 77%
42
42
 
43
+ Later version of this script also shows remove/approve statuses sorted by linked image resolution:
44
+
45
+ EarthPorn Total: 23 Quality: 82% ✅⛔✅✅✅✅⛔✅✅✅✅✅⛔⛔✅✅✅✅✅✅✅✅✅
46
+ FoodPorn Total: 5 Quality: 0% ⛔⛔⛔⛔⛔
47
+ carporn Total: 4 Quality: 0% ⛔⛔⛔⛔
48
+ CityPorn Total: 4 Quality: 100% ✅✅✅✅
49
+ spaceporn Total: 4 Quality: 100% ✅✅✅✅
50
+ MapPorn Total: 4 Quality: 50% ✅⛔✅⛔
51
+ BotanicalPorn Total: 3 Quality: 66% ✅✅⛔
52
+ CemeteryPorn Total: 2 Quality: 0% ⛔⛔
53
+ MilitaryPorn Total: 2 Quality: 50% ✅⛔
54
+ DessertPorn Total: 2 Quality: 50% ⛔✅
55
+ pic Total: 2 Quality: 100% ✅✅
56
+ ArchitecturePorn Total: 2 Quality: 50% ✅⛔
57
+ AbandonedPorn Total: 2 Quality: 100% ✅✅
58
+
43
59
  You obviously can't run these examples as is, because they have some dependencies that are not in this repo. Like `secrets.yaml` file for authorization of the following format:
44
60
 
45
61
  :client_id: Kb9.......6wBw
@@ -6,14 +6,14 @@ require_relative File.join "../..",
6
6
  *("../download_with_retry" if ENV["LOGNAME"] == "nakilon"),
7
7
  "download_with_retry"
8
8
 
9
- require "reddit_bot"
10
-
11
- if RedditBot::VERSION <= "0.1.3"
12
-
13
- RedditBot.init *File.read("secrets").split, ignore_captcha: true
14
-
9
+ if ENV["DEV"]
10
+ require_relative "../lib/reddit_bot"
11
+ else
12
+ require "reddit_bot"
15
13
  end
16
14
 
15
+ RedditBot.init *File.read("secrets").split, ignore_captcha: true if RedditBot::VERSION <= "0.1.3"
16
+
17
17
  require_relative File.join "../..",
18
18
  *(".." if ENV["LOGNAME"] == "nakilon"),
19
19
  "awsstatus/2.rb"
@@ -1,4 +1,4 @@
1
1
  source "https://rubygems.org"
2
2
 
3
3
  gem "reddit_bot", "1.1.5"
4
- gem "mll"
4
+ # gem "mll"
@@ -2,7 +2,6 @@ GEM
2
2
  remote: https://rubygems.org/
3
3
  specs:
4
4
  json (1.8.3)
5
- mll (2.2.1)
6
5
  reddit_bot (1.1.5)
7
6
  json
8
7
 
@@ -10,8 +9,7 @@ PLATFORMS
10
9
  ruby
11
10
 
12
11
  DEPENDENCIES
13
- mll
14
12
  reddit_bot (= 1.1.5)
15
13
 
16
14
  BUNDLED WITH
17
- 1.11.2
15
+ 1.12.3
@@ -7,13 +7,13 @@ cache = lambda do |&block|
7
7
  end
8
8
 
9
9
 
10
- require_relative File.join "..", "boilerplate"
11
- BOT = RedditBot::Bot.new YAML.load(File.read "secrets.yaml"), ignore_captcha: true
10
+ require_relative "../boilerplate"
11
+ BOT = RedditBot::Bot.new YAML.load File.read "secrets.yaml"
12
12
 
13
13
  SUBREDDIT = "largeimages"
14
14
 
15
15
  table = cache.call do
16
- BOT.json(:get, "/r/#{SUBREDDIT}/about/log", [["limit", 10]])["data"]["children"].map do |child|
16
+ BOT.json(:get, "/r/#{SUBREDDIT}/about/log", [["limit", ENV["LIMIT"] || 500]])["data"]["children"].map do |child|
17
17
  fail child unless child["kind"] == "modaction"
18
18
  next unless %w{ removelink approvelink }.include? child["data"]["action"]
19
19
  title = BOT.json(:get, "/api/info", [["id", child["data"]["target_fullname"]]])["data"]["children"][0]["data"]["title"]
@@ -23,10 +23,21 @@ end
23
23
 
24
24
  report = table.group_by(&:last).sort_by{ |_, group| -group.size }.map do |sub, group|
25
25
  good = (group.group_by(&:first)["approvelink"] || []).size
26
- [sub, "Total: #{group.size}", "Quality: #{good * 100 / group.size}%"]
26
+ [
27
+ sub, "Total: #{group.size}",
28
+ "Quality: #{good * 100 / group.size}%",
29
+ group.sort_by do |_, resolution, |
30
+ x, y = resolution.scan(/\d+/).map(&:to_i)
31
+ x * y
32
+ end.map do |status, |
33
+ {"approvelink"=>?✅, "removelink"=>?⛔}[status] || ??
34
+ end.join,
35
+ ]
27
36
  end
28
37
 
29
-
30
- require "mll"
31
-
32
- puts MLL::grid[report.take(20), spacings: [3, 0]]
38
+ widths = report.transpose.map{ |column| column.map(&:size).max }
39
+ report.each do |row|
40
+ puts [row, widths, %i{ center ljust ljust ljust }].transpose.map{ |string, width, alignment|
41
+ " #{string.send(alignment, width)} "
42
+ }.join
43
+ end
@@ -2,14 +2,14 @@ GEM
2
2
  remote: https://rubygems.org/
3
3
  specs:
4
4
  json (1.8.3)
5
- reddit_bot (1.1.5)
5
+ reddit_bot (1.1.7)
6
6
  json
7
7
 
8
8
  PLATFORMS
9
9
  ruby
10
10
 
11
11
  DEPENDENCIES
12
- reddit_bot (~> 1.1.5)
12
+ reddit_bot (~> 1.1.7)
13
13
 
14
14
  BUNDLED WITH
15
15
  1.11.2
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../..
3
3
  specs:
4
- reddit_bot (1.1.4)
4
+ reddit_bot (1.1.7)
5
5
  json
6
6
 
7
7
  GEM
data/lib/reddit_bot.rb CHANGED
@@ -8,7 +8,7 @@ require "json"
8
8
 
9
9
 
10
10
  module RedditBot
11
- VERSION = "1.1.6" # :nodoc:
11
+ VERSION = "1.1.7" # :nodoc:
12
12
 
13
13
  class Bot
14
14
 
@@ -191,7 +191,8 @@ module RedditBot
191
191
  throw :"401"
192
192
  when "403"
193
193
  puts "access denied: #{response.body} when requesting: #{args}"
194
- sleep 5
194
+ sleep 300
195
+ redo
195
196
  # throw :"403"
196
197
  when "200"
197
198
  "ok"
@@ -229,7 +230,7 @@ module RedditBot
229
230
  end
230
231
  response = begin
231
232
  http.request request
232
- rescue Net::ReadTimeout, Errno::EPIPE, EOFError, SocketError, Zlib::BufError
233
+ rescue Net::ReadTimeout, Errno::EPIPE, EOFError, SocketError, Zlib::BufError, OpenSSL::SSL::SSLError
233
234
  puts "ERROR: network"
234
235
  retry
235
236
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reddit_bot
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.6
4
+ version: 1.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Victor Maslov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-21 00:00:00.000000000 Z
11
+ date: 2016-06-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -31,6 +31,7 @@ executables: []
31
31
  extensions: []
32
32
  extra_rdoc_files: []
33
33
  files:
34
+ - .gitignore
34
35
  - Gemfile
35
36
  - LICENSE.txt
36
37
  - README.md