repltalk 4.0.0 → 4.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dd7a674596285cb7f8a4d0c2f6a5a9a03629a128f103def8f25b8404c4a6dba5
4
- data.tar.gz: 53337d06dffe548294ffad1019dcb2c89e96f9d307d57d711fee8f29a6f75298
3
+ metadata.gz: 17af54edd0d1552ed38a2f3e971da22cb42eb3540eac53642f2347555284c4b1
4
+ data.tar.gz: 5a30898e823d5d5959b1fe33e2f6508865f6538982c3e605ef83e9e684b4e52a
5
5
  SHA512:
6
- metadata.gz: 9147b972df6cf7c7c204b748340ad45ddcca8f3d06f8438852625aba108707a6293d2afdcc7728ce3780475237783adb3d846c5802b3333266d9e09f47bb0c6c
7
- data.tar.gz: 9b11286a5337596e79c928a68af57519c65a9e700396be6869b777238f5b31a5bfa8db7cbf670d13ba5a131faf36897e65c943e15a17e8cc320bac626bec5740
6
+ metadata.gz: 7fa905a802f5bbba4d8f7c3d0ee403b3d7885d8069e04c4e68e73ed8891b0403c2e2e4880f2a2ec0155325556f31ff3f50abc4109d0086bb0abd1065000005d2
7
+ data.tar.gz: 0f319ab29a06dbb6424d9cf71cff28dbaba96951ab537f5f6a5819e4988dc26f734f5b27a3df71aab22307c756ef4fc3a7a9c8ebbbf0e491182d28c846dda9e2
@@ -24,7 +24,7 @@ module ReplTalk
24
24
  "X-Requested-With": "ReplTalk"
25
25
  )
26
26
  .post(
27
- "#{$BASE_URL}/graphql",
27
+ "#{$BASE_URL}/graphql",
28
28
  form: payload
29
29
  )
30
30
  begin data = JSON.parse(r)
@@ -132,18 +132,19 @@ 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: "new", count: nil, after: nil, search: nil, languages: nil)
135
+ def get_posts(board: "all", order: "New", count: nil, after: nil, search: nil)
136
136
  p = graphql(
137
- "PostsFeed",
137
+ "ReplPostsFeed",
138
138
  GQL::Queries::GET_POSTS,
139
- boardSlugs: [board],
140
- order: order,
141
- count: count,
142
- after: after,
143
- searchQuery: search,
144
- languages: languages
139
+ options: {
140
+ boardSlugs: [board],
141
+ order: order,
142
+ count: count,
143
+ after: after,
144
+ searchQuery: search
145
+ }
145
146
  )
146
- p["posts"]["items"].map { |post| Post.new(self, post) }
147
+ p["replPosts"]["items"].map { |post| Post.new(self, post) }
147
148
  end
148
149
 
149
150
  def get_explore_featured_repls
@@ -154,10 +155,11 @@ module ReplTalk
154
155
  r["featuredRepls"].map { |repl| Repl.new(self, repl) }
155
156
  end
156
157
 
157
- def get_trending_tags
158
+ def get_trending_tags(count: nil)
158
159
  t = graphql(
159
160
  "ExploreFeed",
160
- GQL::Queries::GET_TRENDING_TAGS
161
+ GQL::Queries::GET_TRENDING_TAGS,
162
+ count: count
161
163
  )
162
164
  t["trendingTagsFeed"]["initialTags"].map { |tag| Tag.new(self, tag) }
163
165
  end
@@ -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,9 +36,6 @@ module ReplTalk
46
36
  roles {
47
37
  #{ROLES}
48
38
  }
49
- organization {
50
- #{ORGANIZATION}
51
- }
52
39
  languages {
53
40
  #{LANGUAGE}
54
41
  }
@@ -139,7 +126,7 @@ module ReplTalk
139
126
  isAnnouncement
140
127
  timeCreated
141
128
  isAnswered
142
- isAnswerable
129
+ isAnswerable
143
130
  voteCount
144
131
  canVote
145
132
  hasVoted
@@ -149,6 +136,9 @@ module ReplTalk
149
136
  repl {
150
137
  #{REPL}
151
138
  }
139
+ replComment {
140
+ #{REPL_COMMENT}
141
+ }
152
142
  board {
153
143
  #{BOARD}
154
144
  }
@@ -343,8 +333,8 @@ module ReplTalk
343
333
  "
344
334
 
345
335
  GET_POSTS = "
