reddit_bot 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +6 -0
- data/examples/boilerplate.rb +15 -0
- data/examples/iostroubleshooting/Gemfile +5 -0
- data/examples/iostroubleshooting/Gemfile.lock +15 -0
- data/examples/iostroubleshooting/main.rb +37 -0
- data/lib/reddit_bot.rb +1 -1
- metadata +6 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cf853922de330ff48fbb769f10d7f49375c1af7c
|
4
|
+
data.tar.gz: 951e17435175ecbd77704ccc91b2ec262081a317
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1ee0c205ec62a088e7336ecbefc760fb8bf0f91f2af46ceace29678fc9ad002d0c4924c3fb0baca7c84f8faf00ced71f6fdecabd2e6ae954617fff1a318e2a22
|
7
|
+
data.tar.gz: 2cf030135c7458facff5432319f5ee2fbbbe590a8ab68352187df20ac29927cd87db14c19a44c4900ab4f080be089e2cea4260e9b283396bc3aca6a7ad92489c
|
data/Rakefile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
STDOUT.sync = true
|
2
|
+
|
3
|
+
require "pp"
|
4
|
+
|
5
|
+
require_relative File.join \
|
6
|
+
*("../../../download_with_retry" if ENV["LOGNAME"] == "nakilon"),
|
7
|
+
"download_with_retry"
|
8
|
+
|
9
|
+
require "reddit_bot"
|
10
|
+
# RedditBot.init *File.read(File.join(Dir.pwd, "secrets")).split, ignore_captcha: true
|
11
|
+
RedditBot.init *File.read("secrets").split, ignore_captcha: true
|
12
|
+
|
13
|
+
require_relative File.join \
|
14
|
+
*("../../.." if ENV["LOGNAME"] == "nakilon"),
|
15
|
+
"awsstatus/2.rb"
|
@@ -0,0 +1,37 @@
|
|
1
|
+
STDOUT.sync = true
|
2
|
+
|
3
|
+
require_relative File.join "..", "boilerplate"
|
4
|
+
|
5
|
+
# SUBREDDIT = "test___________"
|
6
|
+
SUBREDDIT = "iostroubleshooting"
|
7
|
+
|
8
|
+
# require "open-uri"
|
9
|
+
require "csv" # /api/flaircsv
|
10
|
+
|
11
|
+
loop do
|
12
|
+
AWSStatus::touch
|
13
|
+
catch :loop do
|
14
|
+
|
15
|
+
existing = RedditBot.json(:get, "/r/#{SUBREDDIT}/api/flairlist")["users"]
|
16
|
+
begin
|
17
|
+
JSON.parse(DownloadWithRetry::download_with_retry("#{File.read "gas.url"}sheet_name=Bot&spreadsheet_id=10UzXUbawBgXLQkxXDMz28Qcx3IQPjwG9nByd_d8y31I", &:read))
|
18
|
+
rescue JSON::ParserError
|
19
|
+
puts "smth wrong with GAS script"
|
20
|
+
throw :loop
|
21
|
+
end.drop(1).reverse.uniq{ |_, user, _, _| user }.map do |row|
|
22
|
+
next unless row.map(&:empty?) == [false, false, false, false]
|
23
|
+
_, user, ios, flair = row
|
24
|
+
next if existing.include?({"flair_css_class"=>flair, "user"=>user, "flair_text"=>ios})
|
25
|
+
[user, ios, flair]
|
26
|
+
# {"iPhone"=>"greenflair", "iPad"=>"blue", "iPod"=>"red"}[device[/iP(od|ad|hone)/]]]
|
27
|
+
end.compact.each_slice(50) do |slice|
|
28
|
+
CSV(load = ""){ |csv| slice.each{ |record| csv << record } }
|
29
|
+
puts load
|
30
|
+
RedditBot.json(:post, "/r/#{SUBREDDIT}/api/flaircsv", [["flair_csv", load]]).each do |report|
|
31
|
+
pp report unless report.values_at("errors", "ok", "warnings") == [{}, true, {}]
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
sleep 60
|
37
|
+
end
|
data/lib/reddit_bot.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: reddit_bot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Victor Maslov
|
@@ -19,6 +19,11 @@ extra_rdoc_files: []
|
|
19
19
|
files:
|
20
20
|
- Gemfile
|
21
21
|
- LICENSE.txt
|
22
|
+
- Rakefile
|
23
|
+
- examples/boilerplate.rb
|
24
|
+
- examples/iostroubleshooting/Gemfile
|
25
|
+
- examples/iostroubleshooting/Gemfile.lock
|
26
|
+
- examples/iostroubleshooting/main.rb
|
22
27
|
- lib/reddit_bot.rb
|
23
28
|
- reddit_bot.gemspec
|
24
29
|
homepage: ''
|