reddit_bot 1.6.4 → 1.6.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/examples/largeimages/Gemfile +3 -6
- data/examples/largeimages/Gemfile.lock +16 -23
- data/examples/largeimages/main.rb +27 -27
- data/examples/realtimeww2/Gemfile +1 -1
- data/examples/realtimeww2/Gemfile.lock +2 -2
- data/lib/reddit_bot.rb +1 -1
- data/lib/reddit_bot/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: afe3593cb266098860316251a4126efdccced3c0
|
4
|
+
data.tar.gz: bcf920ee2ccf254f5f84aeef64c5a5471400165d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 00c876b7cde3299b2ec06ac5c8f7a34e2299a651ac91c7815d168e547c220c3c4a6317a4eab544c2e81656263ce9d2cf7687dcec062f90952a20d8092e2a6185
|
7
|
+
data.tar.gz: c74d1fac23dafb7ed17165875b164ceec1f2cde7f21f1defc590661f2f6de86c1ec4b446e69320d2dce72491b42a4081cda2b0e5d8d5e979537697de7d8cf6f0
|
@@ -2,14 +2,11 @@
|
|
2
2
|
|
3
3
|
gem "json"
|
4
4
|
|
5
|
-
gem "
|
6
|
-
|
7
|
-
gem "reddit_bot", "~>1.6.3"
|
5
|
+
gem "reddit_bot", git: "git@github.com:nakilon/reddit_bot.git"
|
8
6
|
gem "nokogiri"
|
9
7
|
|
10
|
-
gem "
|
11
|
-
gem "
|
12
|
-
gem "url2dimensions", git: "git@github.com:Nakilon/url2dimensions.git", tag: "v0.0.0.8"
|
8
|
+
gem "fastimage", git: "git@github.com:sdsykes/fastimage.git", ref: "15bc4111c4c4e1af580b63c62e08decf2d5527d5"
|
9
|
+
gem "directlink", git: "git@github.com:Nakilon/directlink.git"
|
13
10
|
|
14
11
|
gem "gcplogger", git: "git@github.com:Nakilon/gcplogger.git", tag: "v0.1.1.0"
|
15
12
|
gem "google-cloud-error_reporting"
|
@@ -1,8 +1,10 @@
|
|
1
1
|
GIT
|
2
|
-
remote: git@github.com:Nakilon/
|
3
|
-
revision:
|
2
|
+
remote: git@github.com:Nakilon/directlink.git
|
3
|
+
revision: 18b1544dcbdee3d9f5c2ad685e4eaf134773e5a1
|
4
4
|
specs:
|
5
|
-
|
5
|
+
directlink (0.0.2.0)
|
6
|
+
fastimage (~> 2.1.3)
|
7
|
+
nethttputils (~> 0.2.4.0)
|
6
8
|
|
7
9
|
GIT
|
8
10
|
remote: git@github.com:Nakilon/gcplogger.git
|
@@ -14,24 +16,18 @@ GIT
|
|
14
16
|
public_suffix (~> 2.0)
|
15
17
|
|
16
18
|
GIT
|
17
|
-
remote: git@github.com:
|
18
|
-
revision:
|
19
|
+
remote: git@github.com:nakilon/reddit_bot.git
|
20
|
+
revision: d2ab4765573ea153e34c99b6f6a4f7bca21df6a7
|
19
21
|
specs:
|
20
|
-
|
21
|
-
|
22
|
-
GIT
|
23
|
-
remote: git@github.com:Nakilon/nethttputils.git
|
24
|
-
revision: 27777142af099556394691c772a33cf5f6548c4f
|
25
|
-
tag: v0.1.2.1
|
26
|
-
specs:
|
27
|
-
nethttputils (0.1.2.1)
|
22
|
+
reddit_bot (1.6.5)
|
23
|
+
json
|
28
24
|
|
29
25
|
GIT
|
30
|
-
remote: git@github.com:
|
31
|
-
revision:
|
32
|
-
|
26
|
+
remote: git@github.com:sdsykes/fastimage.git
|
27
|
+
revision: 15bc4111c4c4e1af580b63c62e08decf2d5527d5
|
28
|
+
ref: 15bc4111c4c4e1af580b63c62e08decf2d5527d5
|
33
29
|
specs:
|
34
|
-
|
30
|
+
fastimage (2.1.3)
|
35
31
|
|
36
32
|
GEM
|
37
33
|
remote: https://rubygems.org/
|
@@ -87,12 +83,11 @@ GEM
|
|
87
83
|
mini_portile2 (2.1.0)
|
88
84
|
multi_json (1.13.1)
|
89
85
|
multipart-post (2.0.0)
|
86
|
+
nethttputils (0.2.4.0)
|
90
87
|
nokogiri (1.6.8.1)
|
91
88
|
mini_portile2 (~> 2.1.0)
|
92
89
|
os (0.9.6)
|
93
90
|
public_suffix (2.0.5)
|
94
|
-
reddit_bot (1.6.3)
|
95
|
-
json
|
96
91
|
rly (0.2.3)
|
97
92
|
signet (0.8.1)
|
98
93
|
addressable (~> 2.3)
|
@@ -106,15 +101,13 @@ PLATFORMS
|
|
106
101
|
ruby
|
107
102
|
|
108
103
|
DEPENDENCIES
|
104
|
+
directlink!
|
109
105
|
fastimage!
|
110
106
|
gcplogger!
|
111
107
|
google-cloud-error_reporting
|
112
|
-
imgur2array!
|
113
108
|
json
|
114
|
-
nethttputils!
|
115
109
|
nokogiri
|
116
|
-
reddit_bot
|
117
|
-
url2dimensions!
|
110
|
+
reddit_bot!
|
118
111
|
|
119
112
|
BUNDLED WITH
|
120
113
|
1.16.1
|
@@ -4,15 +4,14 @@
|
|
4
4
|
require "gcplogger"
|
5
5
|
logger = GCPLogger.logger "largeimagesbot"
|
6
6
|
|
7
|
-
fail
|
7
|
+
fail "no ENV['ERROR_REPORTING_KEYFILE'] specified" unless ENV["ERROR_REPORTING_KEYFILE"]
|
8
8
|
require "google/cloud/error_reporting"
|
9
9
|
Google::Cloud::ErrorReporting.configure do |config|
|
10
|
-
config.project_id =
|
10
|
+
config.project_id = JSON.load(File.read ENV["ERROR_REPORTING_KEYFILE"])["project_id"]
|
11
11
|
end
|
12
12
|
|
13
13
|
|
14
|
-
require "
|
15
|
-
Imgur.logger = logger
|
14
|
+
require "directlink"
|
16
15
|
|
17
16
|
require "nokogiri"
|
18
17
|
|
@@ -84,34 +83,35 @@ loop do
|
|
84
83
|
checked << id
|
85
84
|
# next if Gem::Platform.local.os == "darwin" # prevent concurrent posting
|
86
85
|
logger.debug "image url for #{id}: #{url}"
|
87
|
-
next logger.warn "skipped a post by /u/sjhill"
|
88
|
-
next logger.warn "skipped a post by /u/
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
86
|
+
next logger.warn "skipped a post by /u/sjhill" if author == "sjhill" # opt-out
|
87
|
+
next logger.warn "skipped a post by /u/redisforever" if author == "redisforever" # opt-out
|
88
|
+
next logger.warn "skipped a post by /u/bekalaki" if author == "bekalaki" # 9 ways to divide a karmawhore
|
89
|
+
|
90
|
+
t = begin
|
91
|
+
DirectLink url
|
92
|
+
rescue NetHTTPUtils::Error,
|
93
|
+
SocketError,
|
94
|
+
FastImage::UnknownImageType,
|
95
|
+
FastImage::ImageFetchFailure,
|
96
|
+
# DirectLink::ErrorMissingEnvVar,
|
97
|
+
DirectLink::ErrorNotFound,
|
98
|
+
DirectLink::ErrorBadLink => e
|
99
|
+
next logger.error "skipped (#{e}) #{url} from http://redd.it/#{id}"
|
96
100
|
end
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
unless min_resolution <= width * height
|
101
|
+
logger.info "DirectLink: %p" % t
|
102
|
+
tt = t.is_a?(Array) ? t : [t]
|
103
|
+
unless min_resolution <= tt.first.width * tt.first.height
|
101
104
|
next logger.debug "skipped low resolution #{source}"
|
102
105
|
end
|
103
|
-
# next if Gem::Platform.local.os == "darwin" # prevent concurrent posting
|
104
106
|
# puts "https://www.reddit.com/r/LargeImages/search.json?q=url%3A#{CGI.escape url}&restrict_sr=on"
|
105
|
-
resolution = "[#{width}x#{height}]"
|
106
|
-
# require "cgi"
|
107
|
+
resolution = "[#{tt.first.width}x#{tt.first.height}]"
|
107
108
|
next logger.warn "already submitted #{resolution} #{id}: '#{url}'" unless
|
108
109
|
Gem::Platform.local.os == "darwin" || search_url[url].empty?
|
109
110
|
logger.warn "resolution #{resolution} got from #{id}: #{url}"
|
110
|
-
# next if Gem::Platform.local.os == "darwin" # prevent concurrent posting
|
111
111
|
title = "#{resolution}#{
|
112
|
-
" [#{
|
112
|
+
" [#{tt.size} images]" if tt.size > 1
|
113
113
|
} #{
|
114
|
-
title.sub(/\s*\[?#{width}\s*[*x×]\s*#{height}\]?\s*/i, " ").
|
114
|
+
title.sub(/\s*\[?#{tt.first.width}\s*[*x×]\s*#{tt.first.height}\]?\s*/i, " ").
|
115
115
|
sub("[OC]", " ").gsub(/\s+/, " ").strip.
|
116
116
|
gsub(/(?<=.{190 - subreddit.size}).+/, "...")
|
117
117
|
} /r/#{subreddit}".
|
@@ -137,11 +137,11 @@ loop do
|
|
137
137
|
# "id"=>"3a9rel",
|
138
138
|
# "name"=>"t3_3a9rel"}}}
|
139
139
|
line1 = "[Original thread](#{permalink}) by /u/#{author}"
|
140
|
-
line2 = "Direct link#{" (the largest image)" if
|
140
|
+
line2 = "Direct link#{" (the largest image)" if tt.size > 1}: #{tt.first.url}"
|
141
141
|
line3 = [
|
142
142
|
"Direct links to all other images in album:",
|
143
|
-
|
144
|
-
] if
|
143
|
+
tt.map(&:url) - [tt.first.url]
|
144
|
+
] if tt.size > 1
|
145
145
|
text = [line1, line2, line3].compact.join(" \n")
|
146
146
|
logger.info "new comment: #{text.inspect}"
|
147
147
|
unless Gem::Platform.local.os == "darwin"
|
@@ -152,7 +152,7 @@ loop do
|
|
152
152
|
end
|
153
153
|
end
|
154
154
|
|
155
|
-
abort if
|
155
|
+
abort if Gem::Platform.local.os == "darwin"
|
156
156
|
end
|
157
157
|
end
|
158
158
|
|
@@ -9,7 +9,7 @@ GEM
|
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
11
|
json (2.1.0)
|
12
|
-
reddit_bot (1.
|
12
|
+
reddit_bot (1.6.4)
|
13
13
|
json
|
14
14
|
|
15
15
|
PLATFORMS
|
@@ -17,7 +17,7 @@ PLATFORMS
|
|
17
17
|
|
18
18
|
DEPENDENCIES
|
19
19
|
nethttputils!
|
20
|
-
reddit_bot (~> 1.
|
20
|
+
reddit_bot (~> 1.6.4)
|
21
21
|
|
22
22
|
BUNDLED WITH
|
23
23
|
1.16.1
|
data/lib/reddit_bot.rb
CHANGED
data/lib/reddit_bot/version.rb
CHANGED
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.6.
|
4
|
+
version: 1.6.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Victor Maslov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-06-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|