qwtf_discord_bot 0.5.8 → 0.5.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 83f90cbd31c83661734c27b7dd1c965ad52a6059fc5cd49b16a2f13f23b29920
4
- data.tar.gz: ef56a673b3ac0e92b38dd8211e0c0cd60d5ad7b1629f4fdd139de671c7ce1bf6
3
+ metadata.gz: 1bd7254f41fd6d3cd8f1179854e859ac125682ef8206f82b4248c1e35adce4dc
4
+ data.tar.gz: ff9c1b9b447c76399170518bff90675094daabe6d26e8a0738dbec62656b3716
5
5
  SHA512:
6
- metadata.gz: 1a570a0a3d9b13ead7cfa821c4ef8bb9e29c08b8ff470b874221bd1c1a139aeaa2609aaf076d340513cef45e78ac3eba4cb24c233648205ca68e0ed8e70de3a5
7
- data.tar.gz: 99a2f177908b13de64a1ae90e67a29e898a9f405aff427ada5e2aca20767caa2ee410114c3f6888bae3ab3f0459558e6cf8239b04f205b2dbc5af768c6f31629
6
+ metadata.gz: 67eefb3c5b4eff0989b0b12c9c2364c750d177548023c68295a4e722110f089cf7c74ed15cf7b04585bf1d5cad695997eb6717a0aad4df61367475cd08545fac
7
+ data.tar.gz: db2293dfa8d5f80ac5454ac690c58650ad79c003b4f31f899fb829c6691b4bfef238829b65a8180ef59c8d7e9349f48759ef722d1252faffd7c81dcb79a506e2
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- qwtf_discord_bot (0.5.8)
4
+ qwtf_discord_bot (0.5.9)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/lib/player.rb CHANGED
@@ -28,6 +28,7 @@ class Player
28
28
  end
29
29
 
30
30
  def team
31
+ return 'spec' unless valid_score?
31
32
  @data['team']
32
33
  end
33
34
 
@@ -48,4 +49,8 @@ class Player
48
49
  def skin
49
50
  @data['skin']
50
51
  end
52
+
53
+ def valid_score?
54
+ score >= 0
55
+ end
51
56
  end
data/lib/qstat_request.rb CHANGED
@@ -5,19 +5,16 @@ class QstatRequest
5
5
  end
6
6
 
7
7
  def teams
8
- @teams ||= begin
9
- return nil unless has_players?
10
- build_roster
11
- end
8
+ @teams ||= build_roster
12
9
  end
13
10
 
14
11
  def to_message
15
- return server_summary unless has_players?
12
+ return server_summary if is_empty?
16
13
  [server_summary, player_table].join("\n")
17
14
  end
18
15
 
19
16
  def to_embed
20
- return nil unless has_players?
17
+ return nil if is_empty?
21
18
 
22
19
  embed = Discordrb::Webhooks::Embed.new
23
20
 
@@ -30,11 +27,20 @@ class QstatRequest
30
27
 
31
28
  def server_summary
32
29
  return "#{@endpoint} isn't responding" unless game_map
33
- "#{@endpoint} | #{game_map} | #{numplayers}/#{maxplayers}"
30
+ return "#{@endpoint} | #{game_map} | #{numplayers}/#{maxplayers}" unless has_spectators?
31
+ "#{@endpoint} | #{game_map} | #{numplayers}/#{maxplayers} players | #{numspectators}/#{maxspectators} spectators"
32
+ end
33
+
34
+ def is_empty?
35
+ !has_players? && !has_spectators?
36
+ end
37
+
38
+ def has_spectators?
39
+ numspectators > 0
34
40
  end
35
41
 
36
42
  def has_players?
37
- @data["players"] && @data["players"].any?
43
+ numplayers > 0
38
44
  end
39
45
 
40
46
  def player_names
@@ -67,7 +73,17 @@ class QstatRequest
67
73
  @data["maxplayers"]
68
74
  end
69
75
 
76
+ def numspectators
77
+ @data["numspectators"]
78
+ end
79
+
80
+ def maxspectators
81
+ @data["maxspectators"]
82
+ end
83
+
70
84
  def build_roster
85
+ return nil if is_empty?
86
+
71
87
  roster = {}
72
88
 
73
89
  @data["players"].map do |player_data|
@@ -1,3 +1,3 @@
1
1
  class QwtfDiscordBot
2
- VERSION = '0.5.8'.freeze
2
+ VERSION = '0.5.9'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qwtf_discord_bot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.8
4
+ version: 0.5.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sheldon Johnson