reddit_bot 1.1.3 → 1.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/examples/yayornay/Gemfile.lock +1 -1
- data/examples/yayornay/main.rb +5 -3
- data/lib/reddit_bot.rb +4 -5
- 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: 8779f90d67996246020d69b0288414365eeafd95
|
4
|
+
data.tar.gz: 9d3e19f33612f51a9f11ff10a40d755b07c87a1e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f1c70de7d22dad5f26f422ae8beaaddb347ee47d39ff8373f350f74fe4df561ef4f539c9b26e65bc8d09fccc82333381fdd50c59a49ae9d54fd82bcc46270dc7
|
7
|
+
data.tar.gz: b6042babc2756fcb5afe329e2aa070de12b464171be3d6a6fa0533fe2bb34df960c2252f09728766281d9c5e7a663f977d41ca92931ec4750f672b0236921b94
|
data/examples/yayornay/main.rb
CHANGED
@@ -24,9 +24,11 @@ loop do
|
|
24
24
|
proper_text = "#{(100 * yay / total).round}% Yay"
|
25
25
|
next if [proper_class, proper_text] == [post["link_flair_css_class"], post["link_flair_text"]]
|
26
26
|
puts "setting #{[proper_class, proper_text]} to #{post["name"]}"
|
27
|
-
|
28
|
-
|
29
|
-
|
27
|
+
if _ = BOT.set_post_flair(post, proper_class, proper_text)
|
28
|
+
fail _.inspect unless _ = {"json"=>{"errors"=>[]}}
|
29
|
+
else
|
30
|
+
# 403
|
31
|
+
end
|
30
32
|
end
|
31
33
|
|
32
34
|
puts "END LOOP #{Time.now}"
|
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.4" # :nodoc:
|
12
12
|
|
13
13
|
class Bot
|
14
14
|
|
@@ -77,12 +77,11 @@ module RedditBot
|
|
77
77
|
# [link_flair_text] :nodoc:
|
78
78
|
def set_post_flair post, link_flair_css_class, link_flair_text
|
79
79
|
puts "setting flair '#{link_flair_css_class}' with text '#{link_flair_text}' to post '#{post["name"]}'"
|
80
|
+
return puts "possibly not enough permissions for /r/#{@subreddit}/api/flairselector" if {"error"=>403} == @flairselector_choices ||= json(:post, "/r/#{@subreddit}/api/flairselector", link: post["name"])
|
80
81
|
json :post, "/api/selectflair",
|
81
82
|
link: post["name"],
|
82
83
|
text: link_flair_text,
|
83
|
-
flair_template_id:
|
84
|
-
json :post, "/r/#{@subreddit}/api/flairselector", link: post["name"]
|
85
|
-
)["choices"].find{ |i| i["flair_css_class"] == link_flair_css_class }.tap{ |flair|
|
84
|
+
flair_template_id: @flairselector_choices["choices"].find{ |i| i["flair_css_class"] == link_flair_css_class }.tap{ |flair|
|
86
85
|
fail "can't find '#{link_flair_css_class}' flair class at https://www.reddit.com/r/#{@subreddit}/about/flair/#link_templates" unless flair
|
87
86
|
}["flair_template_id"]
|
88
87
|
end
|
@@ -189,7 +188,7 @@ module RedditBot
|
|
189
188
|
@token_cached = nil # maybe just update_captcha?
|
190
189
|
throw :"401"
|
191
190
|
when "403"
|
192
|
-
puts "access denied: #{response.body}"
|
191
|
+
puts "access denied: #{response.body} when requesting: #{args}"
|
193
192
|
sleep 5
|
194
193
|
# throw :"403"
|
195
194
|
when "200"
|
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.4
|
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-03-
|
11
|
+
date: 2016-03-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -81,3 +81,4 @@ signing_key:
|
|
81
81
|
specification_version: 4
|
82
82
|
summary: Library for Reddit bots
|
83
83
|
test_files: []
|
84
|
+
has_rdoc:
|