reddit_bot 1.7.5 → 1.9.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 +33 -31
- data/reddit_bot.gemspec +9 -11
- metadata +12 -73
- 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 -176
- 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 -34
- 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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 99ebebd30c2e4bfa221cc6b78c6521f4eb2e5c7b
|
4
|
+
data.tar.gz: 79b8d91f910d5ca649f8350f1009bb6c21afd702
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9049548db4c55006a9fd9dd7fef394cb3b973ea3df7047a25528dcd2495e230acaa8217fd17ffa8128e9f23784bd292875d6e01015c785d465c3acc7c51db0b9
|
7
|
+
data.tar.gz: 6e9849c6d4d3c7ed2eacc8b404f256764e0756e773d567ab7004d7f0a041bbdb5b722106d4fbba281b1ef0f8b6898d551b7742b19a232b942058523e8235a669
|
data/lib/reddit_bot.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
STDOUT.sync = true
|
2
|
-
# require "pp"
|
3
2
|
|
4
3
|
require "openssl"
|
5
4
|
require "json"
|
@@ -7,8 +6,6 @@ require "yaml"
|
|
7
6
|
|
8
7
|
require "nethttputils"
|
9
8
|
|
10
|
-
require_relative "reddit_bot/version" # TODO: deprecate this
|
11
|
-
|
12
9
|
module RedditBot
|
13
10
|
require "logger"
|
14
11
|
class << self
|
@@ -17,12 +14,8 @@ module RedditBot
|
|
17
14
|
self.logger = Logger.new STDOUT
|
18
15
|
|
19
16
|
class Bot
|
20
|
-
|
21
|
-
# bot's Reddit username; set via constructor parameter secrets[:login]
|
22
17
|
attr_reader :name
|
23
18
|
|
24
|
-
# [secrets] +Hash+ with keys :client_id, :client_secret, :password: and :login
|
25
|
-
# [kwargs] keyword params may include :subreddit for clever methods
|
26
19
|
def initialize secrets, **kwargs
|
27
20
|
@name, @secret_password, @user_agent, *@secret_auth = secrets.values_at *%i{ login password user_agent client_id client_secret }
|
28
21
|
# @ignore_captcha = true
|
@@ -30,12 +23,14 @@ module RedditBot
|
|
30
23
|
@subreddit = kwargs[:subreddit]
|
31
24
|
end
|
32
25
|
|
33
|
-
# [mtd] +Symbol+ :get or :post
|
34
|
-
# [path] +String+ an API method
|
35
|
-
# [_form] +Array+ or +Hash+ API method params
|
36
26
|
def json mtd, path, _form = []
|
37
27
|
form = Hash[_form]
|
38
|
-
response =
|
28
|
+
response = begin
|
29
|
+
JSON.load resp_with_token mtd, path, form.merge({api_type: "json"})
|
30
|
+
rescue JSON::ParserError
|
31
|
+
$!.message.slice! 1000..-1
|
32
|
+
raise
|
33
|
+
end
|
39
34
|
if response.is_a?(Hash) && response["json"] && # for example, flairlist.json and {"error": 403} do not have it
|
40
35
|
!response["json"]["errors"].empty?
|
41
36
|
Module.nesting[1].logger.error "ERROR OCCURED on #{[mtd, path]}"
|
@@ -72,8 +67,6 @@ module RedditBot
|
|
72
67
|
# # ["previous", result["data"]["children"].last["id"]],
|
73
68
|
# end
|
74
69
|
|
75
|
-
# [reason] :nodoc:
|
76
|
-
# [thing_id] +String+ fullname of a "link, commenr or message"
|
77
70
|
def report reason, thing_id
|
78
71
|
Module.nesting[1].logger.warn "reporting '#{thing_id}'"
|
79
72
|
json :post, "/api/report",
|
@@ -82,9 +75,6 @@ module RedditBot
|
|
82
75
|
thing_id: thing_id
|
83
76
|
end
|
84
77
|
|
85
|
-
# [post] JSON object of a post of self.post
|
86
|
-
# [link_flair_css_class] :nodoc:
|
87
|
-
# [link_flair_text] :nodoc:
|
88
78
|
def set_post_flair post, link_flair_css_class, link_flair_text
|
89
79
|
Module.nesting[1].logger.warn "setting flair '#{link_flair_css_class}' with text '#{link_flair_text}' to post '#{post["name"]}'"
|
90
80
|
if {"error"=>403} == @flairselector_choices ||= json(:post, "/r/#{@subreddit}/api/flairselector", link: post["name"])
|
@@ -99,8 +89,6 @@ module RedditBot
|
|
99
89
|
}["flair_template_id"]
|
100
90
|
end
|
101
91
|
|
102
|
-
# [thing_id] +String+ fullname of a post (or self.post?), comment (and private message?)
|
103
|
-
# [text] :nodoc:
|
104
92
|
def leave_a_comment thing_id, text
|
105
93
|
Module.nesting[1].logger.warn "leaving a comment on '#{thing_id}'"
|
106
94
|
json(:post, "/api/comment",
|
@@ -154,7 +142,9 @@ module RedditBot
|
|
154
142
|
result["data"].keys == %w{ modhash dist children after before }
|
155
143
|
@@skip_erroneous_descending_ids[ result["data"]["children"].map do |post|
|
156
144
|
fail "unknown type post['kind']: #{post["kind"]}" unless post["kind"] == "t3"
|
157
|
-
post["data"]
|
145
|
+
post["data"].dup.tap do |data|
|
146
|
+
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"]
|
147
|
+
end
|
158
148
|
end ].each do |data|
|
159
149
|
e << data
|
160
150
|
end
|
@@ -164,7 +154,6 @@ module RedditBot
|
|
164
154
|
end
|
165
155
|
end
|
166
156
|
|
167
|
-
# :yields: JSON objects: ["data"] part of post or self.post, top level comment (["children"] element)
|
168
157
|
def each_new_post_with_top_level_comments
|
169
158
|
# TODO add keys assertion like in method above?
|
170
159
|
json(:get, "/r/#{@subreddit}/new")["data"]["children"].each do |post|
|
@@ -178,7 +167,6 @@ module RedditBot
|
|
178
167
|
end
|
179
168
|
end
|
180
169
|
|
181
|
-
# [article] +String+ ID36 of a post or self.post
|
182
170
|
def each_comment_of_the_post_thread article
|
183
171
|
Enumerator.new do |e|
|
184
172
|
f = lambda do |smth|
|
@@ -194,6 +182,27 @@ module RedditBot
|
|
194
182
|
end
|
195
183
|
end
|
196
184
|
|
185
|
+
def subreddit_iterate what, **kwargs
|
186
|
+
Enumerator.new do |e|
|
187
|
+
after = {}
|
188
|
+
loop do
|
189
|
+
break unless marker = json(:get, "/r/#{@subreddit}/#{what}", {limit: 100}.merge(after).merge(kwargs)).tap do |result|
|
190
|
+
fail if %w{ kind data } != result.keys
|
191
|
+
fail if "Listing" != result["kind"]
|
192
|
+
fail result["data"].keys.inspect unless result["data"].keys == %w{ after dist modhash whitelist_status children before } ||
|
193
|
+
result["data"].keys == %w{ modhash dist children after before }
|
194
|
+
result["data"]["children"].each do |post|
|
195
|
+
fail "unknown type post['kind']: #{post["kind"]}" unless post["kind"] == "t3"
|
196
|
+
e << ( post["data"].tap do |data|
|
197
|
+
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"]
|
198
|
+
end )
|
199
|
+
end
|
200
|
+
end["data"]["after"]
|
201
|
+
after = {after: marker}
|
202
|
+
end
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
197
206
|
private
|
198
207
|
|
199
208
|
def token
|
@@ -205,7 +214,7 @@ module RedditBot
|
|
205
214
|
username: @name,
|
206
215
|
password: @secret_password,
|
207
216
|
}, {
|
208
|
-
"User-Agent" => "bot/#{@user_agent || @name}/#{
|
217
|
+
"User-Agent" => "bot/#{@user_agent || @name}/#{Gem::Specification::load("#{__dir__}/../reddit_bot.gemspec").version} by /u/nakilon",
|
209
218
|
}, @secret_auth
|
210
219
|
unless @token_cached = response["access_token"]
|
211
220
|
fail "bot #{@name} isn't a 'developer' of app at https://www.reddit.com/prefs/apps/" if response == {"error"=>"invalid_grant"}
|
@@ -232,7 +241,7 @@ module RedditBot
|
|
232
241
|
begin
|
233
242
|
reddit_resp mtd, "https://oauth.reddit.com" + path, form, {
|
234
243
|
"Authorization" => "bearer #{token}",
|
235
|
-
"User-Agent" => "bot/#{@user_agent || @name}/#{
|
244
|
+
"User-Agent" => "bot/#{@user_agent || @name}/#{Gem::Specification::load("#{__dir__}/../reddit_bot.gemspec").version} by /u/nakilon",
|
236
245
|
}
|
237
246
|
rescue NetHTTPUtils::Error => e
|
238
247
|
raise unless e.code == 401
|
@@ -303,14 +312,7 @@ module RedditBot
|
|
303
312
|
"https://api.twitter.com/1.1/statuses/user_timeline.json",
|
304
313
|
form: { screen_name: TWITTER_ACCOUNT, count: 200, tweet_mode: "extended" },
|
305
314
|
header: { Authorization: "Bearer #{TWITTER_ACCESS_TOKEN}" }
|
306
|
-
)
|
307
|
-
next unless res.key? "x-rate-limit-remaining"
|
308
|
-
remaining = res.fetch("x-rate-limit-remaining").to_i
|
309
|
-
next if 100 < remaining
|
310
|
-
t = (res.fetch("x-rate-limit-reset").to_i - Time.now.to_i + 1).fdiv remaining
|
311
|
-
puts "sleep #{t}"
|
312
|
-
sleep t
|
313
|
-
end
|
315
|
+
)
|
314
316
|
rescue NetHTTPUtils::Error => e
|
315
317
|
fail unless [500, 503].include? e.code
|
316
318
|
sleep timeout
|
data/reddit_bot.gemspec
CHANGED
@@ -1,23 +1,21 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = "reddit_bot"
|
3
|
-
spec.version = "1.
|
4
|
-
spec.
|
5
|
-
spec.email = ["nakilon@gmail.com"]
|
3
|
+
spec.version = "1.9.0"
|
4
|
+
spec.summary = "Simple library for Reddit bots"
|
6
5
|
|
7
|
-
spec.
|
8
|
-
spec.
|
9
|
-
spec.homepage = "https://github.com/Nakilon/reddit_bot"
|
6
|
+
spec.author = "Victor Maslov aka Nakilon"
|
7
|
+
spec.email = "nakilon@gmail.com"
|
10
8
|
spec.license = "MIT"
|
9
|
+
spec.metadata = {"source_code_uri" => "https://github.com/Nakilon/reddit_bot"}
|
11
10
|
|
12
|
-
spec.
|
13
|
-
|
14
|
-
|
15
|
-
spec.add_runtime_dependency "json"
|
16
|
-
spec.add_runtime_dependency "nethttputils", "~>0.4.0.0"
|
11
|
+
spec.add_dependency "json_pure"
|
12
|
+
spec.add_dependency "nethttputils", "~>0.4.1.0"
|
17
13
|
# spec.add_development_dependency "bundler", "~> 1.11"
|
18
14
|
# spec.add_development_dependency "rake", "~> 10.0"
|
19
15
|
# spec.add_development_dependency "rspec", "~> 3.0"
|
20
16
|
spec.required_ruby_version = ">= 2.0.0"
|
17
|
+
|
18
|
+
spec.files = %w{ LICENSE.txt reddit_bot.gemspec lib/reddit_bot.rb }
|
21
19
|
end
|
22
20
|
|
23
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.9.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-16 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,89 +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
49
|
- reddit_bot.gemspec
|
112
|
-
homepage:
|
50
|
+
homepage:
|
113
51
|
licenses:
|
114
52
|
- MIT
|
115
|
-
metadata:
|
53
|
+
metadata:
|
54
|
+
source_code_uri: https://github.com/Nakilon/reddit_bot
|
116
55
|
post_install_message:
|
117
56
|
rdoc_options: []
|
118
57
|
require_paths:
|
@@ -132,5 +71,5 @@ rubyforge_project:
|
|
132
71
|
rubygems_version: 2.5.2.3
|
133
72
|
signing_key:
|
134
73
|
specification_version: 4
|
135
|
-
summary:
|
74
|
+
summary: Simple library for Reddit bots
|
136
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