repltalk 0.4.1 → 1.0.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/lib/queries.rb +165 -18
- data/lib/repltalk.rb +175 -16
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 32b5dc0fff67f57f37db1a77079dc65ebb3c16321e12f8b894e37c50ae1efc96
|
4
|
+
data.tar.gz: fec0faaa7eede228e816c570d27e27d3beb74a35d74333e123ac724cece8bf43
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b09dc1d9d86ce9f596f3efce8a4bf613fdaf1704faaa9c9c0bc8b4a9c20f3a1d0ce6fa97a35e50345d94a930153c0bd01fc37e7cae19189b1c29c2b262169205
|
7
|
+
data.tar.gz: 4337fc27b260cf4f4a0ef545e105af092aa77d84740a12044bdda57a4a935641065a3fe159555aad1009ed5d681634245b9d233098b15c5d13294125da10391b
|
data/lib/queries.rb
CHANGED
@@ -9,6 +9,18 @@ class Queries
|
|
9
9
|
@@organization = "
|
10
10
|
id
|
11
11
|
name
|
12
|
+
country
|
13
|
+
postalCode
|
14
|
+
state
|
15
|
+
city
|
16
|
+
timeCreated
|
17
|
+
"
|
18
|
+
|
19
|
+
@@subscription = "
|
20
|
+
id
|
21
|
+
planId
|
22
|
+
quantity
|
23
|
+
timeCreated
|
12
24
|
"
|
13
25
|
|
14
26
|
@@language = "
|
@@ -17,12 +29,14 @@ class Queries
|
|
17
29
|
displayName
|
18
30
|
tagline
|
19
31
|
icon
|
32
|
+
category
|
20
33
|
"
|
21
34
|
|
22
35
|
@@board = "
|
23
36
|
id
|
24
37
|
name
|
25
38
|
color
|
39
|
+
description
|
26
40
|
"
|
27
41
|
|
28
42
|
@@user = "
|
@@ -40,6 +54,9 @@ class Queries
|
|
40
54
|
organization {
|
41
55
|
#{@@organization}
|
42
56
|
}
|
57
|
+
subscription {
|
58
|
+
#{@@subscription}
|
59
|
+
}
|
43
60
|
languages {
|
44
61
|
#{@@language}
|
45
62
|
}
|
@@ -50,6 +67,8 @@ class Queries
|
|
50
67
|
url
|
51
68
|
title
|
52
69
|
description
|
70
|
+
size
|
71
|
+
imageUrl
|
53
72
|
isPrivate
|
54
73
|
isAlwaysOn
|
55
74
|
lang {
|
@@ -58,6 +77,38 @@ class Queries
|
|
58
77
|
user {
|
59
78
|
#{@@user}
|
60
79
|
}
|
80
|
+
origin {
|
81
|
+
url
|
82
|
+
}
|
83
|
+
"
|
84
|
+
|
85
|
+
@@comment = "
|
86
|
+
id
|
87
|
+
body
|
88
|
+
timeCreated
|
89
|
+
url
|
90
|
+
isAnswer
|
91
|
+
voteCount
|
92
|
+
canVote
|
93
|
+
hasVoted
|
94
|
+
user {
|
95
|
+
#{@@user}
|
96
|
+
}
|
97
|
+
post {
|
98
|
+
id
|
99
|
+
}
|
100
|
+
"
|
101
|
+
|
102
|
+
@@repl_comment = "
|
103
|
+
id
|
104
|
+
body
|
105
|
+
timeCreated
|
106
|
+
user {
|
107
|
+
#{@@user}
|
108
|
+
}
|
109
|
+
repl {
|
110
|
+
#{@@repl}
|
111
|
+
}
|
61
112
|
"
|
62
113
|
|
63
114
|
@@post = "
|
@@ -86,22 +137,8 @@ class Queries
|
|
86
137
|
board {
|
87
138
|
#{@@board}
|
88
139
|
}
|
89
|
-
|
90
|
-
|
91
|
-
@@comment = "
|
92
|
-
id
|
93
|
-
body
|
94
|
-
timeCreated
|
95
|
-
url
|
96
|
-
isAnswer
|
97
|
-
voteCount
|
98
|
-
canVote
|
99
|
-
hasVoted
|
100
|
-
user {
|
101
|
-
#{@@user}
|
102
|
-
}
|
103
|
-
post {
|
104
|
-
id
|
140
|
+
answer {
|
141
|
+
#{@@comment}
|
105
142
|
}
|
106
143
|
"
|
107
144
|
|
@@ -123,7 +160,7 @@ class Queries
|
|
123
160
|
end
|
124
161
|
|
125
162
|
def Queries.get_user_posts
|
126
|
-
"query
|
163
|
+
"query user($username: String!, $after: String, $order: String, $count: Int) {
|
127
164
|
user: userByUsername(username: $username) {
|
128
165
|
posts(after: $after, order: $order, count: $count) {
|
129
166
|
items {
|
@@ -135,7 +172,7 @@ class Queries
|
|
135
172
|
end
|
136
173
|
|
137
174
|
def Queries.get_user_comments
|
138
|
-
"query
|
175
|
+
"query user($username: String!, $after: String, $order: String, $count: Int) {
|
139
176
|
user: userByUsername(username: $username) {
|
140
177
|
comments(after: $after, order: $order, count: $count) {
|
141
178
|
items {
|
@@ -146,6 +183,18 @@ class Queries
|
|
146
183
|
}"
|
147
184
|
end
|
148
185
|
|
186
|
+
def Queries.get_user_repls
|
187
|
+
"query user($username: String!, $count: Int, $order: String, $direction: String, $before: String, $after: String, $pinnedReplsFirst: Boolean, $showUnnamed: Boolean) {
|
188
|
+
user: userByUsername(username: $username) {
|
189
|
+
publicRepls(count: $count, order: $order, direction: $direction, before: $before, after: $after, pinnedReplsFirst: $pinnedReplsFirst, showUnnamed: $showUnnamed) {
|
190
|
+
items {
|
191
|
+
#{@@repl}
|
192
|
+
}
|
193
|
+
}
|
194
|
+
}
|
195
|
+
}"
|
196
|
+
end
|
197
|
+
|
149
198
|
def Queries.get_post
|
150
199
|
"query post($id: Int!) {
|
151
200
|
post(id: $id) {
|
@@ -154,6 +203,32 @@ class Queries
|
|
154
203
|
}"
|
155
204
|
end
|
156
205
|
|
206
|
+
def Queries.get_posts_comments
|
207
|
+
"query post($postId: Int!, $order: String, $count: Int, $after: String) {
|
208
|
+
post(id: $postId) {
|
209
|
+
comments(order: $order, count: $count, after: $after) {
|
210
|
+
items {
|
211
|
+
#{@@comment}
|
212
|
+
}
|
213
|
+
}
|
214
|
+
}
|
215
|
+
}"
|
216
|
+
end
|
217
|
+
|
218
|
+
def Queries.get_posts_upvoters
|
219
|
+
"query post($id: Int!, $count: Int) {
|
220
|
+
post(id: $id) {
|
221
|
+
votes(count: $count) {
|
222
|
+
items {
|
223
|
+
user {
|
224
|
+
#{@@user}
|
225
|
+
}
|
226
|
+
}
|
227
|
+
}
|
228
|
+
}
|
229
|
+
}"
|
230
|
+
end
|
231
|
+
|
157
232
|
def Queries.get_comment
|
158
233
|
"query comment ($id: Int!) {
|
159
234
|
comment(id: $id) {
|
@@ -162,6 +237,67 @@ class Queries
|
|
162
237
|
}"
|
163
238
|
end
|
164
239
|
|
240
|
+
def Queries.get_comments_comments
|
241
|
+
"query comment ($id: Int!) {
|
242
|
+
comment(id: $id) {
|
243
|
+
comments {
|
244
|
+
#{@@comment}
|
245
|
+
}
|
246
|
+
}
|
247
|
+
}"
|
248
|
+
end
|
249
|
+
|
250
|
+
def Queries.get_parent_comment
|
251
|
+
"query comment ($id: Int!) {
|
252
|
+
comment(id: $id) {
|
253
|
+
parentComment {
|
254
|
+
#{@@comment}
|
255
|
+
}
|
256
|
+
}
|
257
|
+
}"
|
258
|
+
end
|
259
|
+
|
260
|
+
def Queries.get_repl
|
261
|
+
"query ReplView($url: String!) {
|
262
|
+
repl(url: $url) {
|
263
|
+
... on Repl {
|
264
|
+
#{@@repl}
|
265
|
+
}
|
266
|
+
}
|
267
|
+
}"
|
268
|
+
end
|
269
|
+
|
270
|
+
def Queries.get_repl_forks
|
271
|
+
"query ReplViewForks($url: String!, $count: Int!, $after: String) {
|
272
|
+
repl(url: $url) {
|
273
|
+
... on Repl {
|
274
|
+
publicForks(count: $count, after: $after) {
|
275
|
+
items {
|
276
|
+
#{@@repl}
|
277
|
+
}
|
278
|
+
}
|
279
|
+
}
|
280
|
+
}
|
281
|
+
}"
|
282
|
+
end
|
283
|
+
|
284
|
+
def Queries.get_repl_comments
|
285
|
+
"query ReplViewComments($url: String!, $count: Int, $after: String) {
|
286
|
+
repl(url: $url) {
|
287
|
+
... on Repl {
|
288
|
+
comments(count: $count, after: $after) {
|
289
|
+
items {
|
290
|
+
#{@@repl_comment}
|
291
|
+
replies {
|
292
|
+
#{@@repl_comment}
|
293
|
+
}
|
294
|
+
}
|
295
|
+
}
|
296
|
+
}
|
297
|
+
}
|
298
|
+
}"
|
299
|
+
end
|
300
|
+
|
165
301
|
def Queries.get_posts
|
166
302
|
"query PostsFeed($order: String, $after: String, $searchQuery: String, $languages: [String!], $count: Int, $boardSlugs: [String!], $pinAnnouncements: Boolean, $pinPinned: Boolean) {
|
167
303
|
posts(order: $order, after: $after, searchQuery: $searchQuery, languages: $languages, count: $count, boardSlugs: $boardSlugs, pinAnnouncements: $pinAnnouncements, pinPinned: $pinPinned) {
|
@@ -171,4 +307,15 @@ class Queries
|
|
171
307
|
}
|
172
308
|
}"
|
173
309
|
end
|
310
|
+
|
311
|
+
def Queries.get_leaderboard
|
312
|
+
"query LeaderboardQuery($count: Int, $after: String, $since: KarmaSince) {
|
313
|
+
leaderboard(count: $count, after: $after, since: $since) {
|
314
|
+
items {
|
315
|
+
#{@@user}
|
316
|
+
karmaSince: karma(since: $since)
|
317
|
+
}
|
318
|
+
}
|
319
|
+
}"
|
320
|
+
end
|
174
321
|
end
|
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
|
|
@@ -19,11 +21,16 @@ end
|
|
19
21
|
|
20
22
|
|
21
23
|
class Organization
|
22
|
-
attr_reader :id, :name
|
24
|
+
attr_reader :id, :name, :country, :postal_code, :state, :city, :timestamp
|
23
25
|
|
24
26
|
def initialize(organization)
|
25
27
|
@id = organization["id"]
|
26
28
|
@name = organization["name"]
|
29
|
+
@country = organization["country"]
|
30
|
+
@postal_code = organization["postalCode"]
|
31
|
+
@state = organization["state"]
|
32
|
+
@city = organization["city"]
|
33
|
+
@timestamp = organization["timeCreated"]
|
27
34
|
end
|
28
35
|
|
29
36
|
def to_s
|
@@ -33,8 +40,25 @@ end
|
|
33
40
|
|
34
41
|
|
35
42
|
|
43
|
+
class Subscription
|
44
|
+
attr_reader :id, :plan_id, :quantity, :timestamp
|
45
|
+
|
46
|
+
def initialize(subscription)
|
47
|
+
@id = subscription["id"]
|
48
|
+
@plan_id = subscription["planId"]
|
49
|
+
@quantity = subscription["quantity"]
|
50
|
+
@timestamp = subscription["timeCreated"]
|
51
|
+
end
|
52
|
+
|
53
|
+
def to_s
|
54
|
+
@plan_id
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
|
36
60
|
class Language
|
37
|
-
attr_reader :id, :key, :name, :tagline, :icon
|
61
|
+
attr_reader :id, :key, :name, :tagline, :icon, :category
|
38
62
|
|
39
63
|
def initialize(lang)
|
40
64
|
@id = lang["id"]
|
@@ -42,6 +66,7 @@ class Language
|
|
42
66
|
@name = lang["displayName"]
|
43
67
|
@tagline = lang["tagline"]
|
44
68
|
@icon = lang["icon"]
|
69
|
+
@category = lang["category"]
|
45
70
|
end
|
46
71
|
|
47
72
|
def to_s
|
@@ -51,23 +76,68 @@ end
|
|
51
76
|
|
52
77
|
|
53
78
|
|
79
|
+
class ReplComment
|
80
|
+
attr_reader :id, :content, :author, :repl, :replies
|
81
|
+
|
82
|
+
def initialize(client, comment)
|
83
|
+
@client = client
|
84
|
+
|
85
|
+
@id = comment["id"]
|
86
|
+
@content = comment["body"]
|
87
|
+
@author = comment["user"] == nil ? "[deleted user]" : User.new(@client, comment["user"])
|
88
|
+
@repl = Repl.new(@client, comment["repl"])
|
89
|
+
@replies = comment["replies"] == nil ? nil : comment["replies"].map { |c| ReplComment.new(@client, c) }
|
90
|
+
end
|
91
|
+
|
92
|
+
def to_s
|
93
|
+
@content
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
|
98
|
+
|
54
99
|
class Repl
|
55
|
-
attr_reader :id, :url, :title, :author, :description, :language, :is_private, :is_always_on
|
100
|
+
attr_reader :id, :url, :title, :author, :description, :size, :language, :img_url, :origin_url, :is_private, :is_always_on
|
56
101
|
|
57
102
|
def initialize(client, repl)
|
58
103
|
@client = client
|
59
104
|
|
60
105
|
@id = repl["id"]
|
61
|
-
@url = repl["url"]
|
106
|
+
@url = $BASE_URL + repl["url"]
|
62
107
|
@title = repl["title"]
|
63
108
|
@author = User.new(@client, repl["user"])
|
64
109
|
@description = repl["description"]
|
110
|
+
@size = repl["size"]
|
65
111
|
@language = Language.new(repl["lang"])
|
112
|
+
@image_url = repl["imageUrl"]
|
113
|
+
@origin_url = repl["origin"] == nil ? nil : $BASE_URL + repl["origin"]["url"]
|
66
114
|
|
67
115
|
@is_private = repl["isPrivate"]
|
68
116
|
@is_always_on = repl["isAlwaysOn"]
|
69
117
|
end
|
70
118
|
|
119
|
+
def get_forks(count: 100, after: nil)
|
120
|
+
f = @client.graphql(
|
121
|
+
"ReplViewForks",
|
122
|
+
Queries.get_repl_forks,
|
123
|
+
url: @url,
|
124
|
+
count: count,
|
125
|
+
after: after
|
126
|
+
)
|
127
|
+
f["repl"]["publicForks"]["items"].map { |repl| Repl.new(@client, repl) }
|
128
|
+
end
|
129
|
+
|
130
|
+
def get_comments(count: nil, after: nil)
|
131
|
+
c = @client.graphql(
|
132
|
+
"ReplViewComments",
|
133
|
+
Queries.get_repl_comments,
|
134
|
+
url: @url,
|
135
|
+
count: count,
|
136
|
+
after: after
|
137
|
+
)
|
138
|
+
c["repl"]["comments"]["items"].map { |comment| ReplComment.new(@client, comment) }
|
139
|
+
end
|
140
|
+
|
71
141
|
def to_s
|
72
142
|
@title
|
73
143
|
end
|
@@ -76,12 +146,13 @@ end
|
|
76
146
|
|
77
147
|
|
78
148
|
class Board
|
79
|
-
attr_reader :id, :name, :color
|
149
|
+
attr_reader :id, :name, :color, :description
|
80
150
|
|
81
151
|
def initialize(board)
|
82
152
|
@id = board["id"]
|
83
153
|
@name = board["name"]
|
84
154
|
@color = board["color"]
|
155
|
+
@description = board["description"]
|
85
156
|
end
|
86
157
|
|
87
158
|
def to_s
|
@@ -92,20 +163,19 @@ end
|
|
92
163
|
|
93
164
|
|
94
165
|
class Comment
|
95
|
-
attr_reader :id, :url, :author, :content, :post_id, :is_answer, :vote_count, :timestamp, :
|
166
|
+
attr_reader :id, :url, :author, :content, :post_id, :is_answer, :vote_count, :timestamp, :can_vote, :has_voted
|
96
167
|
|
97
168
|
def initialize(client, comment)
|
98
169
|
@client = client
|
99
170
|
|
100
171
|
@id = comment["id"]
|
101
|
-
@url = comment["url"]
|
172
|
+
@url = $BASE_URL + comment["url"]
|
102
173
|
@author = comment["user"] == nil ? "[deleted user]" : User.new(@client, comment["user"])
|
103
174
|
@content = comment["body"]
|
104
175
|
@post_id = comment["post"]["id"]
|
105
176
|
@is_answer = comment["isAnswer"]
|
106
177
|
@vote_count = comment["voteCount"]
|
107
178
|
@timestamp = comment["timeCreated"]
|
108
|
-
@comments = comment.include?("comments") ? comment["comments"].map { |c| Comment.new(@client, c)} : Array.new
|
109
179
|
|
110
180
|
@can_vote = comment["canVote"]
|
111
181
|
@has_voted = comment["hasVoted"]
|
@@ -117,7 +187,25 @@ class Comment
|
|
117
187
|
Queries.get_post,
|
118
188
|
id: @post_id
|
119
189
|
)
|
120
|
-
Post.new(
|
190
|
+
Post.new(@client, p["post"])
|
191
|
+
end
|
192
|
+
|
193
|
+
def get_comments
|
194
|
+
c = @client.graphql(
|
195
|
+
"comment",
|
196
|
+
Queries.get_comments_comments,
|
197
|
+
id: @id
|
198
|
+
)
|
199
|
+
c["comment"]["comments"].map { |comment| Comment.new(@client, comment) }
|
200
|
+
end
|
201
|
+
|
202
|
+
def get_parent
|
203
|
+
c = @client.graphql(
|
204
|
+
"comment",
|
205
|
+
Queries.get_parent_comment,
|
206
|
+
id: @id
|
207
|
+
)
|
208
|
+
c["comment"]["parentComment"] == nil ? nil : Comment.new(@client, c["comment"]["parentComment"])
|
121
209
|
end
|
122
210
|
|
123
211
|
def to_s
|
@@ -128,13 +216,13 @@ end
|
|
128
216
|
|
129
217
|
|
130
218
|
class Post
|
131
|
-
attr_reader :id, :url, :repl, :board, :title, :author, :content, :preview, :timestamp, :vote_count, :comment_count, :can_vote, :has_voted, :is_answered, :is_answerable, :is_hidden, :is_pinned, :is_locked, :is_announcement
|
219
|
+
attr_reader :id, :url, :repl, :board, :title, :author, :answer, :content, :preview, :timestamp, :vote_count, :comment_count, :can_vote, :has_voted, :is_answered, :is_answerable, :is_hidden, :is_pinned, :is_locked, :is_announcement
|
132
220
|
|
133
221
|
def initialize(client, post)
|
134
222
|
@client = client
|
135
223
|
|
136
224
|
@id = post["id"]
|
137
|
-
@url = post["url"]
|
225
|
+
@url = $BASE_URL + post["url"]
|
138
226
|
@title = post["title"]
|
139
227
|
@content = post["body"]
|
140
228
|
@preview = post["preview"]
|
@@ -143,6 +231,7 @@ class Post
|
|
143
231
|
@board = Board.new(post["board"])
|
144
232
|
@repl = post["repl"] == nil ? nil : Repl.new(@client, post["repl"])
|
145
233
|
@author = post["user"] == nil ? "[deleted user]" : User.new(@client, post["user"])
|
234
|
+
@answer = post["answer"] == nil ? nil : Comment.new(@client, post["answer"])
|
146
235
|
|
147
236
|
@vote_count = post["voteCount"]
|
148
237
|
@comment_count = post["commentCount"]
|
@@ -159,6 +248,28 @@ class Post
|
|
159
248
|
@is_announcement = post["isAnnouncement"]
|
160
249
|
end
|
161
250
|
|
251
|
+
def get_comments(order: "new", count: nil, after: nil)
|
252
|
+
c = @client.graphql(
|
253
|
+
"post",
|
254
|
+
Queries.get_posts_comments,
|
255
|
+
postId: @id,
|
256
|
+
order: order,
|
257
|
+
count: count,
|
258
|
+
after: after
|
259
|
+
)
|
260
|
+
c["post"]["comments"]["items"].map { |comment| Comment.new(@client, comment) }
|
261
|
+
end
|
262
|
+
|
263
|
+
def get_upvotes(count: nil)
|
264
|
+
u = @client.graphql(
|
265
|
+
"post",
|
266
|
+
Queries.get_posts_upvoters,
|
267
|
+
id: @id,
|
268
|
+
count: count
|
269
|
+
)
|
270
|
+
u["post"]["votes"]["items"].map { |vote| User.new(@client, vote["user"]) }
|
271
|
+
end
|
272
|
+
|
162
273
|
def to_s
|
163
274
|
@title
|
164
275
|
end
|
@@ -167,7 +278,7 @@ end
|
|
167
278
|
|
168
279
|
|
169
280
|
class User
|
170
|
-
attr_reader :id, :username, :name, :pfp, :bio, :cycles, :is_hacker, :timestamp, :roles, :organization, :languages
|
281
|
+
attr_reader :id, :username, :name, :pfp, :bio, :cycles, :is_hacker, :timestamp, :subscription, :roles, :organization, :languages
|
171
282
|
|
172
283
|
def initialize(client, user)
|
173
284
|
@client = client
|
@@ -180,6 +291,7 @@ class User
|
|
180
291
|
@cycles = user["karma"]
|
181
292
|
@is_hacker = user["isHacker"]
|
182
293
|
@timestamp = user["timeCreated"]
|
294
|
+
@subscription = user["subscription"] == nil ? nil : Subscription.new(user["subscription"])
|
183
295
|
@roles = user["roles"].map { |role| Role.new(role) }
|
184
296
|
@organization = user["organization"] == nil ? nil : Organization.new(user["organization"])
|
185
297
|
@languages = user["languages"].map { |lang| Language.new(lang) }
|
@@ -187,7 +299,7 @@ class User
|
|
187
299
|
|
188
300
|
def get_posts(order: "new", count: nil, after: nil)
|
189
301
|
p = @client.graphql(
|
190
|
-
"
|
302
|
+
"user",
|
191
303
|
Queries.get_user_posts,
|
192
304
|
username: @username,
|
193
305
|
order: order,
|
@@ -199,7 +311,7 @@ class User
|
|
199
311
|
|
200
312
|
def get_comments(order: "new", count: nil, after: nil)
|
201
313
|
c = @client.graphql(
|
202
|
-
"
|
314
|
+
"user",
|
203
315
|
Queries.get_user_comments,
|
204
316
|
username: @username,
|
205
317
|
order: order,
|
@@ -209,6 +321,22 @@ class User
|
|
209
321
|
c["user"]["comments"]["items"].map { |comment| Comment.new(@client, comment) }
|
210
322
|
end
|
211
323
|
|
324
|
+
def get_repls(count: nil, order: nil, direction: nil, before: nil, after: nil, pinnedReplsFirst: nil, showUnnamed: nil)
|
325
|
+
r = @client.graphql(
|
326
|
+
"user",
|
327
|
+
Queries.get_user_repls,
|
328
|
+
username: @username,
|
329
|
+
order: order,
|
330
|
+
count: count,
|
331
|
+
direction: direction,
|
332
|
+
before: before,
|
333
|
+
after: after,
|
334
|
+
pinnedReplsFirst: pinnedReplsFirst,
|
335
|
+
showUnnamed: showUnnamed
|
336
|
+
)
|
337
|
+
r["user"]["publicRepls"]["items"].map { |repl| Repl.new(@client, repl) }
|
338
|
+
end
|
339
|
+
|
212
340
|
def to_s
|
213
341
|
@username
|
214
342
|
end
|
@@ -216,6 +344,17 @@ end
|
|
216
344
|
|
217
345
|
|
218
346
|
|
347
|
+
class LeaderboardUser < User
|
348
|
+
attr_reader :cycles_since
|
349
|
+
|
350
|
+
def initialize(client, user)
|
351
|
+
super(client, user)
|
352
|
+
@cycles_since = user["karmaSince"]
|
353
|
+
end
|
354
|
+
end
|
355
|
+
|
356
|
+
|
357
|
+
|
219
358
|
class Client
|
220
359
|
attr_writer :sid
|
221
360
|
|
@@ -234,11 +373,11 @@ class Client
|
|
234
373
|
"connect.sid": @sid
|
235
374
|
)
|
236
375
|
.headers(
|
237
|
-
referer: "
|
376
|
+
referer: "#{$BASE_URL}/@CodingCactus/repltalk",
|
238
377
|
"X-Requested-With": "ReplTalk"
|
239
378
|
)
|
240
379
|
.post(
|
241
|
-
"
|
380
|
+
"#{$BASE_URL}/graphql",
|
242
381
|
form: payload
|
243
382
|
)
|
244
383
|
begin data = JSON.parse(r)
|
@@ -289,6 +428,26 @@ class Client
|
|
289
428
|
)
|
290
429
|
Comment.new(self, c["comment"])
|
291
430
|
end
|
431
|
+
|
432
|
+
def get_repl(url)
|
433
|
+
r = graphql(
|
434
|
+
"ReplView",
|
435
|
+
Queries.get_repl,
|
436
|
+
url: url
|
437
|
+
)
|
438
|
+
Repl.new(self, r["repl"])
|
439
|
+
end
|
440
|
+
|
441
|
+
def get_leaderboard(count: nil, since: nil, after: nil)
|
442
|
+
u = graphql(
|
443
|
+
"LeaderboardQuery",
|
444
|
+
Queries.get_leaderboard,
|
445
|
+
count: count,
|
446
|
+
since: since,
|
447
|
+
after: after
|
448
|
+
)
|
449
|
+
u["leaderboard"]["items"].map { |user| LeaderboardUser.new(self, user) }
|
450
|
+
end
|
292
451
|
|
293
452
|
def get_posts(board: "all", order: "new", count: nil, after: nil, search: nil, languages: nil)
|
294
453
|
p = graphql(
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: repltalk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- CodingCactus
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-03-
|
11
|
+
date: 2021-03-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: http
|
@@ -48,7 +48,8 @@ files:
|
|
48
48
|
- lib/queries.rb
|
49
49
|
- lib/repltalk.rb
|
50
50
|
homepage:
|
51
|
-
licenses:
|
51
|
+
licenses:
|
52
|
+
- MIT
|
52
53
|
metadata:
|
53
54
|
source_code_uri: https://github.com/Coding-Cactus/repltalk
|
54
55
|
post_install_message:
|