reddit_bot 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/examples/boilerplate.rb +2 -2
- data/examples/iostroubleshooting/main.rb +0 -2
- data/examples/mlgtv/Gemfile +4 -0
- data/examples/mlgtv/Gemfile.lock +13 -0
- data/examples/mlgtv/main.rb +76 -0
- data/lib/reddit_bot.rb +1 -1
- data/reddit_bot.gemspec +3 -2
- metadata +22 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: daabdb0e46020c2a06840b208f784b7ef1fad493
|
4
|
+
data.tar.gz: 4f8efbfc0df0c6e7679d0b55bc5100079ee8eb7e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6a434f58cf7e6c9f1b8fdea7c37ab65725458aa241772d30d0d6fb3c9bbc645a4ce37d54c2eacccd0268e986f5bd5a662a10eed5a48ed314a053b7f3374d33c
|
7
|
+
data.tar.gz: c9eca04193797593324ad5b51be85e875dbcdbd493afe1fff71225445313fa03b191c0171a4667d54ea2ee9a990eadbaedee266be50eae2880dd723a9f2fcfff
|
data/examples/boilerplate.rb
CHANGED
@@ -2,8 +2,8 @@ STDOUT.sync = true
|
|
2
2
|
|
3
3
|
require "pp"
|
4
4
|
|
5
|
-
require_relative File.join
|
6
|
-
*("
|
5
|
+
require_relative File.join "../..",
|
6
|
+
*("../download_with_retry" if ENV["LOGNAME"] == "nakilon"),
|
7
7
|
"download_with_retry"
|
8
8
|
|
9
9
|
require "reddit_bot"
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require_relative File.join "..", "boilerplate"
|
2
|
+
|
3
|
+
SUBREDDIT = "codcompetitive"
|
4
|
+
# SUBREDDIT = "test___________"
|
5
|
+
|
6
|
+
loop do
|
7
|
+
AWSStatus::touch
|
8
|
+
catch :loop do
|
9
|
+
|
10
|
+
text = " Live Streams\n\n" + [].tap do |list|
|
11
|
+
|
12
|
+
throw :loop unless statuses = JSON.parse(
|
13
|
+
DownloadWithRetry::download_with_retry("http://streamapi.majorleaguegaming.com/service/streams/all")[/\{.+\}/m]
|
14
|
+
)["data"]["items"]
|
15
|
+
begin
|
16
|
+
JSON.parse DownloadWithRetry::download_with_retry(
|
17
|
+
# DownloadWithRetry::download_with_retry("http://www.majorleaguegaming.com/api/channels/all.js?fields=id,name,slug,subtitle,game_id,stream_name,type,default_tab,is_hidden,chat_is_disabled,image_1_1,image_16_9,image_16_9_small,image_16_9_medium,image_background,url,embed_code,stream_featured,stream_sort_order,tags,tag_names,children,description,subscription_url,donate_url,donate_text,partner_embed")
|
18
|
+
"http://www.majorleaguegaming.com/api/channels/all.js?fields=name,url,tags,stream_name"
|
19
|
+
)
|
20
|
+
rescue JSON::ParserError
|
21
|
+
puts "JSON::ParserError"
|
22
|
+
sleep 60
|
23
|
+
retry
|
24
|
+
end["data"]["items"].each do |item1|
|
25
|
+
next unless item1["tags"].include? "COD Pro League"
|
26
|
+
status = statuses.find{ |item2| item1["stream_name"] == item2["stream_name"] }
|
27
|
+
next unless status && status["status"] > 0
|
28
|
+
list << "* [](#mlg) [](##{
|
29
|
+
["?", "live", "replay"][status["status"]]
|
30
|
+
}) [**#{
|
31
|
+
item1["name"]
|
32
|
+
}**](#{
|
33
|
+
item1["url"]
|
34
|
+
})"
|
35
|
+
end
|
36
|
+
|
37
|
+
require "cgi"
|
38
|
+
JSON.parse(DownloadWithRetry::download_with_retry(
|
39
|
+
"https://api.twitch.tv/kraken/streams?game=#{CGI::escape "Call of Duty: Black Ops III"}&access_token=#{File.read "twitch.token"}&channel=TyreeLegal,Phizzurp,TheFEARS,CMPLXX,Methodz,Blfire,Tylerfelo,Sender_cw,Diabolic_tv,MJChino,Clayster,Enable,Attach,Zoomaaa,John,ReplaysTV,SpacelyTV,ColeChanTV,SaintsRF,Proofy,Whea7s,ParasiteTV,Ricky,Nameless,Mirx1,Formal,Karma,Scumperjumper,Crimsix,Slacked,Octane,Aqua,Nagafen,Faccento,Jkap,Aches,Teepee,Sharp,Neslo,Goon_jar,TheoryCOD,SteveMochilaCanle,Silly,Merk,Studyy,K1lla93,Burns,Dedo,Swanny,Tommey,DylDaly,Gotaga,QwikerThanU,TCM_Moose,Themarkyb,Maven,MattMrX,CourageJD,Happyy97,Revan,PacmanianDevil,Loonnny,BriceyHD,TeeCM,Senderxz,Zoomaa"
|
40
|
+
))["streams"].each do |channel|
|
41
|
+
list << "* [](#twitch) [](#live) [**#{
|
42
|
+
channel["channel"]["display_name"]
|
43
|
+
}**](#{
|
44
|
+
channel["channel"]["url"]
|
45
|
+
})"
|
46
|
+
end
|
47
|
+
|
48
|
+
end.join(" \n") + "\n"
|
49
|
+
|
50
|
+
settings = RedditBot.json(:get, "/r/#{SUBREDDIT}/about/edit")["data"]
|
51
|
+
# https://github.com/praw-dev/praw/blob/c45e5f6ca0c5cd9968b51301989eb82740f8dc85/praw/__init__.py#L1592
|
52
|
+
settings.store "sr", settings.delete("subreddit_id")
|
53
|
+
settings.store "lang", settings.delete("language")
|
54
|
+
settings.store "link_type", settings.delete("content_options")
|
55
|
+
settings.store "type", settings.delete("subreddit_type")
|
56
|
+
settings.store "header-title", settings.delete("header_hover_text") || ""
|
57
|
+
settings["domain"] ||= ""
|
58
|
+
settings["submit_link_label"] ||= ""
|
59
|
+
settings["submit_text_label"] ||= ""
|
60
|
+
settings["allow_top"] = settings["allow_top"]
|
61
|
+
settings.delete "default_set"
|
62
|
+
|
63
|
+
prefix, postfix = settings["description"].split(/(?<=\n#####)\s*Live Streams.+?(?=\n#+)/im)
|
64
|
+
unless postfix
|
65
|
+
puts "!!! can't parse sidebar !!!"
|
66
|
+
throw :loop
|
67
|
+
end
|
68
|
+
next puts "nothing to change" if prefix + text + postfix == settings["description"]
|
69
|
+
|
70
|
+
settings["description"] = prefix + text + postfix
|
71
|
+
_ = RedditBot.json :post, "/api/site_admin", settings.to_a
|
72
|
+
fail _.inspect if _ != {"json"=>{"errors"=>[]}} && !(_["json"]["errors"].map(&:first) - ["BAD_CAPTCHA"]).empty?
|
73
|
+
|
74
|
+
end
|
75
|
+
sleep 60
|
76
|
+
end
|
data/lib/reddit_bot.rb
CHANGED
data/reddit_bot.gemspec
CHANGED
@@ -10,13 +10,14 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ["nakilon@gmail.com"]
|
11
11
|
|
12
12
|
spec.summary = "Library for Reddit bots"
|
13
|
-
spec.description = ""
|
14
|
-
spec.homepage = ""
|
13
|
+
spec.description = "better than PRAW"
|
14
|
+
spec.homepage = "https://github.com/Nakilon/reddit_bot"
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
17
17
|
spec.files = `git ls-files -z`.split("\x0")#.reject { |f| f.match(%r{^(test|spec|features)/})/ }
|
18
18
|
# spec.require_paths = ["lib"]
|
19
19
|
|
20
|
+
spec.add_runtime_dependency "json"
|
20
21
|
# spec.add_development_dependency "bundler", "~> 1.11"
|
21
22
|
# spec.add_development_dependency "rake", "~> 10.0"
|
22
23
|
# spec.add_development_dependency "rspec", "~> 3.0"
|
metadata
CHANGED
@@ -1,16 +1,30 @@
|
|
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.2
|
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-01-
|
12
|
-
dependencies:
|
13
|
-
|
11
|
+
date: 2016-01-09 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: json
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
description: better than PRAW
|
14
28
|
email:
|
15
29
|
- nakilon@gmail.com
|
16
30
|
executables: []
|
@@ -24,9 +38,12 @@ files:
|
|
24
38
|
- examples/iostroubleshooting/Gemfile
|
25
39
|
- examples/iostroubleshooting/Gemfile.lock
|
26
40
|
- examples/iostroubleshooting/main.rb
|
41
|
+
- examples/mlgtv/Gemfile
|
42
|
+
- examples/mlgtv/Gemfile.lock
|
43
|
+
- examples/mlgtv/main.rb
|
27
44
|
- lib/reddit_bot.rb
|
28
45
|
- reddit_bot.gemspec
|
29
|
-
homepage:
|
46
|
+
homepage: https://github.com/Nakilon/reddit_bot
|
30
47
|
licenses:
|
31
48
|
- MIT
|
32
49
|
metadata: {}
|