repltalk 0.2.0 → 0.4.3
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 +155 -383
- data/lib/repltalk.rb +72 -18
- 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: 56aa983cc7fe53b0a33e5c75c7b60b2136630286f2c7f599dc8ce76ca8d40041
|
4
|
+
data.tar.gz: 893866d5aa136f6f429257bbc0b1f6aae8284d75154109f2a575fbd3e0e2e507
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f4a44b90f04b1a51fec9039b5c4d7098643870dbd7e2f755f0ce253f91e38b9cd03e1d37b346ee165bf942cedcae9a890d057afd1dc8200575af771fbe98587b
|
7
|
+
data.tar.gz: 727e37ffcbf3f09ac706c443b4c8aa219e250ff5cd8285b21a40737a76285a3c7fe0eb69094fe1adbadfb46d9403d67ea39e2e70921e2bb981c0cd2997345ed7
|
data/lib/queries.rb
CHANGED
@@ -1,423 +1,208 @@
|
|
1
1
|
class Queries
|
2
|
+
@@roles = "
|
3
|
+
id
|
4
|
+
name
|
5
|
+
key
|
6
|
+
tagline
|
7
|
+
"
|
8
|
+
|
9
|
+
@@organization = "
|
10
|
+
id
|
11
|
+
name
|
12
|
+
"
|
13
|
+
|
14
|
+
@@language = "
|
15
|
+
id
|
16
|
+
key
|
17
|
+
displayName
|
18
|
+
tagline
|
19
|
+
icon
|
20
|
+
"
|
21
|
+
|
22
|
+
@@board = "
|
23
|
+
id
|
24
|
+
name
|
25
|
+
color
|
26
|
+
"
|
27
|
+
|
28
|
+
@@user = "
|
29
|
+
id
|
30
|
+
fullName
|
31
|
+
username
|
32
|
+
image
|
33
|
+
bio
|
34
|
+
karma
|
35
|
+
isHacker
|
36
|
+
timeCreated
|
37
|
+
roles {
|
38
|
+
#{@@roles}
|
39
|
+
}
|
40
|
+
organization {
|
41
|
+
#{@@organization}
|
42
|
+
}
|
43
|
+
languages {
|
44
|
+
#{@@language}
|
45
|
+
}
|
46
|
+
"
|
47
|
+
|
48
|
+
@@repl = "
|
49
|
+
id
|
50
|
+
url
|
51
|
+
title
|
52
|
+
description
|
53
|
+
isPrivate
|
54
|
+
isAlwaysOn
|
55
|
+
lang {
|
56
|
+
#{@@language}
|
57
|
+
}
|
58
|
+
user {
|
59
|
+
#{@@user}
|
60
|
+
}
|
61
|
+
"
|
62
|
+
|
63
|
+
@@post = "
|
64
|
+
id
|
65
|
+
title
|
66
|
+
body
|
67
|
+
preview(removeMarkdown: true, length: 150)
|
68
|
+
url
|
69
|
+
commentCount
|
70
|
+
isHidden
|
71
|
+
isPinned
|
72
|
+
isLocked
|
73
|
+
isAnnouncement
|
74
|
+
timeCreated
|
75
|
+
isAnswered
|
76
|
+
isAnswerable
|
77
|
+
voteCount
|
78
|
+
canVote
|
79
|
+
hasVoted
|
80
|
+
user {
|
81
|
+
#{@@user}
|
82
|
+
}
|
83
|
+
repl {
|
84
|
+
#{@@repl}
|
85
|
+
}
|
86
|
+
board {
|
87
|
+
#{@@board}
|
88
|
+
}
|
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
|
105
|
+
}
|
106
|
+
"
|
107
|
+
|
108
|
+
|
2
109
|
def Queries.get_user
|
3
110
|
"query userByUsername($username: String!) {
|
4
111
|
user: userByUsername(username: $username) {
|
5
|
-
|
6
|
-
username
|
7
|
-
fullName
|
8
|
-
image
|
9
|
-
url
|
10
|
-
...ProfileHeaderUser
|
11
|
-
__typename
|
112
|
+
#{@@user}
|
12
113
|
}
|
13
|
-
}
|
14
|
-
|
15
|
-
fragment ProfileHeaderUser on User {
|
16
|
-
id
|
17
|
-
fullName
|
18
|
-
username
|
19
|
-
image
|
20
|
-
bio
|
21
|
-
karma
|
22
|
-
isHacker
|
23
|
-
roles {
|
24
|
-
id
|
25
|
-
name
|
26
|
-
key
|
27
|
-
tagline
|
28
|
-
__typename
|
29
|
-
}
|
30
|
-
organization {
|
31
|
-
id
|
32
|
-
name
|
33
|
-
__typename
|
34
|
-
}
|
35
|
-
languages {
|
36
|
-
id
|
37
|
-
key
|
38
|
-
displayName
|
39
|
-
tagline
|
40
|
-
icon
|
41
|
-
__typename
|
42
|
-
}
|
43
|
-
__typename
|
44
114
|
}"
|
45
115
|
end
|
46
116
|
|
47
117
|
def Queries.get_user_by_id
|
48
118
|
"query user($user_id: Int!) {
|
49
119
|
user: user(id: $user_id) {
|
50
|
-
|
51
|
-
username
|
52
|
-
fullName
|
53
|
-
image
|
54
|
-
url
|
55
|
-
...ProfileHeaderUser
|
56
|
-
__typename
|
57
|
-
}
|
58
|
-
}
|
59
|
-
|
60
|
-
fragment ProfileHeaderUser on User {
|
61
|
-
id
|
62
|
-
fullName
|
63
|
-
username
|
64
|
-
image
|
65
|
-
bio
|
66
|
-
karma
|
67
|
-
isHacker
|
68
|
-
roles {
|
69
|
-
id
|
70
|
-
name
|
71
|
-
key
|
72
|
-
tagline
|
73
|
-
__typename
|
120
|
+
#{@@user}
|
74
121
|
}
|
75
|
-
organization {
|
76
|
-
id
|
77
|
-
name
|
78
|
-
__typename
|
79
|
-
}
|
80
|
-
languages {
|
81
|
-
id
|
82
|
-
key
|
83
|
-
displayName
|
84
|
-
tagline
|
85
|
-
icon
|
86
|
-
__typename
|
87
|
-
}
|
88
|
-
__typename
|
89
122
|
}"
|
90
123
|
end
|
91
124
|
|
92
125
|
def Queries.get_user_posts
|
93
126
|
"query ProfilePosts($username: String!, $after: String, $order: String, $count: Int) {
|
94
127
|
user: userByUsername(username: $username) {
|
95
|
-
id
|
96
|
-
displayName
|
97
128
|
posts(after: $after, order: $order, count: $count) {
|
98
129
|
items {
|
99
|
-
|
100
|
-
isHidden
|
101
|
-
...PostsFeedItemPost
|
102
|
-
board {
|
103
|
-
id
|
104
|
-
name
|
105
|
-
url
|
106
|
-
color
|
107
|
-
__typename
|
108
|
-
}
|
109
|
-
__typename
|
110
|
-
}
|
111
|
-
pageInfo {
|
112
|
-
nextCursor
|
113
|
-
__typename
|
130
|
+
#{@@post}
|
114
131
|
}
|
115
|
-
__typename
|
116
|
-
}
|
117
|
-
__typename
|
118
|
-
}
|
119
|
-
}
|
120
|
-
|
121
|
-
fragment PostsFeedItemPost on Post {
|
122
|
-
id
|
123
|
-
title
|
124
|
-
body
|
125
|
-
preview(removeMarkdown: true, length: 150)
|
126
|
-
url
|
127
|
-
commentCount
|
128
|
-
isPinned
|
129
|
-
isLocked
|
130
|
-
isAnnouncement
|
131
|
-
timeCreated
|
132
|
-
isAnswered
|
133
|
-
isAnswerable
|
134
|
-
...PostVoteControlPost
|
135
|
-
...PostLinkPost
|
136
|
-
user {
|
137
|
-
id
|
138
|
-
username
|
139
|
-
isHacker
|
140
|
-
image
|
141
|
-
...UserLabelUser
|
142
|
-
...UserLinkUser
|
143
|
-
__typename
|
144
|
-
}
|
145
|
-
repl {
|
146
|
-
id
|
147
|
-
url
|
148
|
-
title
|
149
|
-
description
|
150
|
-
isPrivate
|
151
|
-
isAlwaysOn
|
152
|
-
lang {
|
153
|
-
id
|
154
|
-
icon
|
155
|
-
key
|
156
|
-
displayName
|
157
|
-
tagline
|
158
|
-
__typename
|
159
132
|
}
|
160
|
-
__typename
|
161
133
|
}
|
162
|
-
board {
|
163
|
-
id
|
164
|
-
name
|
165
|
-
color
|
166
|
-
__typename
|
167
|
-
}
|
168
|
-
}
|
169
|
-
|
170
|
-
fragment PostVoteControlPost on Post {
|
171
|
-
id
|
172
|
-
voteCount
|
173
|
-
canVote
|
174
|
-
hasVoted
|
175
|
-
__typename
|
176
|
-
}
|
177
|
-
|
178
|
-
fragment PostLinkPost on Post {
|
179
|
-
id
|
180
|
-
url
|
181
|
-
__typename
|
182
|
-
}
|
183
|
-
|
184
|
-
fragment UserLabelUser on User {
|
185
|
-
id
|
186
|
-
username
|
187
|
-
karma
|
188
|
-
...UserLinkUser
|
189
|
-
__typename
|
190
|
-
}
|
191
|
-
|
192
|
-
fragment UserLinkUser on User {
|
193
|
-
id
|
194
|
-
url
|
195
|
-
username
|
196
|
-
roles {
|
197
|
-
id
|
198
|
-
name
|
199
|
-
key
|
200
|
-
tagline
|
201
|
-
__typename
|
202
|
-
}
|
203
|
-
organization {
|
204
|
-
id
|
205
|
-
name
|
206
|
-
__typename
|
207
|
-
}
|
208
|
-
languages {
|
209
|
-
id
|
210
|
-
key
|
211
|
-
displayName
|
212
|
-
tagline
|
213
|
-
icon
|
214
|
-
__typename
|
215
|
-
}
|
216
|
-
__typename
|
217
134
|
}"
|
218
135
|
end
|
219
136
|
|
220
137
|
def Queries.get_user_comments
|
221
138
|
"query ProfileComments($username: String!, $after: String, $order: String, $count: Int) {
|
222
139
|
user: userByUsername(username: $username) {
|
223
|
-
id
|
224
|
-
displayName
|
225
140
|
comments(after: $after, order: $order, count: $count) {
|
226
141
|
items {
|
227
|
-
|
228
|
-
...ProfileCommentsComment
|
229
|
-
__typename
|
230
|
-
}
|
231
|
-
pageInfo {
|
232
|
-
nextCursor
|
233
|
-
__typename
|
142
|
+
#{@@comment}
|
234
143
|
}
|
235
|
-
__typename
|
236
144
|
}
|
237
|
-
__typename
|
238
145
|
}
|
239
|
-
}
|
240
|
-
|
241
|
-
fragment ProfileCommentsComment on Comment {
|
242
|
-
id
|
243
|
-
body
|
244
|
-
timeCreated
|
245
|
-
url
|
246
|
-
...CommentVoteControlComment
|
247
|
-
user {
|
248
|
-
id
|
249
|
-
fullName
|
250
|
-
username
|
251
|
-
image
|
252
|
-
bio
|
253
|
-
karma
|
254
|
-
isHacker
|
255
|
-
roles {
|
256
|
-
id
|
257
|
-
name
|
258
|
-
key
|
259
|
-
tagline
|
260
|
-
__typename
|
261
|
-
}
|
262
|
-
organization {
|
263
|
-
id
|
264
|
-
name
|
265
|
-
__typename
|
266
|
-
}
|
267
|
-
languages {
|
268
|
-
id
|
269
|
-
key
|
270
|
-
displayName
|
271
|
-
tagline
|
272
|
-
icon
|
273
|
-
__typename
|
274
|
-
}
|
275
|
-
}
|
276
|
-
post {
|
277
|
-
id
|
278
|
-
title
|
279
|
-
url
|
280
|
-
user {
|
281
|
-
id
|
282
|
-
username
|
283
|
-
url
|
284
|
-
__typename
|
285
|
-
}
|
286
|
-
board {
|
287
|
-
id
|
288
|
-
name
|
289
|
-
url
|
290
|
-
slug
|
291
|
-
__typename
|
292
|
-
}
|
293
|
-
__typename
|
294
|
-
}
|
295
|
-
__typename
|
296
|
-
}
|
297
|
-
|
298
|
-
fragment CommentVoteControlComment on Comment {
|
299
|
-
id
|
300
|
-
voteCount
|
301
|
-
canVote
|
302
|
-
hasVoted
|
303
|
-
__typename
|
304
146
|
}"
|
305
147
|
end
|
306
148
|
|
307
149
|
def Queries.get_post
|
308
150
|
"query post($id: Int!) {
|
309
151
|
post(id: $id) {
|
310
|
-
|
311
|
-
title
|
312
|
-
preview(removeMarkdown: true, length: 150)
|
313
|
-
body
|
314
|
-
isAnnouncement
|
315
|
-
url
|
316
|
-
isAnswerable
|
317
|
-
isHidden
|
318
|
-
answeredBy {
|
319
|
-
id
|
320
|
-
...PostAnsweredCardUser
|
321
|
-
__typename
|
322
|
-
}
|
323
|
-
answer {
|
324
|
-
id
|
325
|
-
...PostAnsweredCardComment
|
326
|
-
__typename
|
327
|
-
}
|
328
|
-
board {
|
329
|
-
id
|
330
|
-
url
|
331
|
-
description
|
332
|
-
slug
|
333
|
-
__typename
|
334
|
-
}
|
335
|
-
...PostDetailPost
|
336
|
-
__typename
|
152
|
+
#{@@post}
|
337
153
|
}
|
338
|
-
}
|
154
|
+
}"
|
155
|
+
end
|
339
156
|
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
isAnnouncement
|
348
|
-
isPinned
|
349
|
-
isLocked
|
350
|
-
isHidden
|
351
|
-
commentCount
|
352
|
-
isAnswered
|
353
|
-
isAnswerable
|
354
|
-
...PostVoteControlPost
|
355
|
-
user {
|
356
|
-
id
|
357
|
-
roles {
|
358
|
-
id
|
359
|
-
name
|
360
|
-
key
|
361
|
-
tagline
|
362
|
-
__typename
|
363
|
-
}
|
364
|
-
organization {
|
365
|
-
id
|
366
|
-
name
|
367
|
-
__typename
|
368
|
-
}
|
369
|
-
languages {
|
370
|
-
id
|
371
|
-
key
|
372
|
-
displayName
|
373
|
-
tagline
|
374
|
-
icon
|
375
|
-
__typename
|
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
|
+
}
|
376
164
|
}
|
377
|
-
...UserPostHeaderUser
|
378
|
-
__typename
|
379
165
|
}
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
166
|
+
}"
|
167
|
+
end
|
168
|
+
|
169
|
+
def Queries.get_comment
|
170
|
+
"query comment ($id: Int!) {
|
171
|
+
comment(id: $id) {
|
172
|
+
#{@@comment}
|
173
|
+
}
|
174
|
+
}"
|
175
|
+
end
|
176
|
+
|
177
|
+
def Queries.get_posts
|
178
|
+
"query PostsFeed($order: String, $after: String, $searchQuery: String, $languages: [String!], $count: Int, $boardSlugs: [String!], $pinAnnouncements: Boolean, $pinPinned: Boolean) {
|
179
|
+
posts(order: $order, after: $after, searchQuery: $searchQuery, languages: $languages, count: $count, boardSlugs: $boardSlugs, pinAnnouncements: $pinAnnouncements, pinPinned: $pinPinned) {
|
180
|
+
items {
|
181
|
+
#{@@post}
|
394
182
|
}
|
395
|
-
__typename
|
396
183
|
}
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
184
|
+
}"
|
185
|
+
end
|
186
|
+
|
187
|
+
def Queries.get_leaderboard
|
188
|
+
"query LeaderboardQuery($after: String, $since: KarmaSince) {
|
189
|
+
leaderboard(after: $after, since: $since) {
|
190
|
+
items {
|
191
|
+
}
|
402
192
|
}
|
403
|
-
__typename
|
404
193
|
}
|
405
194
|
|
406
|
-
fragment
|
195
|
+
fragment UserLabelWithImageUser on User {
|
407
196
|
id
|
408
|
-
|
409
|
-
|
410
|
-
hasVoted
|
197
|
+
image
|
198
|
+
...UserLabelUser
|
411
199
|
__typename
|
412
200
|
}
|
413
201
|
|
414
|
-
fragment
|
202
|
+
fragment UserLabelUser on User {
|
415
203
|
id
|
416
|
-
|
417
|
-
|
418
|
-
isModerator: hasRole(role: MODERATOR)
|
419
|
-
isAdmin: hasRole(role: ADMIN)
|
420
|
-
...DepreciatedUserLabelUser
|
204
|
+
username
|
205
|
+
karma
|
421
206
|
...UserLinkUser
|
422
207
|
__typename
|
423
208
|
}
|
@@ -429,25 +214,12 @@ class Queries
|
|
429
214
|
__typename
|
430
215
|
}
|
431
216
|
|
432
|
-
fragment
|
433
|
-
id
|
434
|
-
image
|
435
|
-
username
|
436
|
-
url
|
437
|
-
karma
|
438
|
-
__typename
|
439
|
-
}
|
440
|
-
|
441
|
-
fragment PostAnsweredCardUser on User {
|
217
|
+
fragment TopLeaderUser on User {
|
442
218
|
id
|
443
219
|
username
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
fragment PostAnsweredCardComment on Comment {
|
449
|
-
id
|
450
|
-
url
|
220
|
+
karmaSince: karma(since: $since)
|
221
|
+
...UserLabelWithImageUser
|
222
|
+
...UserLinkUser
|
451
223
|
__typename
|
452
224
|
}"
|
453
225
|
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
|
|
@@ -52,12 +54,15 @@ end
|
|
52
54
|
|
53
55
|
|
54
56
|
class Repl
|
55
|
-
attr_reader :id, :url, :title, :description, :language, :is_private, :is_always_on
|
57
|
+
attr_reader :id, :url, :title, :author, :description, :language, :is_private, :is_always_on
|
58
|
+
|
59
|
+
def initialize(client, repl)
|
60
|
+
@client = client
|
56
61
|
|
57
|
-
def initialize(repl)
|
58
62
|
@id = repl["id"]
|
59
|
-
@url = repl["url"]
|
63
|
+
@url = $BASE_URL + repl["url"]
|
60
64
|
@title = repl["title"]
|
65
|
+
@author = User.new(@client, repl["user"])
|
61
66
|
@description = repl["description"]
|
62
67
|
@language = Language.new(repl["lang"])
|
63
68
|
|
@@ -89,21 +94,34 @@ end
|
|
89
94
|
|
90
95
|
|
91
96
|
class Comment
|
92
|
-
attr_reader :id, :url, :author, :content, :vote_count, :can_vote, :has_voted
|
97
|
+
attr_reader :id, :url, :author, :content, :post_id, :is_answer, :vote_count, :timestamp, :comments, :can_vote, :has_voted
|
93
98
|
|
94
99
|
def initialize(client, comment)
|
95
100
|
@client = client
|
96
101
|
|
97
102
|
@id = comment["id"]
|
98
|
-
@url = comment["url"]
|
99
|
-
@author = User.new(@client, comment["user"])
|
103
|
+
@url = $BASE_URL + comment["url"]
|
104
|
+
@author = comment["user"] == nil ? "[deleted user]" : User.new(@client, comment["user"])
|
100
105
|
@content = comment["body"]
|
106
|
+
@post_id = comment["post"]["id"]
|
107
|
+
@is_answer = comment["isAnswer"]
|
101
108
|
@vote_count = comment["voteCount"]
|
109
|
+
@timestamp = comment["timeCreated"]
|
110
|
+
@comments = comment.include?("comments") ? comment["comments"].map { |c| Comment.new(@client, c)} : Array.new
|
102
111
|
|
103
112
|
@can_vote = comment["canVote"]
|
104
113
|
@has_voted = comment["hasVoted"]
|
105
114
|
end
|
106
115
|
|
116
|
+
def get_post
|
117
|
+
p = @client.graphql(
|
118
|
+
"post",
|
119
|
+
Queries.get_post,
|
120
|
+
id: @post_id
|
121
|
+
)
|
122
|
+
Post.new(self, p["post"])
|
123
|
+
end
|
124
|
+
|
107
125
|
def to_s
|
108
126
|
@content
|
109
127
|
end
|
@@ -118,15 +136,15 @@ class Post
|
|
118
136
|
@client = client
|
119
137
|
|
120
138
|
@id = post["id"]
|
121
|
-
@url = post["url"]
|
139
|
+
@url = $BASE_URL + post["url"]
|
122
140
|
@title = post["title"]
|
123
141
|
@content = post["body"]
|
124
142
|
@preview = post["preview"]
|
125
143
|
@timestamp = post["timeCreated"]
|
126
144
|
|
127
145
|
@board = Board.new(post["board"])
|
128
|
-
@
|
129
|
-
@
|
146
|
+
@repl = post["repl"] == nil ? nil : Repl.new(@client, post["repl"])
|
147
|
+
@author = post["user"] == nil ? "[deleted user]" : User.new(@client, post["user"])
|
130
148
|
|
131
149
|
@vote_count = post["voteCount"]
|
132
150
|
@comment_count = post["commentCount"]
|
@@ -143,6 +161,18 @@ class Post
|
|
143
161
|
@is_announcement = post["isAnnouncement"]
|
144
162
|
end
|
145
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
|
+
|
146
176
|
def to_s
|
147
177
|
@title
|
148
178
|
end
|
@@ -151,7 +181,7 @@ end
|
|
151
181
|
|
152
182
|
|
153
183
|
class User
|
154
|
-
attr_reader :id, :username, :name, :pfp, :bio, :cycles, :is_hacker, :roles, :organization, :languages
|
184
|
+
attr_reader :id, :username, :name, :pfp, :bio, :cycles, :is_hacker, :timestamp, :roles, :organization, :languages
|
155
185
|
|
156
186
|
def initialize(client, user)
|
157
187
|
@client = client
|
@@ -163,6 +193,7 @@ class User
|
|
163
193
|
@bio = user["bio"]
|
164
194
|
@cycles = user["karma"]
|
165
195
|
@is_hacker = user["isHacker"]
|
196
|
+
@timestamp = user["timeCreated"]
|
166
197
|
@roles = user["roles"].map { |role| Role.new(role) }
|
167
198
|
@organization = user["organization"] == nil ? nil : Organization.new(user["organization"])
|
168
199
|
@languages = user["languages"].map { |lang| Language.new(lang) }
|
@@ -177,9 +208,7 @@ class User
|
|
177
208
|
count: count,
|
178
209
|
after: after
|
179
210
|
)
|
180
|
-
posts
|
181
|
-
p["user"]["posts"]["items"].each { |post| posts << Post.new(@client, post) }
|
182
|
-
posts
|
211
|
+
p["user"]["posts"]["items"].map { |post| Post.new(@client, post) }
|
183
212
|
end
|
184
213
|
|
185
214
|
def get_comments(order: "new", count: nil, after: nil)
|
@@ -191,9 +220,7 @@ class User
|
|
191
220
|
count: count,
|
192
221
|
after: after
|
193
222
|
)
|
194
|
-
comments
|
195
|
-
c["user"]["comments"]["items"].each { |comment| comments << Comment.new(@client, comment) }
|
196
|
-
comments
|
223
|
+
c["user"]["comments"]["items"].map { |comment| Comment.new(@client, comment) }
|
197
224
|
end
|
198
225
|
|
199
226
|
def to_s
|
@@ -221,11 +248,11 @@ class Client
|
|
221
248
|
"connect.sid": @sid
|
222
249
|
)
|
223
250
|
.headers(
|
224
|
-
referer: "
|
251
|
+
referer: "#{$BASE_URL}/@CodingCactus/repltalk",
|
225
252
|
"X-Requested-With": "ReplTalk"
|
226
253
|
)
|
227
254
|
.post(
|
228
|
-
"
|
255
|
+
"#{$BASE_URL}/graphql",
|
229
256
|
form: payload
|
230
257
|
)
|
231
258
|
begin data = JSON.parse(r)
|
@@ -233,6 +260,10 @@ class Client
|
|
233
260
|
puts "\e[31mERROR\n#{r}\e[0m"
|
234
261
|
return nil
|
235
262
|
end
|
263
|
+
if data.include?("errors")
|
264
|
+
puts "\e[31mERROR\n#{r}\e[0m"
|
265
|
+
return nil
|
266
|
+
end
|
236
267
|
data = data["data"] if data.include?("data")
|
237
268
|
data
|
238
269
|
end
|
@@ -263,4 +294,27 @@ class Client
|
|
263
294
|
)
|
264
295
|
Post.new(self, p["post"])
|
265
296
|
end
|
297
|
+
|
298
|
+
def get_comment(id)
|
299
|
+
c = graphql(
|
300
|
+
"comment",
|
301
|
+
Queries.get_comment,
|
302
|
+
id: id
|
303
|
+
)
|
304
|
+
Comment.new(self, c["comment"])
|
305
|
+
end
|
306
|
+
|
307
|
+
def get_posts(board: "all", order: "new", count: nil, after: nil, search: nil, languages: nil)
|
308
|
+
p = graphql(
|
309
|
+
"PostsFeed",
|
310
|
+
Queries.get_posts,
|
311
|
+
baordSlugs: [board],
|
312
|
+
order: order,
|
313
|
+
count: count,
|
314
|
+
after: after,
|
315
|
+
searchQuery: search,
|
316
|
+
languages: languages
|
317
|
+
)
|
318
|
+
p["posts"]["items"].map { |post| Post.new(self, post) }
|
319
|
+
end
|
266
320
|
end
|
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: 0.4.3
|
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-06 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:
|