repltalk 3.2.0 → 4.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/repltalk/client.rb +36 -9
- data/lib/repltalk/graphql.rb +97 -15
- data/lib/repltalk/structures.rb +121 -25
- data/lib/repltalk.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b84d171f11260c6228c57a98ecafa820de55beee7e3b2b6a6a073c8d1f098e2d
|
4
|
+
data.tar.gz: 5308bbf0fe4421b85445e3d30166073508fe6a51298e862844d33bc876323c03
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e6233c13df87432bd1465da62193bc46d1b3ba7305ada0974693d88548ccd681af160f3ea82ea1384264434f185ca2364f2bf3de186dbcf9b44dd29d39c5324e
|
7
|
+
data.tar.gz: cc1d0293a530e7baaae7a3c1bbbe89296b2193fdad2c4097889dd25b96b641e218428db86672de0552cd17acb02420832d40285d0076080b45fbe97c3e4ffef3
|
data/lib/repltalk/client.rb
CHANGED
@@ -132,18 +132,45 @@ module ReplTalk
|
|
132
132
|
u["leaderboard"]["items"].map { |user| LeaderboardUser.new(self, user) }
|
133
133
|
end
|
134
134
|
|
135
|
-
def get_posts(board: "all", order: "
|
135
|
+
def get_posts(board: "all", order: "New", count: nil, after: nil, search: nil)
|
136
136
|
p = graphql(
|
137
|
-
"
|
137
|
+
"ReplPostsFeed",
|
138
138
|
GQL::Queries::GET_POSTS,
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
139
|
+
options: {
|
140
|
+
boardSlugs: [board],
|
141
|
+
order: order,
|
142
|
+
count: count,
|
143
|
+
after: after,
|
144
|
+
searchQuery: search
|
145
|
+
}
|
146
|
+
)
|
147
|
+
p["replPosts"]["items"].map { |post| Post.new(self, post) }
|
148
|
+
end
|
149
|
+
|
150
|
+
def get_explore_featured_repls
|
151
|
+
r = graphql(
|
152
|
+
"ExploreFeaturedRepls",
|
153
|
+
GQL::Queries::GET_EXPLORE_FEATURED_REPLS
|
154
|
+
)
|
155
|
+
r["featuredRepls"].map { |repl| Repl.new(self, repl) }
|
156
|
+
end
|
157
|
+
|
158
|
+
def get_trending_tags(count: nil)
|
159
|
+
t = graphql(
|
160
|
+
"ExploreFeed",
|
161
|
+
GQL::Queries::GET_TRENDING_TAGS,
|
162
|
+
count: count
|
163
|
+
)
|
164
|
+
t["trendingTagsFeed"]["initialTags"].map { |tag| Tag.new(self, tag) }
|
165
|
+
end
|
166
|
+
|
167
|
+
def get_tag(tag)
|
168
|
+
t = graphql(
|
169
|
+
"ExploreTrendingRepls",
|
170
|
+
GQL::Queries::GET_TAG,
|
171
|
+
tag: tag
|
145
172
|
)
|
146
|
-
|
173
|
+
Tag.new(self, t["tag"])
|
147
174
|
end
|
148
175
|
|
149
176
|
def create_post(board_name, title, content, repl_id: nil, show_hosted: false)
|
data/lib/repltalk/graphql.rb
CHANGED
@@ -8,16 +8,6 @@ module ReplTalk
|
|
8
8
|
tagline
|
9
9
|
"
|
10
10
|
|
11
|
-
ORGANIZATION = "
|
12
|
-
id
|
13
|
-
name
|
14
|
-
country
|
15
|
-
postalCode
|
16
|
-
state
|
17
|
-
city
|
18
|
-
timeCreated
|
19
|
-
"
|
20
|
-
|
21
11
|
LANGUAGE = "
|
22
12
|
id
|
23
13
|
key
|
@@ -46,14 +36,25 @@ module ReplTalk
|
|
46
36
|
roles {
|
47
37
|
#{ROLES}
|
48
38
|
}
|
49
|
-
organization {
|
50
|
-
#{ORGANIZATION}
|
51
|
-
}
|
52
39
|
languages {
|
53
40
|
#{LANGUAGE}
|
54
41
|
}
|
55
42
|
"
|
56
43
|
|
44
|
+
TAG = "
|
45
|
+
id
|
46
|
+
replCount
|
47
|
+
replsTaggedTodayCount
|
48
|
+
creatorCount
|
49
|
+
isTrending
|
50
|
+
"
|
51
|
+
|
52
|
+
REACTIONS = "
|
53
|
+
id
|
54
|
+
type
|
55
|
+
count
|
56
|
+
"
|
57
|
+
|
57
58
|
REPL = "
|
58
59
|
id
|
59
60
|
url
|
@@ -61,9 +62,17 @@ module ReplTalk
|
|
61
62
|
description
|
62
63
|
timeCreated
|
63
64
|
size
|
65
|
+
runCount
|
66
|
+
publicForkCount
|
64
67
|
imageUrl
|
65
68
|
isPrivate
|
66
69
|
isAlwaysOn
|
70
|
+
tags {
|
71
|
+
#{TAG}
|
72
|
+
}
|
73
|
+
reactions {
|
74
|
+
#{REACTIONS}
|
75
|
+
}
|
67
76
|
lang {
|
68
77
|
#{LANGUAGE}
|
69
78
|
}
|
@@ -127,6 +136,9 @@ module ReplTalk
|
|
127
136
|
repl {
|
128
137
|
#{REPL}
|
129
138
|
}
|
139
|
+
replComment {
|
140
|
+
#{REPL_COMMENT}
|
141
|
+
}
|
130
142
|
board {
|
131
143
|
#{BOARD}
|
132
144
|
}
|
@@ -321,8 +333,8 @@ module ReplTalk
|
|
321
333
|
"
|
322
334
|
|
323
335
|
GET_POSTS = "
|
324
|
-
query
|
325
|
-
|
336
|
+
query ReplPostsFeed($options: ReplPostsQueryOptions) {
|
337
|
+
replPosts(options: $options) {
|
326
338
|
items {
|
327
339
|
#{Fields::POST}
|
328
340
|
}
|
@@ -340,6 +352,44 @@ module ReplTalk
|
|
340
352
|
}
|
341
353
|
}
|
342
354
|
"
|
355
|
+
|
356
|
+
GET_EXPLORE_FEATURED_REPLS = "
|
357
|
+
query ExploreFeaturedRepls {
|
358
|
+
featuredRepls {
|
359
|
+
#{Fields::REPL}
|
360
|
+
}
|
361
|
+
}
|
362
|
+
"
|
363
|
+
|
364
|
+
GET_TAG = "
|
365
|
+
query ExploreTrendingRepls($tag: String!) {
|
366
|
+
tag(id: $tag) {
|
367
|
+
#{Fields::TAG}
|
368
|
+
}
|
369
|
+
}
|
370
|
+
"
|
371
|
+
|
372
|
+
GET_TRENDING_TAGS = "
|
373
|
+
query ExploreFeed($count: Int) {
|
374
|
+
trendingTagsFeed(initialTagsCount: $count) {
|
375
|
+
initialTags {
|
376
|
+
#{Fields::TAG}
|
377
|
+
}
|
378
|
+
}
|
379
|
+
}
|
380
|
+
"
|
381
|
+
|
382
|
+
GET_TAGS_REPLS = "
|
383
|
+
query ExploreTrendingRepls($tag: String!, $count: Int, $after: String) {
|
384
|
+
tag(id: $tag) {
|
385
|
+
repls(limit: $count, after: $after) {
|
386
|
+
items {
|
387
|
+
#{Fields::REPL}
|
388
|
+
}
|
389
|
+
}
|
390
|
+
}
|
391
|
+
}
|
392
|
+
"
|
343
393
|
end
|
344
394
|
|
345
395
|
|
@@ -442,6 +492,38 @@ module ReplTalk
|
|
442
492
|
}
|
443
493
|
"
|
444
494
|
|
495
|
+
PUBLISH_REPL = "
|
496
|
+
mutation PublishRepl($input: PublishReplInput!) {
|
497
|
+
publishRepl(input: $input) {
|
498
|
+
... on Repl {
|
499
|
+
#{Fields::REPL}
|
500
|
+
}
|
501
|
+
}
|
502
|
+
}
|
503
|
+
"
|
504
|
+
|
505
|
+
UNPUBLISH_REPL = "
|
506
|
+
mutation ReplViewHeaderActionsUnpublishRepl($input: UnpublishReplInput!) {
|
507
|
+
unpublishRepl(input: $input) {
|
508
|
+
... on Repl {
|
509
|
+
#{Fields::REPL}
|
510
|
+
}
|
511
|
+
}
|
512
|
+
}
|
513
|
+
"
|
514
|
+
|
515
|
+
TOGGLE_REACTION = "
|
516
|
+
mutation ReplViewReactionsToggleReactions($input: SetReplReactionInput!) {
|
517
|
+
setReplReaction(input: $input) {
|
518
|
+
... on Repl {
|
519
|
+
reactions {
|
520
|
+
#{Fields::REACTIONS}
|
521
|
+
}
|
522
|
+
}
|
523
|
+
}
|
524
|
+
}
|
525
|
+
"
|
526
|
+
|
445
527
|
REPORT_POST = "
|
446
528
|
mutation createBoardReport($id: Int!, $reason: String!) {
|
447
529
|
createBoardReport(postId: $id, reason: $reason) {
|
data/lib/repltalk/structures.rb
CHANGED
@@ -18,26 +18,6 @@ module ReplTalk
|
|
18
18
|
|
19
19
|
|
20
20
|
|
21
|
-
class Organization
|
22
|
-
attr_reader :id, :name, :country, :postal_code, :state, :city, :timestamp
|
23
|
-
|
24
|
-
def initialize(organization)
|
25
|
-
@id = organization["id"]
|
26
|
-
@name = organization["name"]
|
27
|
-
@country = organization["country"]
|
28
|
-
@postal_code = organization["postalCode"]
|
29
|
-
@state = organization["state"]
|
30
|
-
@city = organization["city"]
|
31
|
-
@timestamp = organization["timeCreated"]
|
32
|
-
end
|
33
|
-
|
34
|
-
def to_s
|
35
|
-
@name
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
|
40
|
-
|
41
21
|
class Language
|
42
22
|
attr_reader :id, :key, :name, :tagline, :icon, :category
|
43
23
|
|
@@ -74,6 +54,55 @@ module ReplTalk
|
|
74
54
|
|
75
55
|
|
76
56
|
|
57
|
+
class Tag
|
58
|
+
attr_reader :id, :repl_count, :creator_count, :is_trending, :repls_tagged_today_count
|
59
|
+
|
60
|
+
def initialize(client, tag)
|
61
|
+
@client = client
|
62
|
+
|
63
|
+
@id = tag["id"]
|
64
|
+
@repl_count = tag["replCount"]
|
65
|
+
@is_trending = tag["isTrending"]
|
66
|
+
@creator_count = tag["creatorCount"]
|
67
|
+
@repls_tagged_today_count = tag["replsTaggedTodayCount"]
|
68
|
+
end
|
69
|
+
|
70
|
+
def get_repls(count: nil, after: nil)
|
71
|
+
r = @client.graphql(
|
72
|
+
"ExploreTrendingRepls",
|
73
|
+
GQL::Queries::GET_TAGS_REPLS,
|
74
|
+
tag: @id,
|
75
|
+
count: count,
|
76
|
+
after: after
|
77
|
+
)
|
78
|
+
r["tag"]["repls"]["items"].map { |repl| Repl.new(@client, repl) }
|
79
|
+
end
|
80
|
+
|
81
|
+
def to_s
|
82
|
+
@id
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
class Reaction
|
90
|
+
attr_reader :id, :type, :count
|
91
|
+
|
92
|
+
def initialize(reaction)
|
93
|
+
@id = reaction["id"]
|
94
|
+
@type = reaction["type"]
|
95
|
+
@count = reaction["count"]
|
96
|
+
end
|
97
|
+
|
98
|
+
def to_s
|
99
|
+
@type
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
|
77
106
|
class ReplComment
|
78
107
|
attr_reader :id, :content, :author, :repl, :replies
|
79
108
|
|
@@ -128,7 +157,7 @@ module ReplTalk
|
|
128
157
|
|
129
158
|
|
130
159
|
class Repl
|
131
|
-
attr_reader :id, :url, :title, :author, :description, :timestamp, :size, :language, :img_url, :origin_url, :is_private, :is_always_on
|
160
|
+
attr_reader :id, :url, :title, :author, :description, :timestamp, :size, :run_count, :fork_count, :language, :img_url, :origin_url, :is_private, :is_always_on, :tags, :reactions
|
132
161
|
|
133
162
|
def initialize(client, repl)
|
134
163
|
@client = client
|
@@ -140,12 +169,17 @@ module ReplTalk
|
|
140
169
|
@description = repl["description"]
|
141
170
|
@timestamp = repl["timeCreated"]
|
142
171
|
@size = repl["size"]
|
172
|
+
@run_count = repl["runCount"]
|
173
|
+
@fork_count = repl["publicForkCount"]
|
143
174
|
@language = Language.new(repl["lang"])
|
144
175
|
@image_url = repl["imageUrl"]
|
145
176
|
@origin_url = repl["origin"] == nil ? nil : $BASE_URL + repl["origin"]["url"]
|
146
177
|
|
147
178
|
@is_private = repl["isPrivate"]
|
148
179
|
@is_always_on = repl["isAlwaysOn"]
|
180
|
+
|
181
|
+
@tags = repl["tags"].map { |tag| Tag.new(@client, tag) }
|
182
|
+
@reactions = repl["reactions"].map { |reaction| Reaction.new(reaction) }
|
149
183
|
end
|
150
184
|
|
151
185
|
def get_forks(count: 100, after: nil)
|
@@ -182,6 +216,63 @@ module ReplTalk
|
|
182
216
|
ReplComment.new(@client, c["createReplComment"])
|
183
217
|
end
|
184
218
|
|
219
|
+
def add_reaction(type)
|
220
|
+
r = @client.graphql(
|
221
|
+
"ReplViewReactionsToggleReactions",
|
222
|
+
GQL::Mutations::TOGGLE_REACTION,
|
223
|
+
input: {
|
224
|
+
replId: @id,
|
225
|
+
react: true,
|
226
|
+
reactionType: type
|
227
|
+
}
|
228
|
+
)
|
229
|
+
if r["setReplReaction"]["reactions"] == nil
|
230
|
+
@reactions
|
231
|
+
else
|
232
|
+
@reactions = r["setReplReaction"]["reactions"].map { |reaction| Reaction.new(reaction) }
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
236
|
+
def remove_reaction(type)
|
237
|
+
r = @client.graphql(
|
238
|
+
"ReplViewReactionsToggleReactions",
|
239
|
+
GQL::Mutations::TOGGLE_REACTION,
|
240
|
+
input: {
|
241
|
+
replId: @id,
|
242
|
+
react: false,
|
243
|
+
reactionType: type
|
244
|
+
}
|
245
|
+
)
|
246
|
+
@reactions = r["setReplReaction"]["reactions"].map { |reaction| Reaction.new(reaction) }
|
247
|
+
end
|
248
|
+
|
249
|
+
def publish(description, image_url, tags, enable_comments: true)
|
250
|
+
r = @client.graphql(
|
251
|
+
"PublishRepl",
|
252
|
+
GQL::Mutations::PUBLISH_REPL,
|
253
|
+
input: {
|
254
|
+
replId: @id,
|
255
|
+
replTitle: @title,
|
256
|
+
description: description,
|
257
|
+
imageUrl: image_url,
|
258
|
+
tags: tags,
|
259
|
+
enableComments: enable_comments,
|
260
|
+
}
|
261
|
+
)
|
262
|
+
Repl.new(@client, r["publishRepl"])
|
263
|
+
end
|
264
|
+
|
265
|
+
def unpublish
|
266
|
+
r = @client.graphql(
|
267
|
+
"ReplViewHeaderActionsUnpublishRepl",
|
268
|
+
GQL::Mutations::UNPUBLISH_REPL,
|
269
|
+
input: {
|
270
|
+
replId: @id
|
271
|
+
}
|
272
|
+
)
|
273
|
+
Repl.new(@client, r["unpublishRepl"])
|
274
|
+
end
|
275
|
+
|
185
276
|
def to_s
|
186
277
|
@title
|
187
278
|
end
|
@@ -289,15 +380,21 @@ module ReplTalk
|
|
289
380
|
class Post
|
290
381
|
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
|
291
382
|
|
292
|
-
def initialize(client, post)
|
383
|
+
def initialize(client, post)
|
293
384
|
@client = client
|
294
385
|
|
295
386
|
@id = post["id"]
|
296
387
|
@url = $BASE_URL + post["url"]
|
297
388
|
@title = post["title"]
|
389
|
+
@timestamp = post["timeCreated"]
|
390
|
+
|
298
391
|
@content = post["body"]
|
299
392
|
@preview = post["preview"]
|
300
|
-
|
393
|
+
|
394
|
+
if @content == ""
|
395
|
+
@content = post["replComment"]["body"]
|
396
|
+
@preview = @content.length > 150 ? @content[0..150] : @content
|
397
|
+
end
|
301
398
|
|
302
399
|
@board = Board.new(post["board"])
|
303
400
|
@repl = post["repl"] == nil ? nil : Repl.new(@client, post["repl"])
|
@@ -395,7 +492,7 @@ module ReplTalk
|
|
395
492
|
|
396
493
|
|
397
494
|
class User
|
398
|
-
attr_reader :id, :username, :name, :pfp, :bio, :cycles, :is_hacker, :timestamp, :subscription, :roles, :
|
495
|
+
attr_reader :id, :username, :name, :pfp, :bio, :cycles, :is_hacker, :timestamp, :subscription, :roles, :languages
|
399
496
|
|
400
497
|
def initialize(client, user)
|
401
498
|
return nil if user == nil
|
@@ -410,7 +507,6 @@ module ReplTalk
|
|
410
507
|
@is_hacker = user["isHacker"]
|
411
508
|
@timestamp = user["timeCreated"]
|
412
509
|
@roles = user["roles"].map { |role| Role.new(role) }
|
413
|
-
@organization = user["organization"] == nil ? nil : Organization.new(user["organization"])
|
414
510
|
@languages = user["languages"].map { |lang| Language.new(lang) }
|
415
511
|
end
|
416
512
|
|
data/lib/repltalk.rb
CHANGED
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:
|
4
|
+
version: 4.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- CodingCactus
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: http
|