repltalk 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/queries.rb +12 -0
- data/lib/repltalk.rb +19 -5
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cb325d2217b8b9e4a283dce8405cc1288fb430377d030f7fb201d344e8348f23
|
4
|
+
data.tar.gz: 3f35941f2a9d0542bc6c6fb205d9d1bd97c570921b6ab666b4b49aeef9f40c8a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 20f4e65ddc1174889fb2767a1b87a1bf3d7ee418094b665e3b8b3de77884f0ddad956aa417b4db134f0fa9a57266dc4f5f6727aa26710a9ca4242fc3a0b79f56
|
7
|
+
data.tar.gz: 03d580505be28f0aa190d417ef6a33c4a71f154e15c0a26e196b0fe8e38a3efe4661a53d28a5a0a82cb6a2b0a6ff667e9da57c53bd17f329d6523b5da7075fef
|
data/lib/queries.rb
CHANGED
@@ -154,6 +154,18 @@ class Queries
|
|
154
154
|
}"
|
155
155
|
end
|
156
156
|
|
157
|
+
def Queries.get_posts_comments
|
158
|
+
"query post($postId: Int!, $order: String, $count: Int, $after: String) {
|
159
|
+
post(id: $postId) {
|
160
|
+
comments(order: $order, count: $count, after: $after) {
|
161
|
+
items {
|
162
|
+
#{@@comment}
|
163
|
+
}
|
164
|
+
}
|
165
|
+
}
|
166
|
+
}"
|
167
|
+
end
|
168
|
+
|
157
169
|
def Queries.get_comment
|
158
170
|
"query comment ($id: Int!) {
|
159
171
|
comment(id: $id) {
|
data/lib/repltalk.rb
CHANGED
@@ -2,6 +2,8 @@ require "http"
|
|
2
2
|
require "json"
|
3
3
|
require_relative "queries"
|
4
4
|
|
5
|
+
$BASE_URL = "https://repl.it"
|
6
|
+
|
5
7
|
class Role
|
6
8
|
attr_reader :name, :key, :tagline
|
7
9
|
|
@@ -58,7 +60,7 @@ class Repl
|
|
58
60
|
@client = client
|
59
61
|
|
60
62
|
@id = repl["id"]
|
61
|
-
@url = repl["url"]
|
63
|
+
@url = $BASE_URL + repl["url"]
|
62
64
|
@title = repl["title"]
|
63
65
|
@author = User.new(@client, repl["user"])
|
64
66
|
@description = repl["description"]
|
@@ -98,7 +100,7 @@ class Comment
|
|
98
100
|
@client = client
|
99
101
|
|
100
102
|
@id = comment["id"]
|
101
|
-
@url = comment["url"]
|
103
|
+
@url = $BASE_URL + comment["url"]
|
102
104
|
@author = comment["user"] == nil ? "[deleted user]" : User.new(@client, comment["user"])
|
103
105
|
@content = comment["body"]
|
104
106
|
@post_id = comment["post"]["id"]
|
@@ -134,7 +136,7 @@ class Post
|
|
134
136
|
@client = client
|
135
137
|
|
136
138
|
@id = post["id"]
|
137
|
-
@url = post["url"]
|
139
|
+
@url = $BASE_URL + post["url"]
|
138
140
|
@title = post["title"]
|
139
141
|
@content = post["body"]
|
140
142
|
@preview = post["preview"]
|
@@ -159,6 +161,18 @@ class Post
|
|
159
161
|
@is_announcement = post["isAnnouncement"]
|
160
162
|
end
|
161
163
|
|
164
|
+
def get_comments(order: "new", count: nil, after: nil)
|
165
|
+
c = @client.graphql(
|
166
|
+
"post",
|
167
|
+
Queries.get_posts_comments,
|
168
|
+
postId: @id,
|
169
|
+
order: order,
|
170
|
+
count: count,
|
171
|
+
after: after
|
172
|
+
)
|
173
|
+
c["post"]["comments"]["items"].map { |comment| Comment.new(@client, comment) }
|
174
|
+
end
|
175
|
+
|
162
176
|
def to_s
|
163
177
|
@title
|
164
178
|
end
|
@@ -234,11 +248,11 @@ class Client
|
|
234
248
|
"connect.sid": @sid
|
235
249
|
)
|
236
250
|
.headers(
|
237
|
-
referer: "
|
251
|
+
referer: "#{$BASE_URL}/@CodingCactus/repltalk",
|
238
252
|
"X-Requested-With": "ReplTalk"
|
239
253
|
)
|
240
254
|
.post(
|
241
|
-
"
|
255
|
+
"#{$BASE_URL}/graphql",
|
242
256
|
form: payload
|
243
257
|
)
|
244
258
|
begin data = JSON.parse(r)
|