reddit_bot 1.7.4 → 1.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/reddit_bot.rb +63 -21
- data/reddit_bot.gemspec +9 -13
- metadata +12 -74
- data/Gemfile +0 -5
- data/README.md +0 -101
- data/Rakefile +0 -6
- data/examples/.bashrc +0 -2
- data/examples/.gitignore +0 -2
- data/examples/Gemfile.lock +0 -17
- data/examples/boilerplate.rb +0 -12
- data/examples/councilofricks/Gemfile +0 -4
- data/examples/councilofricks/Gemfile.lock +0 -17
- data/examples/councilofricks/main.rb +0 -58
- data/examples/cptflairbot3/.bashrc +0 -1
- data/examples/cptflairbot3/Code.gs +0 -13
- data/examples/cptflairbot3/Gemfile +0 -5
- data/examples/cptflairbot3/Gemfile.lock +0 -74
- data/examples/cptflairbot3/app.js +0 -40
- data/examples/cptflairbot3/casual/casualpokemontrades.htm +0 -910
- data/examples/cptflairbot3/casual/script.js +0 -55
- data/examples/cptflairbot3/casual/style.css +0 -1099
- data/examples/cptflairbot3/log.htm +0 -1
- data/examples/cptflairbot3/main.rb +0 -62
- data/examples/cptflairbot3/package.json +0 -6
- data/examples/cptflairbot3/pubsub.rb +0 -30
- data/examples/cptflairbot3/update_gas_hook_secret.rb +0 -4
- data/examples/devflairbot/Gemfile +0 -6
- data/examples/devflairbot/Gemfile.lock +0 -74
- data/examples/devflairbot/main.rb +0 -81
- data/examples/get_dimensions.rb +0 -212
- data/examples/iostroubleshooting/Gemfile +0 -5
- data/examples/iostroubleshooting/Gemfile.lock +0 -16
- data/examples/iostroubleshooting/main.rb +0 -36
- data/examples/johnnymarr/Gemfile +0 -3
- data/examples/johnnymarr/Gemfile.lock +0 -17
- data/examples/johnnymarr/main.rb +0 -54
- data/examples/johnnymarr/twitter.rb +0 -80
- data/examples/largeimages/Gemfile +0 -11
- data/examples/largeimages/Gemfile.lock +0 -107
- data/examples/largeimages/main.rb +0 -167
- data/examples/largeimagesreview/Gemfile +0 -4
- data/examples/largeimagesreview/Gemfile.lock +0 -15
- data/examples/largeimagesreview/main.rb +0 -43
- data/examples/mlgtv/Gemfile +0 -4
- data/examples/mlgtv/Gemfile.lock +0 -23
- data/examples/mlgtv/channels.txt +0 -127
- data/examples/mlgtv/main.rb +0 -160
- data/examples/net_http_utils.rb +0 -148
- data/examples/oneplus/Gemfile +0 -5
- data/examples/oneplus/Gemfile.lock +0 -26
- data/examples/oneplus/main.rb +0 -43
- data/examples/realtimeww2/.bashrc +0 -1
- data/examples/realtimeww2/Gemfile +0 -3
- data/examples/realtimeww2/Gemfile.lock +0 -17
- data/examples/realtimeww2/main.rb +0 -129
- data/examples/sexypizza/Gemfile +0 -3
- data/examples/sexypizza/Gemfile.lock +0 -15
- data/examples/sexypizza/main.rb +0 -33
- data/examples/wallpaper/Gemfile +0 -5
- data/examples/wallpaper/Gemfile.lock +0 -33
- data/examples/wallpaper/main.rb +0 -27
- data/examples/yayornay/Gemfile +0 -3
- data/examples/yayornay/Gemfile.lock +0 -15
- data/examples/yayornay/main.rb +0 -33
- data/lib/reddit_bot/version.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 56b982ca68fe28189b57f07c597c68d0db80541f
|
4
|
+
data.tar.gz: f25148fd86d9cc67f93651b16298d1d902bb0567
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fbdd04f798cc039e66a32639bf4949887de5b9875c57ff5f63291730ca903afb2437b91440e7eb8449374589249d3dd4808cbc29385ffbdb65c4faa509d01b65
|
7
|
+
data.tar.gz: 1125779a8c6a4aa55ba98ecb50f6b54ebfd3c4496b983adc09a575aba247d98c6c4583208c5668b58aa86014bf5064e2f24afc150bb4befd8e8b4dd8ca8c48a9
|
data/lib/reddit_bot.rb
CHANGED
@@ -3,11 +3,10 @@ STDOUT.sync = true
|
|
3
3
|
|
4
4
|
require "openssl"
|
5
5
|
require "json"
|
6
|
+
require "yaml"
|
6
7
|
|
7
8
|
require "nethttputils"
|
8
9
|
|
9
|
-
require_relative "reddit_bot/version" # TODO: deprecate this
|
10
|
-
|
11
10
|
module RedditBot
|
12
11
|
require "logger"
|
13
12
|
class << self
|
@@ -153,7 +152,9 @@ module RedditBot
|
|
153
152
|
result["data"].keys == %w{ modhash dist children after before }
|
154
153
|
@@skip_erroneous_descending_ids[ result["data"]["children"].map do |post|
|
155
154
|
fail "unknown type post['kind']: #{post["kind"]}" unless post["kind"] == "t3"
|
156
|
-
post["data"]
|
155
|
+
post["data"].dup.tap do |data|
|
156
|
+
data["url"] = "https://www.reddit.com" + data["url"] if /\A\/r\/[0-9a-zA-Z_]+\/comments\/[0-9a-z]{5,6}\// =~ data["url"] if data["crosspost_parent"]
|
157
|
+
end
|
157
158
|
end ].each do |data|
|
158
159
|
e << data
|
159
160
|
end
|
@@ -204,7 +205,7 @@ module RedditBot
|
|
204
205
|
username: @name,
|
205
206
|
password: @secret_password,
|
206
207
|
}, {
|
207
|
-
"User-Agent" => "bot/#{@user_agent || @name}/#{
|
208
|
+
"User-Agent" => "bot/#{@user_agent || @name}/#{Gem::Specification::load("#{__dir__}/../reddit_bot.gemspec").version} by /u/nakilon",
|
208
209
|
}, @secret_auth
|
209
210
|
unless @token_cached = response["access_token"]
|
210
211
|
fail "bot #{@name} isn't a 'developer' of app at https://www.reddit.com/prefs/apps/" if response == {"error"=>"invalid_grant"}
|
@@ -231,13 +232,13 @@ module RedditBot
|
|
231
232
|
begin
|
232
233
|
reddit_resp mtd, "https://oauth.reddit.com" + path, form, {
|
233
234
|
"Authorization" => "bearer #{token}",
|
234
|
-
"User-Agent" => "bot/#{@user_agent || @name}/#{
|
235
|
+
"User-Agent" => "bot/#{@user_agent || @name}/#{Gem::Specification::load("#{__dir__}/../reddit_bot.gemspec").version} by /u/nakilon",
|
235
236
|
}
|
236
237
|
rescue NetHTTPUtils::Error => e
|
238
|
+
raise unless e.code == 401
|
237
239
|
sleep timeout
|
238
240
|
Module.nesting[1].logger.info "sleeping #{timeout} seconds because of #{e.code}"
|
239
241
|
timeout *= 2
|
240
|
-
raise unless e.code == 401
|
241
242
|
@token_cached = nil
|
242
243
|
retry
|
243
244
|
end
|
@@ -247,21 +248,7 @@ module RedditBot
|
|
247
248
|
mtd, url, form, headers, basic_auth = *args
|
248
249
|
headers["Cookie:"] = "over18=1"
|
249
250
|
begin
|
250
|
-
NetHTTPUtils.request_data
|
251
|
-
next unless remaining = response.to_hash["x-ratelimit-remaining"]
|
252
|
-
if Gem::Platform.local.os == "darwin"
|
253
|
-
Module.nesting[1].logger.debug %w{
|
254
|
-
x-ratelimit-remaining
|
255
|
-
x-ratelimit-used
|
256
|
-
x-ratelimit-reset
|
257
|
-
}.map{ |key| "#{key}=#{response.to_hash[key]}" }.join ", "
|
258
|
-
end
|
259
|
-
fail remaining[0] if remaining[0].size < 4
|
260
|
-
next if remaining[0].size > 4
|
261
|
-
t = (response.to_hash["x-ratelimit-reset"][0].to_f + 1) / [remaining[0].to_f - 10, 1].max + 1
|
262
|
-
Module.nesting[1].logger.info "sleeping #{t} seconds because of x-ratelimit"
|
263
|
-
sleep t
|
264
|
-
end
|
251
|
+
NetHTTPUtils.request_data url, mtd, form: form, header: headers, auth: basic_auth
|
265
252
|
rescue NetHTTPUtils::Error => e
|
266
253
|
sleep 5
|
267
254
|
raise unless e.code.to_s.start_with? "50"
|
@@ -271,4 +258,59 @@ module RedditBot
|
|
271
258
|
end
|
272
259
|
|
273
260
|
end
|
261
|
+
|
262
|
+
module Twitter
|
263
|
+
require "json"
|
264
|
+
|
265
|
+
def self.init_twitter twitter
|
266
|
+
const_set :TWITTER_ACCOUNT, twitter
|
267
|
+
const_set :TWITTER_ACCESS_TOKEN, JSON.load(
|
268
|
+
NetHTTPUtils.request_data "https://api.twitter.com/oauth2/token", :post,
|
269
|
+
auth: File.read("twitter.token").split,
|
270
|
+
form: {grant_type: :client_credentials}
|
271
|
+
)["access_token"]
|
272
|
+
end
|
273
|
+
|
274
|
+
require "cgi"
|
275
|
+
def self.tweet2titleNtext tweet
|
276
|
+
text = ""
|
277
|
+
contains_media = false
|
278
|
+
up = ->s{ s.split.map{ |w| "^#{w}" }.join " " }
|
279
|
+
if tweet["extended_entities"] && !tweet["extended_entities"]["media"].empty?
|
280
|
+
contains_media = true
|
281
|
+
tweet["extended_entities"]["media"].each_with_index do |media, i|
|
282
|
+
text.concat "* [Image #{i + 1}](#{media["media_url_https"]})\n\n"
|
283
|
+
end
|
284
|
+
end
|
285
|
+
if !tweet["entities"]["urls"].empty?
|
286
|
+
contains_media = true
|
287
|
+
tweet["entities"]["urls"].each_with_index do |url, i|
|
288
|
+
text.concat "* [Link #{i + 1}](#{url["expanded_url"]})\n\n"
|
289
|
+
end
|
290
|
+
end
|
291
|
+
text.concat "^- #{
|
292
|
+
up[tweet["user"]["name"]]
|
293
|
+
} [^\\(@#{TWITTER_ACCOUNT}\\)](https://twitter.com/#{TWITTER_ACCOUNT}) ^| [#{
|
294
|
+
up[Date.parse(tweet["created_at"]).strftime "%B %-d, %Y"]
|
295
|
+
}](https://twitter.com/#{TWITTER_ACCOUNT}/status/#{tweet["id"]})"
|
296
|
+
[CGI::unescapeHTML(tweet["full_text"]).sub(/( https:\/\/t\.co\/[0-9a-zA-Z]{10})*\z/, ""), text, contains_media]
|
297
|
+
end
|
298
|
+
|
299
|
+
def self.user_timeline
|
300
|
+
timeout = 1
|
301
|
+
JSON.load begin
|
302
|
+
NetHTTPUtils.request_data(
|
303
|
+
"https://api.twitter.com/1.1/statuses/user_timeline.json",
|
304
|
+
form: { screen_name: TWITTER_ACCOUNT, count: 200, tweet_mode: "extended" },
|
305
|
+
header: { Authorization: "Bearer #{TWITTER_ACCESS_TOKEN}" }
|
306
|
+
)
|
307
|
+
rescue NetHTTPUtils::Error => e
|
308
|
+
fail unless [500, 503].include? e.code
|
309
|
+
sleep timeout
|
310
|
+
timeout *= 2
|
311
|
+
retry
|
312
|
+
end
|
313
|
+
end
|
314
|
+
end
|
315
|
+
|
274
316
|
end
|
data/reddit_bot.gemspec
CHANGED
@@ -1,25 +1,21 @@
|
|
1
|
-
require_relative "lib/reddit_bot/version"
|
2
|
-
|
3
1
|
Gem::Specification.new do |spec|
|
4
2
|
spec.name = "reddit_bot"
|
5
|
-
spec.version =
|
6
|
-
spec.
|
7
|
-
spec.email = ["nakilon@gmail.com"]
|
3
|
+
spec.version = "1.8.0"
|
4
|
+
spec.summary = "Simple library for Reddit bots"
|
8
5
|
|
9
|
-
spec.
|
10
|
-
spec.
|
11
|
-
spec.homepage = "https://github.com/Nakilon/reddit_bot"
|
6
|
+
spec.author = "Victor Maslov aka Nakilon"
|
7
|
+
spec.email = "nakilon@gmail.com"
|
12
8
|
spec.license = "MIT"
|
9
|
+
spec.metadata = {"source_code_uri" => "https://github.com/Nakilon/reddit_bot"}
|
13
10
|
|
14
|
-
spec.
|
15
|
-
|
16
|
-
|
17
|
-
spec.add_runtime_dependency "json"
|
18
|
-
spec.add_runtime_dependency "nethttputils", "~>0.4.0.0"
|
11
|
+
spec.add_dependency "json_pure"
|
12
|
+
spec.add_dependency "nethttputils", "~>0.4.1.0"
|
19
13
|
# spec.add_development_dependency "bundler", "~> 1.11"
|
20
14
|
# spec.add_development_dependency "rake", "~> 10.0"
|
21
15
|
# spec.add_development_dependency "rspec", "~> 3.0"
|
22
16
|
spec.required_ruby_version = ">= 2.0.0"
|
17
|
+
|
18
|
+
spec.files = %w{ LICENSE.txt reddit_bot.gemspec lib/reddit_bot.rb }
|
23
19
|
end
|
24
20
|
|
25
21
|
# spec.test_files = ["spec/"]
|
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: reddit_bot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
- Victor Maslov
|
7
|
+
- Victor Maslov aka Nakilon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-02-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: json_pure
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
@@ -30,90 +30,28 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.4.
|
33
|
+
version: 0.4.1.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.4.
|
41
|
-
description:
|
42
|
-
email:
|
43
|
-
- nakilon@gmail.com
|
40
|
+
version: 0.4.1.0
|
41
|
+
description:
|
42
|
+
email: nakilon@gmail.com
|
44
43
|
executables: []
|
45
44
|
extensions: []
|
46
45
|
extra_rdoc_files: []
|
47
46
|
files:
|
48
|
-
- Gemfile
|
49
47
|
- LICENSE.txt
|
50
|
-
- README.md
|
51
|
-
- Rakefile
|
52
|
-
- examples/.bashrc
|
53
|
-
- examples/.gitignore
|
54
|
-
- examples/Gemfile.lock
|
55
|
-
- examples/boilerplate.rb
|
56
|
-
- examples/councilofricks/Gemfile
|
57
|
-
- examples/councilofricks/Gemfile.lock
|
58
|
-
- examples/councilofricks/main.rb
|
59
|
-
- examples/cptflairbot3/.bashrc
|
60
|
-
- examples/cptflairbot3/Code.gs
|
61
|
-
- examples/cptflairbot3/Gemfile
|
62
|
-
- examples/cptflairbot3/Gemfile.lock
|
63
|
-
- examples/cptflairbot3/app.js
|
64
|
-
- examples/cptflairbot3/casual/casualpokemontrades.htm
|
65
|
-
- examples/cptflairbot3/casual/script.js
|
66
|
-
- examples/cptflairbot3/casual/style.css
|
67
|
-
- examples/cptflairbot3/log.htm
|
68
|
-
- examples/cptflairbot3/main.rb
|
69
|
-
- examples/cptflairbot3/package.json
|
70
|
-
- examples/cptflairbot3/pubsub.rb
|
71
|
-
- examples/cptflairbot3/update_gas_hook_secret.rb
|
72
|
-
- examples/devflairbot/Gemfile
|
73
|
-
- examples/devflairbot/Gemfile.lock
|
74
|
-
- examples/devflairbot/main.rb
|
75
|
-
- examples/get_dimensions.rb
|
76
|
-
- examples/iostroubleshooting/Gemfile
|
77
|
-
- examples/iostroubleshooting/Gemfile.lock
|
78
|
-
- examples/iostroubleshooting/main.rb
|
79
|
-
- examples/johnnymarr/Gemfile
|
80
|
-
- examples/johnnymarr/Gemfile.lock
|
81
|
-
- examples/johnnymarr/main.rb
|
82
|
-
- examples/johnnymarr/twitter.rb
|
83
|
-
- examples/largeimages/Gemfile
|
84
|
-
- examples/largeimages/Gemfile.lock
|
85
|
-
- examples/largeimages/main.rb
|
86
|
-
- examples/largeimagesreview/Gemfile
|
87
|
-
- examples/largeimagesreview/Gemfile.lock
|
88
|
-
- examples/largeimagesreview/main.rb
|
89
|
-
- examples/mlgtv/Gemfile
|
90
|
-
- examples/mlgtv/Gemfile.lock
|
91
|
-
- examples/mlgtv/channels.txt
|
92
|
-
- examples/mlgtv/main.rb
|
93
|
-
- examples/net_http_utils.rb
|
94
|
-
- examples/oneplus/Gemfile
|
95
|
-
- examples/oneplus/Gemfile.lock
|
96
|
-
- examples/oneplus/main.rb
|
97
|
-
- examples/realtimeww2/.bashrc
|
98
|
-
- examples/realtimeww2/Gemfile
|
99
|
-
- examples/realtimeww2/Gemfile.lock
|
100
|
-
- examples/realtimeww2/main.rb
|
101
|
-
- examples/sexypizza/Gemfile
|
102
|
-
- examples/sexypizza/Gemfile.lock
|
103
|
-
- examples/sexypizza/main.rb
|
104
|
-
- examples/wallpaper/Gemfile
|
105
|
-
- examples/wallpaper/Gemfile.lock
|
106
|
-
- examples/wallpaper/main.rb
|
107
|
-
- examples/yayornay/Gemfile
|
108
|
-
- examples/yayornay/Gemfile.lock
|
109
|
-
- examples/yayornay/main.rb
|
110
48
|
- lib/reddit_bot.rb
|
111
|
-
- lib/reddit_bot/version.rb
|
112
49
|
- reddit_bot.gemspec
|
113
|
-
homepage:
|
50
|
+
homepage:
|
114
51
|
licenses:
|
115
52
|
- MIT
|
116
|
-
metadata:
|
53
|
+
metadata:
|
54
|
+
source_code_uri: https://github.com/Nakilon/reddit_bot
|
117
55
|
post_install_message:
|
118
56
|
rdoc_options: []
|
119
57
|
require_paths:
|
@@ -133,5 +71,5 @@ rubyforge_project:
|
|
133
71
|
rubygems_version: 2.5.2.3
|
134
72
|
signing_key:
|
135
73
|
specification_version: 4
|
136
|
-
summary:
|
74
|
+
summary: Simple library for Reddit bots
|
137
75
|
test_files: []
|
data/Gemfile
DELETED
data/README.md
DELETED
@@ -1,101 +0,0 @@
|
|
1
|
-
# RedditBot
|
2
|
-
|
3
|
-
[![Join the chat at https://gitter.im/Nakilon/reddit_bot](https://badges.gitter.im/Nakilon/reddit_bot.svg)](https://gitter.im/Nakilon/reddit_bot)
|
4
|
-
[![Gem Version](https://badge.fury.io/rb/reddit_bot.svg)](http://badge.fury.io/rb/reddit_bot)
|
5
|
-
|
6
|
-
### What
|
7
|
-
|
8
|
-
This library provides an easy way to run bots and scripts that use Reddit API.
|
9
|
-
I ([/u/nakilon](https://www.reddit.com/u/nakilon)) currently run near 10 bots with it.
|
10
|
-
|
11
|
-
### Why
|
12
|
-
|
13
|
-
Python (and so PRAW) sucks.
|
14
|
-
|
15
|
-
### Examples
|
16
|
-
|
17
|
-
I'm not usually publish every program (since there are thousand of them and adequate programmer knows that publishing everything is like throwing trash on street) but I'll add bots here so you could see how to use the library.
|
18
|
-
The [examples folder](examples) includes:
|
19
|
-
|
20
|
-
* **sexypizza** -- bot that updates wiki page with current flairs statistics
|
21
|
-
* **devflairbot** -- bot that flairs posts when some specifically flaired user comments there
|
22
|
-
* **mlgtv** -- bot that updates sidebar with currently streaming twitch channels
|
23
|
-
* **councilofricks** -- bot that flairs users according to Google Spreadsheet
|
24
|
-
* **wallpaper** -- bot that reports images with dimensions being not the same as in title
|
25
|
-
* **cptflairbot3** -- bot that sets user flair according to request submitted via web form
|
26
|
-
also publishes its activily log here http://www.nakilon.pro/casualpokemontrades/log.htm via Google Cloud Platform automations (Apps Script and Functions)
|
27
|
-
* **oneplus** -- bot that removes and modmails about links to 1080x1920 images
|
28
|
-
* **yayornay** -- bot that flairs posts according to voting in top level comments
|
29
|
-
* **realtimeww2** -- bot that posts tweets to a subreddit from a Twitter user timeline
|
30
|
-
* **johnnymarr** -- another Twitter timeline streaming bot working in the similar way
|
31
|
-
* **largeimages** -- this was my first bot -- it uses two approaches to track the most high resolution photos posted anywhere on Reddit to x-post them to [subreddit /r/largeimages](https://www.reddit.com/r/largeimages)
|
32
|
-
* **largeimagesreview** -- script that was used /r/largeimages to calculates quality of x-posts from different subreddits based on mods activity (remove/approve) so it showed that /r/pics and /r/foodporn should better be excluded:
|
33
|
-
|
34
|
-
pics Total: 98 Quality: 19%
|
35
|
-
wallpapers Total: 69 Quality: 52%
|
36
|
-
wallpaper Total: 45 Quality: 51%
|
37
|
-
woahdude Total: 30 Quality: 66%
|
38
|
-
CityPorn Total: 17 Quality: 82%
|
39
|
-
FoodPorn Total: 13 Quality: 7%
|
40
|
-
MapPorn Total: 13 Quality: 46%
|
41
|
-
SkyPorn Total: 11 Quality: 45%
|
42
|
-
carporn Total: 11 Quality: 45%
|
43
|
-
InfrastructurePorn Total: 9 Quality: 77%
|
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
|
-
|
59
|
-
### Usage
|
60
|
-
|
61
|
-
$ gem install reddit_bot
|
62
|
-
|
63
|
-
or via Gemfile:
|
64
|
-
|
65
|
-
source "https://rubygems.org"
|
66
|
-
gem "reddit_bot"
|
67
|
-
|
68
|
-
helloworld.rb:
|
69
|
-
|
70
|
-
```ruby
|
71
|
-
require "reddit_bot"
|
72
|
-
```
|
73
|
-
|
74
|
-
You obviously can't run these examples as is, because they use local configs that are not in git repo, like `secrets.yaml` file for Reddit authorization of the following format:
|
75
|
-
|
76
|
-
:client_id: Kb9.......6wBw
|
77
|
-
:client_secret: Fqo.....................AFI
|
78
|
-
:password: mybotpassword
|
79
|
-
:login: MyBotUsername
|
80
|
-
# :user_agent: optional_custom_useragent_to_bypass_reddit_spam_protection
|
81
|
-
|
82
|
-
To change log level:
|
83
|
-
|
84
|
-
```ruby
|
85
|
-
RedditBot.logger.level = Logger::ERROR
|
86
|
-
```
|
87
|
-
|
88
|
-
To update the gem version in Gemfile.lock when using Gemfile like this: `gem "reddit_bot", "~>1.1.0"`, do the:
|
89
|
-
|
90
|
-
$ bundle update reddit_bot
|
91
|
-
|
92
|
-
### Contributing and License
|
93
|
-
|
94
|
-
Bug reports and pull requests are welcome.
|
95
|
-
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
96
|
-
|
97
|
-
### TODO
|
98
|
-
|
99
|
-
* write more usage instructions here
|
100
|
-
* manual on how to create bots with Reddit web interface and run via bash console
|
101
|
-
* about NetHTTPUtils dependency; and that get_response returns String code not Integer like request_data
|
data/Rakefile
DELETED
data/examples/.bashrc
DELETED
data/examples/.gitignore
DELETED
data/examples/Gemfile.lock
DELETED