346
- query PostsFeed($order: String, $after: String, $searchQuery: String, $languages: [String!], $count: Int, $boardSlugs: [String!]) {
347
- posts(order: $order, after: $after, searchQuery: $searchQuery, languages: $languages, count: $count, boardSlugs: $boardSlugs) {
336
+ query ReplPostsFeed($options: ReplPostsQueryOptions) {
337
+ replPosts(options: $options) {
348
338
  items {
349
339
  #{Fields::POST}
350
340
  }
@@ -380,17 +370,19 @@ module ReplTalk
380
370
  "
381
371
 
382
372
  GET_TRENDING_TAGS = "
383
- query ExploreTrendingRepls($tag: String!) {
384
- tag(id: $tag) {
385
- #{Fields::TAG}
373
+ query ExploreFeed($count: Int) {
374
+ trendingTagsFeed(initialTagsCount: $count) {
375
+ initialTags {
376
+ #{Fields::TAG}
377
+ }
386
378
  }
387
379
  }
388
380
  "
389
381
 
390
382
  GET_TAGS_REPLS = "
391
- query ExploreTrendingRepls($tag: String!, $after: String) {
383
+ query ExploreTrendingRepls($tag: String!, $count: Int, $after: String) {
392
384
  tag(id: $tag) {
393
- repls(after: $after) {
385
+ repls(limit: $count, after: $after) {
394
386
  items {
395
387
  #{Fields::REPL}
396
388
  }
@@ -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
 
@@ -87,11 +67,12 @@ module ReplTalk
87
67
  @repls_tagged_today_count = tag["replsTaggedTodayCount"]
88
68
  end
89
69
 
90
- def get_repls(after: nil)
70
+ def get_repls(count: nil, after: nil)
91
71
  r = @client.graphql(
92
72
  "ExploreTrendingRepls",
93
73
  GQL::Queries::GET_TAGS_REPLS,
94
74
  tag: @id,
75
+ count: count,
95
76
  after: after
96
77
  )
97
78
  r["tag"]["repls"]["items"].map { |repl| Repl.new(@client, repl) }
@@ -405,14 +386,21 @@ module ReplTalk
405
386
  @id = post["id"]
406
387
  @url = $BASE_URL + post["url"]
407
388
  @title = post["title"]
408
- @content = post["body"]
409
- @preview = post["preview"]
410
389
  @timestamp = post["timeCreated"]
411
390
 
412
391
  @board = Board.new(post["board"])
413
392
  @repl = post["repl"] == nil ? nil : Repl.new(@client, post["repl"])
414
393
  @author = post["user"] == nil ? nil : User.new(@client, post["user"])
415
394
  @answer = post["answer"] == nil ? nil : Comment.new(@client, post["answer"])
395
+
396
+ @content = post["body"]
397
+ @preview = post["preview"]
398
+
399
+ if @content == "" # new post type
400
+ @url = "#{@repl.url}?c=#{post["replComment"]["id"]}"
401
+ @content = post["replComment"]["body"]
402
+ @preview = @content.length > 150 ? @content[0..150] : @content
403
+ end
416
404
 
417
405
  @vote_count = post["voteCount"]
418
406
  @comment_count = post["commentCount"]
@@ -505,7 +493,7 @@ module ReplTalk
505
493
 
506
494
 
507
495
  class User
508
- attr_reader :id, :username, :name, :pfp, :bio, :cycles, :is_hacker, :timestamp, :subscription, :roles, :organization, :languages
496
+ attr_reader :id, :username, :name, :pfp, :bio, :cycles, :is_hacker, :timestamp, :subscription, :roles, :languages
509
497
 
510
498
  def initialize(client, user)
511
499
  return nil if user == nil
@@ -520,7 +508,6 @@ module ReplTalk
520
508
  @is_hacker = user["isHacker"]
521
509
  @timestamp = user["timeCreated"]
522
510
  @roles = user["roles"].map { |role| Role.new(role) }
523
- @organization = user["organization"] == nil ? nil : Organization.new(user["organization"])
524
511
  @languages = user["languages"].map { |lang| Language.new(lang) }
525
512
  end
526
513
 
data/lib/repltalk.rb CHANGED
@@ -4,5 +4,5 @@ require_relative "repltalk/structures"
4
4
 
5
5
  module ReplTalk
6
6
  $BASE_URL = "https://replit.com"
7
- VERSION = "4.0.0"
7
+ VERSION = "4.1.0"
8
8
  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: 4.0.0
4
+ version: 4.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - CodingCactus
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-08 00:00:00.000000000 Z
11
+ date: 2022-01-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http