reddit_bot 1.6.13 → 1.7.0
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/README.md +10 -2
- data/examples/Gemfile.lock +6 -24
- data/examples/councilofricks/main.rb +1 -1
- data/examples/cptflairbot3/main.rb +1 -1
- data/examples/devflairbot/main.rb +1 -1
- data/examples/largeimages/Gemfile.lock +1 -1
- data/examples/largeimages/main.rb +1 -1
- data/examples/mlgtv/main.rb +1 -1
- data/examples/sexypizza/Gemfile.lock +2 -2
- data/examples/sexypizza/main.rb +0 -1
- data/examples/wallpaper/Gemfile +3 -3
- data/examples/wallpaper/Gemfile.lock +21 -14
- data/examples/wallpaper/main.rb +9 -15
- data/examples/yayornay/Gemfile.lock +2 -2
- data/examples/yayornay/main.rb +0 -1
- data/lib/reddit_bot.rb +4 -2
- data/lib/reddit_bot/version.rb +1 -1
- data/reddit_bot.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f0c06107eb4207ba45e047f0215189bd5fe47fc2
|
4
|
+
data.tar.gz: e0d609e5b43af0229d3b8f96b0f9dd406635ae56
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4978e63e9a25c61094f15db396f274099e4ccf9f475fb1c71b630d9fe717cd07764a29fd3bb56533cedc55e071a79cd1a37911255635663d2f20d7c7507931bc
|
7
|
+
data.tar.gz: 07cf64c0550cb8505a2dfb87b86bf503680ac24c3020ba3791aede79fe9ea452fd307a164b8abf647f9bca311eb124ed18b117d2b0e64e1e44f7f856d62bdd13
|
data/README.md
CHANGED
@@ -67,9 +67,11 @@ or via Gemfile:
|
|
67
67
|
|
68
68
|
helloworld.rb:
|
69
69
|
|
70
|
-
|
70
|
+
```ruby
|
71
|
+
require "reddit_bot"
|
72
|
+
```
|
71
73
|
|
72
|
-
You obviously can't run these examples as is, because they use
|
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:
|
73
75
|
|
74
76
|
:client_id: Kb9.......6wBw
|
75
77
|
:client_secret: Fqo.....................AFI
|
@@ -77,6 +79,12 @@ You obviously can't run these examples as is, because they use some dependencies
|
|
77
79
|
:login: MyBotUsername
|
78
80
|
# :user_agent: optional_custom_useragent_to_bypass_reddit_spam_protection
|
79
81
|
|
82
|
+
To change the log level:
|
83
|
+
|
84
|
+
```ruby
|
85
|
+
RedditBot.logger.level = Logger::ERROR
|
86
|
+
```
|
87
|
+
|
80
88
|
To update the gem version in Gemfile.lock when using Gemfile like this: `gem "reddit_bot", "~>1.1.0"`, do the:
|
81
89
|
|
82
90
|
$ bundle update reddit_bot
|
data/examples/Gemfile.lock
CHANGED
@@ -1,35 +1,17 @@
|
|
1
|
-
GIT
|
2
|
-
remote: git@github.com:Nakilon/imgur2array.git
|
3
|
-
revision: eea2aa8a39d72726318aae8805b66bcddd7acbb6
|
4
|
-
tag: v0.0.2.7
|
5
|
-
specs:
|
6
|
-
imgur2array (0.0.2.7)
|
7
|
-
|
8
|
-
GIT
|
9
|
-
remote: git@github.com:Nakilon/nethttputils.git
|
10
|
-
revision: 84ac32db6d44b68f5bd6e2f1ce8698fc5e2ad968
|
11
|
-
tag: v0.0.4.1
|
12
|
-
specs:
|
13
|
-
nethttputils (0.0.4.1)
|
14
|
-
|
15
1
|
GEM
|
16
2
|
remote: https://rubygems.org/
|
17
3
|
specs:
|
18
|
-
addressable (2.5.2)
|
19
|
-
public_suffix (>= 2.0.2, < 4.0)
|
20
|
-
fastimage (1.7.0)
|
21
|
-
addressable (~> 2.3, >= 2.3.5)
|
22
4
|
json (2.1.0)
|
23
|
-
|
5
|
+
nethttputils (0.2.5.1)
|
6
|
+
reddit_bot (1.6.13)
|
7
|
+
json
|
8
|
+
nethttputils (~> 0.2.5.1)
|
24
9
|
|
25
10
|
PLATFORMS
|
26
11
|
ruby
|
27
12
|
|
28
13
|
DEPENDENCIES
|
29
|
-
|
30
|
-
imgur2array!
|
31
|
-
json
|
32
|
-
nethttputils!
|
14
|
+
reddit_bot
|
33
15
|
|
34
16
|
BUNDLED WITH
|
35
|
-
1.
|
17
|
+
1.17.1
|
@@ -4,7 +4,7 @@
|
|
4
4
|
# so it's possible to miss if bot is down for a while but in fact it's enough stable and does not go down.
|
5
5
|
|
6
6
|
require_relative "../boilerplate"
|
7
|
-
BOT = RedditBot::Bot.new YAML.
|
7
|
+
BOT = RedditBot::Bot.new YAML.load_file "secrets.yaml"
|
8
8
|
|
9
9
|
fail("no ENV['ERROR_REPORTING_KEYFILE'] specified") unless ENV["ERROR_REPORTING_KEYFILE"]
|
10
10
|
require "google/cloud/error_reporting"
|
data/examples/mlgtv/main.rb
CHANGED
data/examples/sexypizza/main.rb
CHANGED
@@ -4,7 +4,6 @@ BOT = RedditBot::Bot.new YAML.load(File.read "secrets.yaml"), ignore_captcha: tr
|
|
4
4
|
SUBREDDIT = "sexypizza"
|
5
5
|
|
6
6
|
loop do
|
7
|
-
Hearthbeat.beat "u_SexyPizzaBot_r_sexypizza", 3610 unless Gem::Platform.local.os == "darwin"
|
8
7
|
puts "LOOP #{Time.now}"
|
9
8
|
|
10
9
|
flairs = BOT.json(:get, "/r/#{SUBREDDIT}/api/flairlist", {limit: 1000})["users"]
|
data/examples/wallpaper/Gemfile
CHANGED
@@ -1,26 +1,33 @@
|
|
1
|
-
GIT
|
2
|
-
remote: https://gist.github.com/97549ceb58d21e1fcbc0e6cdaf92fce8.git
|
3
|
-
revision: 54c47ab3f9665f3e35a8e94fdd267e3743c736a9
|
4
|
-
specs:
|
5
|
-
net_http_utils (0)
|
6
|
-
|
7
1
|
GEM
|
8
2
|
remote: https://rubygems.org/
|
9
3
|
specs:
|
10
|
-
addressable (2.
|
11
|
-
|
12
|
-
|
4
|
+
addressable (2.5.2)
|
5
|
+
public_suffix (>= 2.0.2, < 4.0)
|
6
|
+
directlink (0.0.4.7)
|
7
|
+
addressable
|
8
|
+
fastimage (~> 2.1.3)
|
9
|
+
kramdown
|
10
|
+
nokogiri
|
11
|
+
reddit_bot (~> 1.6.13)
|
12
|
+
fastimage (2.1.5)
|
13
13
|
json (2.1.0)
|
14
|
-
|
14
|
+
kramdown (1.17.0)
|
15
|
+
mini_portile2 (2.1.0)
|
16
|
+
nethttputils (0.2.5.1)
|
17
|
+
nokogiri (1.6.8.1)
|
18
|
+
mini_portile2 (~> 2.1.0)
|
19
|
+
public_suffix (2.0.5)
|
20
|
+
reddit_bot (1.6.13)
|
15
21
|
json
|
22
|
+
nethttputils (~> 0.2.5.1)
|
16
23
|
|
17
24
|
PLATFORMS
|
18
25
|
ruby
|
19
26
|
|
20
27
|
DEPENDENCIES
|
21
|
-
|
22
|
-
|
23
|
-
|
28
|
+
directlink
|
29
|
+
nokogiri (~> 1.6.7)
|
30
|
+
public_suffix (< 3.0)
|
24
31
|
|
25
32
|
BUNDLED WITH
|
26
|
-
1.
|
33
|
+
1.17.1
|
data/examples/wallpaper/main.rb
CHANGED
@@ -1,31 +1,25 @@
|
|
1
1
|
require_relative "../boilerplate"
|
2
2
|
|
3
|
-
BOT = RedditBot::Bot.new YAML.
|
3
|
+
BOT = RedditBot::Bot.new YAML.load_file "secrets.yaml"
|
4
4
|
SUBREDDIT = "wallpaper"
|
5
5
|
|
6
|
-
|
7
|
-
require_relative "../../../../dimensioner/get_dimensions"
|
8
|
-
else
|
9
|
-
require_relative "#{Dir.home}/get_dimensions"
|
10
|
-
end
|
6
|
+
require "directlink"
|
11
7
|
|
12
8
|
checked = []
|
13
9
|
loop do
|
14
|
-
Hearthbeat.beat "u_wallpaperpedantbot_r_#{SUBREDDIT}", 70 unless Gem::Platform.local.os == "darwin"
|
15
10
|
puts "LOOP #{Time.now}"
|
16
11
|
|
17
12
|
BOT.json(:get, "/r/#{SUBREDDIT}/new")["data"]["children"].each do |post|
|
18
13
|
id, url, title, subreddit = post["data"].values_at(*%w{ id url title subreddit })
|
19
14
|
next if checked.include? id
|
20
15
|
checked.push id
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
BOT.report "true resolution is #{resolution}", "t3_#{id}" unless result
|
16
|
+
t = DirectLink url
|
17
|
+
(t.is_a?(Array) ? t : [t]).each do |s|
|
18
|
+
resolution = "#{s.width}x#{s.height}"
|
19
|
+
result = title[/\s*\[?#{s.width}\s*[*x×]\s*#{s.height}\]?\s*/i]
|
20
|
+
puts "#{!!result} #{id} [#{resolution}] #{title} #{s.url}"
|
21
|
+
BOT.report "true resolution is #{resolution}", "t3_#{id}" unless result
|
22
|
+
end
|
29
23
|
end
|
30
24
|
|
31
25
|
puts "END LOOP #{Time.now}"
|
data/examples/yayornay/main.rb
CHANGED
@@ -4,7 +4,6 @@ SUBREDDIT = "yayornay"
|
|
4
4
|
BOT = RedditBot::Bot.new YAML.load(File.read "secrets.yaml"), subreddit: SUBREDDIT
|
5
5
|
|
6
6
|
loop do
|
7
|
-
Hearthbeat.beat "u_gotfan247_r_yayornay", 310 unless Gem::Platform.local.os == "darwin"
|
8
7
|
puts "LOOP #{Time.now}"
|
9
8
|
|
10
9
|
BOT.each_new_post_with_top_level_comments do |post, comments|
|
data/lib/reddit_bot.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
STDOUT.sync = true
|
2
2
|
# require "pp"
|
3
3
|
|
4
|
-
require "net/http"
|
5
4
|
require "openssl"
|
6
5
|
require "json"
|
7
6
|
|
@@ -228,13 +227,16 @@ module RedditBot
|
|
228
227
|
|
229
228
|
def resp_with_token mtd, path, form
|
230
229
|
fail unless path.start_with? ?/
|
230
|
+
timeout = 5
|
231
231
|
begin
|
232
232
|
reddit_resp mtd, "https://oauth.reddit.com" + path, form, {
|
233
233
|
"Authorization" => "bearer #{token}",
|
234
234
|
"User-Agent" => "bot/#{@user_agent || @name}/#{RedditBot::VERSION} by /u/nakilon",
|
235
235
|
}
|
236
236
|
rescue NetHTTPUtils::Error => e
|
237
|
-
sleep
|
237
|
+
sleep timeout
|
238
|
+
Module.nesting[1].logger.info "sleeping #{timeout} seconds because of #{e.code}"
|
239
|
+
timeout *= 2
|
238
240
|
raise unless e.code == 401
|
239
241
|
@token_cached = nil
|
240
242
|
retry
|
data/lib/reddit_bot/version.rb
CHANGED
data/reddit_bot.gemspec
CHANGED
@@ -15,7 +15,7 @@ Gem::Specification.new do |spec|
|
|
15
15
|
# spec.require_paths = ["lib"]
|
16
16
|
|
17
17
|
spec.add_runtime_dependency "json"
|
18
|
-
spec.add_runtime_dependency "nethttputils", "~>0.
|
18
|
+
spec.add_runtime_dependency "nethttputils", "~>0.3.1.0"
|
19
19
|
# spec.add_development_dependency "bundler", "~> 1.11"
|
20
20
|
# spec.add_development_dependency "rake", "~> 10.0"
|
21
21
|
# spec.add_development_dependency "rspec", "~> 3.0"
|
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.
|
4
|
+
version: 1.7.0
|
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-12-
|
11
|
+
date: 2018-12-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
33
|
+
version: 0.3.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.
|
40
|
+
version: 0.3.1.0
|
41
41
|
description: better than PRAW
|
42
42
|
email:
|
43
43
|
- nakilon@gmail.com
|