repltalk 4.0.1 → 4.2.0

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: ca32c6abe912a479dc7c61817f187201159673fbb1552709ba6ea2430d6eaa9c
4
- data.tar.gz: 52227cb7b963b6c1a1f5398ce8352dd223c70dd1a0e089bf6f175fbe253fa6cb
3
+ metadata.gz: a53c13e1afa3b083432593518f24be2413de67b4ac7c9c3d0a325e118ce5a21b
4
+ data.tar.gz: c3973f28be9f38c34c9fbab0b194bb9bc4c76dd8b6cea92f4fca6b135dd93656
5
5
  SHA512:
6
- metadata.gz: 2c02a0b643517276ecb60d843345dae996855ff0b726f576a824000b1cc21d16fb0d6522d56d87839c12730a488aa616dc1617bdee703d0a524d1b3f4d306abb
7
- data.tar.gz: 98ada7dd72a0646fe6b4312a18b33ad71c36b45cc14f0e0c9bf13759d5cf0da079aa939481b8410c5aca599edc7fe07183aebbca90b26e9b643960a8a4b75119
6
+ metadata.gz: 838143889e780ba16a2701a3acaa108851f17f37dd806a1e75f9a078825e3851cfba69aae0ce43699d11d3bc0b5d0066ee3926f17b711c2e564eb3421ef64a44
7
+ data.tar.gz: 2b41a5f852a0afdb1ac84b2fb6ee8c51b137ac945f93a670d9af3680d801ba68fcd4c3e3cf9d5a1724c40f33b5330a9f0d024d7ebcfc0126fc7a58fa0d9a015c
@@ -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)
@@ -120,30 +120,20 @@ module ReplTalk
120
120
  return nil if b == nil || b["board"] == nil
121
121
  Board.new(b["board"])
122
122
  end
123
-
124
- def get_leaderboard(count: nil, since: nil, after: nil)
125
- u = graphql(
126
- "LeaderboardQuery",
127
- GQL::Queries::GET_LEADERBOARD,
128
- count: count,
129
- since: since,
130
- after: after
131
- )
132
- u["leaderboard"]["items"].map { |user| LeaderboardUser.new(self, user) }
133
- end
134
123
 
135
- def get_posts(board: "all", order: "new", count: nil, after: nil, search: nil, languages: nil)
124
+ def get_posts(board: "all", order: "new", count: nil, after: nil, search: nil)
136
125
  p = graphql(
137
- "PostsFeed",
126
+ "ReplPostsFeed",
138
127
  GQL::Queries::GET_POSTS,
139
- boardSlugs: [board],
140
- order: order,
141
- count: count,
142
- after: after,
143
- searchQuery: search,
144
- languages: languages
128
+ options: {
129
+ boardSlugs: [board],
130
+ order: order.capitalize,
131
+ count: count,
132
+ after: after,
133
+ searchQuery: search
134
+ }
145
135
  )
146
- p["posts"]["items"].map { |post| Post.new(self, post) }
136
+ p["replPosts"]["items"].map { |post| Post.new(self, post) }
147
137
  end
148
138
 
149
139
  def get_explore_featured_repls
@@ -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
  }
@@ -352,17 +342,6 @@ module ReplTalk
352
342
  }
353
343
  "
354
344
 
355
- GET_LEADERBOARD = "
356
- query LeaderboardQuery($count: Int, $after: String, $since: KarmaSince) {
357
- leaderboard(count: $count, after: $after, since: $since) {
358
- items {
359
- #{Fields::USER}
360
- karmaSince: karma(since: $since)
361
- }
362
- }
363
- }
364
- "
365
-
366
345
  GET_EXPLORE_FEATURED_REPLS = "
367
346
  query ExploreFeaturedRepls {
368
347
  featuredRepls {
@@ -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
 
@@ -186,7 +166,7 @@ module ReplTalk
186
166
  @url = $BASE_URL + repl["url"]
187
167
  @title = repl["title"]
188
168
  @author = User.new(@client, repl["user"])
189
- @description = repl["description"]
169
+ @description = repl["description"].to_s
190
170
  @timestamp = repl["timeCreated"]
191
171
  @size = repl["size"]
192
172
  @run_count = repl["runCount"]
@@ -406,14 +386,27 @@ module ReplTalk
406
386
  @id = post["id"]
407
387
  @url = $BASE_URL + post["url"]
408
388
  @title = post["title"]
409
- @content = post["body"]
410
- @preview = post["preview"]
411
389
  @timestamp = post["timeCreated"]
412
390
 
413
- @board = Board.new(post["board"])
391
+ @board = post["board"].nil? ? nil : Board.new(post["board"])
414
392
  @repl = post["repl"] == nil ? nil : Repl.new(@client, post["repl"])
415
393
  @author = post["user"] == nil ? nil : User.new(@client, post["user"])
416
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
+ if post["replComment"].nil? # no post attached
401
+ @url = @repl.url
402
+ @title = @repl.title
403
+ @content = @repl.description
404
+ else # post attached
405
+ @url = "#{@repl.url}?c=#{post["replComment"]["id"]}"
406
+ @content = post["replComment"]["body"]
407
+ end
408
+ @preview = @content.length > 150 ? @content[0..150] : @content
409
+ end
417
410
 
418
411
  @vote_count = post["voteCount"]
419
412
  @comment_count = post["commentCount"]
@@ -506,7 +499,7 @@ module ReplTalk
506
499
 
507
500
 
508
501
  class User
509
- attr_reader :id, :username, :name, :pfp, :bio, :cycles, :is_hacker, :timestamp, :subscription, :roles, :organization, :languages
502
+ attr_reader :id, :username, :name, :pfp, :bio, :cycles, :is_hacker, :timestamp, :subscription, :roles, :languages
510
503
 
511
504
  def initialize(client, user)
512
505
  return nil if user == nil
@@ -521,7 +514,6 @@ module ReplTalk
521
514
  @is_hacker = user["isHacker"]
522
515
  @timestamp = user["timeCreated"]
523
516
  @roles = user["roles"].map { |role| Role.new(role) }
524
- @organization = user["organization"] == nil ? nil : Organization.new(user["organization"])
525
517
  @languages = user["languages"].map { |lang| Language.new(lang) }
526
518
  end
527
519
 
@@ -569,15 +561,4 @@ module ReplTalk
569
561
  @username
570
562
  end
571
563
  end
572
-
573
-
574
-
575
- class LeaderboardUser < User
576
- attr_reader :cycles_since
577
-
578
- def initialize(client, user)
579
- super(client, user)
580
- @cycles_since = user["karmaSince"]
581
- end
582
- end
583
564
  end
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.1"
7
+ VERSION = "4.2.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.1
4
+ version: 4.2.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-05-15 00:00:00.000000000 Z
11
+ date: 2022-02-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http