reddit_bot 1.1.6 → 1.1.7
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 +4 -4
- data/.gitignore +2 -0
- data/README.md +17 -1
- data/examples/boilerplate.rb +6 -6
- data/examples/largeimagesreview/Gemfile +1 -1
- data/examples/largeimagesreview/Gemfile.lock +1 -3
- data/examples/largeimagesreview/main.rb +19 -8
- data/examples/mlgtv/Gemfile.lock +2 -2
- data/examples/yayornay/Gemfile.lock +1 -1
- data/lib/reddit_bot.rb +4 -3
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 71f09acd949afcc9d5273d40debc6742c0e778e0
|
4
|
+
data.tar.gz: e9e53d49bc24c2d6167fc7a570929201fb35ff60
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c4e13c65fa267c7e519ac853d0299e592a12ebeb33673dd6c86b4be33d2b7bc2b37ea2006d10482a171b1c9e815c073a067b473c7c6e868e9ad3891623584b3b
|
7
|
+
data.tar.gz: fb589f11556b81e21e8e5489acabe486b4b2f9e2e64477b7d9c5837aa0d999cd8a95ffe7154fb1861f9480044ee5ae41baf0ede7f5bd5b95d101d507f3ac7890
|
data/.gitignore
ADDED
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
|
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
|
data/examples/boilerplate.rb
CHANGED
@@ -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
|
-
|
10
|
-
|
11
|
-
|
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"
|
@@ -7,13 +7,13 @@ cache = lambda do |&block|
|
|
7
7
|
end
|
8
8
|
|
9
9
|
|
10
|
-
require_relative
|
11
|
-
BOT = RedditBot::Bot.new YAML.load
|
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",
|
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
|
-
[
|
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
|
-
|
31
|
-
|
32
|
-
|
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
|
data/examples/mlgtv/Gemfile.lock
CHANGED
data/lib/reddit_bot.rb
CHANGED
@@ -8,7 +8,7 @@ require "json"
|
|
8
8
|
|
9
9
|
|
10
10
|
module RedditBot
|
11
|
-
VERSION = "1.1.
|
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
|
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.
|
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-
|
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
|