repltalk 0.4.3 → 1.1.0
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 +165 -49
- data/lib/repltalk.rb +180 -11
- metadata +19 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f298413413c3c3b6cf63fabc23de37dd86117011d8980b533b5d381769ed5fbd
|
4
|
+
data.tar.gz: 0a9bdac51d43d47c639f4c8eb64d7e40951de9302cb805b7a5bf40d4504dd38b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db03ee9bc966d0b3af618b14d2075b3b5037cc6698dac4587c1fa3a8f55c098e1bee72ca09665f0eea3f7475db3fd8fc8cde96981a9a854e11c45f8820df1ffc
|
7
|
+
data.tar.gz: 2213d3a581ccc4144ac4359835b36ee2b62e3b0f900aa55863fd28ec1e4ded0f097d15588af9968038ea49080904217dbd1556e92f8cb281c21dfb4828f9798a
|
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) {
|
@@ -166,6 +215,20 @@ class Queries
|
|
166
215
|
}"
|
167
216
|
end
|
168
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
|
+
|
169
232
|
def Queries.get_comment
|
170
233
|
"query comment ($id: Int!) {
|
171
234
|
comment(id: $id) {
|
@@ -174,6 +237,75 @@ class Queries
|
|
174
237
|
}"
|
175
238
|
end
|
176
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
|
+
|
301
|
+
def Queries.get_board
|
302
|
+
"query boardBySlug($slug: String!) {
|
303
|
+
board: boardBySlug(slug: $slug) {
|
304
|
+
#{@@board}
|
305
|
+
}
|
306
|
+
}"
|
307
|
+
end
|
308
|
+
|
177
309
|
def Queries.get_posts
|
178
310
|
"query PostsFeed($order: String, $after: String, $searchQuery: String, $languages: [String!], $count: Int, $boardSlugs: [String!], $pinAnnouncements: Boolean, $pinPinned: Boolean) {
|
179
311
|
posts(order: $order, after: $after, searchQuery: $searchQuery, languages: $languages, count: $count, boardSlugs: $boardSlugs, pinAnnouncements: $pinAnnouncements, pinPinned: $pinPinned) {
|
@@ -185,42 +317,26 @@ class Queries
|
|
185
317
|
end
|
186
318
|
|
187
319
|
def Queries.get_leaderboard
|
188
|
-
"query LeaderboardQuery($after: String, $since: KarmaSince) {
|
189
|
-
leaderboard(after: $after, since: $since) {
|
320
|
+
"query LeaderboardQuery($count: Int, $after: String, $since: KarmaSince) {
|
321
|
+
leaderboard(count: $count, after: $after, since: $since) {
|
190
322
|
items {
|
323
|
+
#{@@user}
|
324
|
+
karmaSince: karma(since: $since)
|
191
325
|
}
|
192
326
|
}
|
193
|
-
}
|
194
|
-
|
195
|
-
|
196
|
-
id
|
197
|
-
image
|
198
|
-
...UserLabelUser
|
199
|
-
__typename
|
200
|
-
}
|
327
|
+
}"
|
328
|
+
end
|
329
|
+
end
|
201
330
|
|
202
|
-
fragment UserLabelUser on User {
|
203
|
-
id
|
204
|
-
username
|
205
|
-
karma
|
206
|
-
...UserLinkUser
|
207
|
-
__typename
|
208
|
-
}
|
209
331
|
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
id
|
219
|
-
username
|
220
|
-
karmaSince: karma(since: $since)
|
221
|
-
...UserLabelWithImageUser
|
222
|
-
...UserLinkUser
|
223
|
-
__typename
|
332
|
+
class Mutations < Queries
|
333
|
+
def Mutations.create_post
|
334
|
+
"mutation createPost($input: CreatePostInput!) {
|
335
|
+
createPost(input: $input) {
|
336
|
+
post {
|
337
|
+
#{@@post}
|
338
|
+
}
|
339
|
+
}
|
224
340
|
}"
|
225
341
|
end
|
226
342
|
end
|
data/lib/repltalk.rb
CHANGED
@@ -21,11 +21,16 @@ end
|
|
21
21
|
|
22
22
|
|
23
23
|
class Organization
|
24
|
-
attr_reader :id, :name
|
24
|
+
attr_reader :id, :name, :country, :postal_code, :state, :city, :timestamp
|
25
25
|
|
26
26
|
def initialize(organization)
|
27
27
|
@id = organization["id"]
|
28
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"]
|
29
34
|
end
|
30
35
|
|
31
36
|
def to_s
|
@@ -35,8 +40,25 @@ end
|
|
35
40
|
|
36
41
|
|
37
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
|
+
|
38
60
|
class Language
|
39
|
-
attr_reader :id, :key, :name, :tagline, :icon
|
61
|
+
attr_reader :id, :key, :name, :tagline, :icon, :category
|
40
62
|
|
41
63
|
def initialize(lang)
|
42
64
|
@id = lang["id"]
|
@@ -44,6 +66,7 @@ class Language
|
|
44
66
|
@name = lang["displayName"]
|
45
67
|
@tagline = lang["tagline"]
|
46
68
|
@icon = lang["icon"]
|
69
|
+
@category = lang["category"]
|
47
70
|
end
|
48
71
|
|
49
72
|
def to_s
|
@@ -53,8 +76,28 @@ end
|
|
53
76
|
|
54
77
|
|
55
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
|
+
|
56
99
|
class Repl
|
57
|
-
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
|
58
101
|
|
59
102
|
def initialize(client, repl)
|
60
103
|
@client = client
|
@@ -64,12 +107,37 @@ class Repl
|
|
64
107
|
@title = repl["title"]
|
65
108
|
@author = User.new(@client, repl["user"])
|
66
109
|
@description = repl["description"]
|
110
|
+
@size = repl["size"]
|
67
111
|
@language = Language.new(repl["lang"])
|
112
|
+
@image_url = repl["imageUrl"]
|
113
|
+
@origin_url = repl["origin"] == nil ? nil : $BASE_URL + repl["origin"]["url"]
|
68
114
|
|
69
115
|
@is_private = repl["isPrivate"]
|
70
116
|
@is_always_on = repl["isAlwaysOn"]
|
71
117
|
end
|
72
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
|
+
|
73
141
|
def to_s
|
74
142
|
@title
|
75
143
|
end
|
@@ -78,12 +146,13 @@ end
|
|
78
146
|
|
79
147
|
|
80
148
|
class Board
|
81
|
-
attr_reader :id, :name, :color
|
149
|
+
attr_reader :id, :name, :color, :description
|
82
150
|
|
83
151
|
def initialize(board)
|
84
152
|
@id = board["id"]
|
85
153
|
@name = board["name"]
|
86
154
|
@color = board["color"]
|
155
|
+
@description = board["description"]
|
87
156
|
end
|
88
157
|
|
89
158
|
def to_s
|
@@ -94,7 +163,7 @@ end
|
|
94
163
|
|
95
164
|
|
96
165
|
class Comment
|
97
|
-
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
|
98
167
|
|
99
168
|
def initialize(client, comment)
|
100
169
|
@client = client
|
@@ -107,7 +176,6 @@ class Comment
|
|
107
176
|
@is_answer = comment["isAnswer"]
|
108
177
|
@vote_count = comment["voteCount"]
|
109
178
|
@timestamp = comment["timeCreated"]
|
110
|
-
@comments = comment.include?("comments") ? comment["comments"].map { |c| Comment.new(@client, c)} : Array.new
|
111
179
|
|
112
180
|
@can_vote = comment["canVote"]
|
113
181
|
@has_voted = comment["hasVoted"]
|
@@ -119,7 +187,25 @@ class Comment
|
|
119
187
|
Queries.get_post,
|
120
188
|
id: @post_id
|
121
189
|
)
|
122
|
-
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"])
|
123
209
|
end
|
124
210
|
|
125
211
|
def to_s
|
@@ -130,7 +216,7 @@ end
|
|
130
216
|
|
131
217
|
|
132
218
|
class Post
|
133
|
-
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
|
134
220
|
|
135
221
|
def initialize(client, post)
|
136
222
|
@client = client
|
@@ -145,6 +231,7 @@ class Post
|
|
145
231
|
@board = Board.new(post["board"])
|
146
232
|
@repl = post["repl"] == nil ? nil : Repl.new(@client, post["repl"])
|
147
233
|
@author = post["user"] == nil ? "[deleted user]" : User.new(@client, post["user"])
|
234
|
+
@answer = post["answer"] == nil ? nil : Comment.new(@client, post["answer"])
|
148
235
|
|
149
236
|
@vote_count = post["voteCount"]
|
150
237
|
@comment_count = post["commentCount"]
|
@@ -173,6 +260,16 @@ class Post
|
|
173
260
|
c["post"]["comments"]["items"].map { |comment| Comment.new(@client, comment) }
|
174
261
|
end
|
175
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
|
+
|
176
273
|
def to_s
|
177
274
|
@title
|
178
275
|
end
|
@@ -181,7 +278,7 @@ end
|
|
181
278
|
|
182
279
|
|
183
280
|
class User
|
184
|
-
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
|
185
282
|
|
186
283
|
def initialize(client, user)
|
187
284
|
@client = client
|
@@ -194,6 +291,7 @@ class User
|
|
194
291
|
@cycles = user["karma"]
|
195
292
|
@is_hacker = user["isHacker"]
|
196
293
|
@timestamp = user["timeCreated"]
|
294
|
+
@subscription = user["subscription"] == nil ? nil : Subscription.new(user["subscription"])
|
197
295
|
@roles = user["roles"].map { |role| Role.new(role) }
|
198
296
|
@organization = user["organization"] == nil ? nil : Organization.new(user["organization"])
|
199
297
|
@languages = user["languages"].map { |lang| Language.new(lang) }
|
@@ -201,7 +299,7 @@ class User
|
|
201
299
|
|
202
300
|
def get_posts(order: "new", count: nil, after: nil)
|
203
301
|
p = @client.graphql(
|
204
|
-
"
|
302
|
+
"user",
|
205
303
|
Queries.get_user_posts,
|
206
304
|
username: @username,
|
207
305
|
order: order,
|
@@ -213,7 +311,7 @@ class User
|
|
213
311
|
|
214
312
|
def get_comments(order: "new", count: nil, after: nil)
|
215
313
|
c = @client.graphql(
|
216
|
-
"
|
314
|
+
"user",
|
217
315
|
Queries.get_user_comments,
|
218
316
|
username: @username,
|
219
317
|
order: order,
|
@@ -223,6 +321,22 @@ class User
|
|
223
321
|
c["user"]["comments"]["items"].map { |comment| Comment.new(@client, comment) }
|
224
322
|
end
|
225
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
|
+
|
226
340
|
def to_s
|
227
341
|
@username
|
228
342
|
end
|
@@ -230,6 +344,17 @@ end
|
|
230
344
|
|
231
345
|
|
232
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
|
+
|
233
358
|
class Client
|
234
359
|
attr_writer :sid
|
235
360
|
|
@@ -303,6 +428,35 @@ class Client
|
|
303
428
|
)
|
304
429
|
Comment.new(self, c["comment"])
|
305
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_board(name)
|
442
|
+
b = graphql(
|
443
|
+
"boardBySlug",
|
444
|
+
Queries.get_board,
|
445
|
+
slug: name
|
446
|
+
)
|
447
|
+
Board.new(b["board"])
|
448
|
+
end
|
449
|
+
|
450
|
+
def get_leaderboard(count: nil, since: nil, after: nil)
|
451
|
+
u = graphql(
|
452
|
+
"LeaderboardQuery",
|
453
|
+
Queries.get_leaderboard,
|
454
|
+
count: count,
|
455
|
+
since: since,
|
456
|
+
after: after
|
457
|
+
)
|
458
|
+
u["leaderboard"]["items"].map { |user| LeaderboardUser.new(self, user) }
|
459
|
+
end
|
306
460
|
|
307
461
|
def get_posts(board: "all", order: "new", count: nil, after: nil, search: nil, languages: nil)
|
308
462
|
p = graphql(
|
@@ -317,4 +471,19 @@ class Client
|
|
317
471
|
)
|
318
472
|
p["posts"]["items"].map { |post| Post.new(self, post) }
|
319
473
|
end
|
474
|
+
|
475
|
+
def create_post(board_name, title, content, repl_id: nil, show_hosted: false)
|
476
|
+
p = graphql(
|
477
|
+
"createPost",
|
478
|
+
Mutations.create_post,
|
479
|
+
input: {
|
480
|
+
boardId: get_board(board_name).id,
|
481
|
+
title: title,
|
482
|
+
body: content,
|
483
|
+
replId: repl_id,
|
484
|
+
showHosted: show_hosted
|
485
|
+
}
|
486
|
+
)
|
487
|
+
Post.new(self, p["createPost"]["post"])
|
488
|
+
end
|
320
489
|
end
|
metadata
CHANGED
@@ -1,43 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: repltalk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.1.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
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '4.4'
|
17
20
|
- - ">="
|
18
21
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
22
|
+
version: 4.4.1
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '4.4'
|
24
30
|
- - ">="
|
25
31
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
32
|
+
version: 4.4.1
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: json
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
30
36
|
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '2.5'
|
31
40
|
- - ">="
|
32
41
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
42
|
+
version: 2.5.1
|
34
43
|
type: :runtime
|
35
44
|
prerelease: false
|
36
45
|
version_requirements: !ruby/object:Gem::Requirement
|
37
46
|
requirements:
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '2.5'
|
38
50
|
- - ">="
|
39
51
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
52
|
+
version: 2.5.1
|
41
53
|
description: With the repltalk gem, you can easily interect with the repltalk graphql
|
42
54
|
api. See https://github.com/Coding-Cactus/repltalk for documentation
|
43
55
|
email: codingcactus.cc@gmail.com
|
@@ -47,7 +59,7 @@ extra_rdoc_files: []
|
|
47
59
|
files:
|
48
60
|
- lib/queries.rb
|
49
61
|
- lib/repltalk.rb
|
50
|
-
homepage:
|
62
|
+
homepage: https://github.com/Coding-Cactus/repltalk
|
51
63
|
licenses:
|
52
64
|
- MIT
|
53
65
|
metadata:
|