qwtf_discord_bot 5.5.22 → 6.0.1
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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +2 -2
- data/VERSION +1 -1
- data/docker-compose.yml +1 -0
- data/lib/dashboard.rb +7 -7
- data/lib/qstat_request.rb +33 -30
- data/lib/qwtf_discord_bot/qwtf_discord_bot_pug.rb +14 -7
- 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: 7873dfbc7828ca1970851e98c563be1adfc62cb0f451a4a3f76d5dbc551db8a4
|
4
|
+
data.tar.gz: b34b2f5138fff279ff9ed28f2034058cef15ba3cd95c4c4157d1588dd0664dc3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6bc88b6b480c2a53a8f79a17a1c7202d446d8a068aa1daf0bc9a685ca63c09705450466572ba3fb95a7b7e84360e7e29db41415a74f3e277ea08ae1e61c18b89
|
7
|
+
data.tar.gz: a75c8be77b08ffd148e79c374451e65d31f7b5131e6254f0fa2da434885db24a7ebb1df6e84509c3715a1f46cde7a53dae8d4a326fc367c996c791c81a3926ce
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -180,8 +180,8 @@ Build:
|
|
180
180
|
|
181
181
|
Push:
|
182
182
|
|
183
|
-
docker tag discord-bot fortressone/discord-bot:latest
|
184
|
-
|
183
|
+
docker tag discord-bot fortressone/discord-bot:latest \
|
184
|
+
&& docker push fortressone/discord-bot:latest
|
185
185
|
|
186
186
|
|
187
187
|
Create AWS instance:
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
6.0.1
|
data/docker-compose.yml
CHANGED
data/lib/dashboard.rb
CHANGED
@@ -2,6 +2,8 @@ class Dashboard
|
|
2
2
|
def initialize(dashboard_config, bot)
|
3
3
|
@server = bot.server(dashboard_config["server_id"])
|
4
4
|
@endpoints = dashboard_config["endpoints"]
|
5
|
+
@messages = {}
|
6
|
+
|
5
7
|
|
6
8
|
channel_name = dashboard_config["name"]
|
7
9
|
|
@@ -32,15 +34,13 @@ class Dashboard
|
|
32
34
|
end
|
33
35
|
|
34
36
|
def update
|
35
|
-
messages = {}
|
36
|
-
|
37
37
|
@endpoints.each do |endpoint|
|
38
38
|
qstat_request = QstatRequest.new(endpoint)
|
39
39
|
|
40
40
|
if qstat_request.is_empty?
|
41
|
-
if messages[endpoint]
|
42
|
-
messages[endpoint].delete
|
43
|
-
messages.delete(endpoint)
|
41
|
+
if @messages[endpoint]
|
42
|
+
@messages[endpoint].delete
|
43
|
+
@messages.delete(endpoint)
|
44
44
|
end
|
45
45
|
|
46
46
|
next
|
@@ -48,8 +48,8 @@ class Dashboard
|
|
48
48
|
|
49
49
|
embed = qstat_request.to_full_embed
|
50
50
|
|
51
|
-
messages[endpoint] = if messages[endpoint]
|
52
|
-
messages[endpoint].edit(nil, embed)
|
51
|
+
@messages[endpoint] = if @messages[endpoint]
|
52
|
+
@messages[endpoint].edit(nil, embed)
|
53
53
|
else
|
54
54
|
@channel.send_embed(nil, embed)
|
55
55
|
end
|
data/lib/qstat_request.rb
CHANGED
@@ -17,7 +17,7 @@ class QstatRequest
|
|
17
17
|
embed = Discordrb::Webhooks::Embed.new
|
18
18
|
|
19
19
|
teams.each do |team|
|
20
|
-
embed
|
20
|
+
embed << team.to_embed_field
|
21
21
|
end
|
22
22
|
|
23
23
|
embed
|
@@ -45,39 +45,39 @@ class QstatRequest
|
|
45
45
|
def server_summary
|
46
46
|
return "#{@endpoint} isn't responding" unless game_map
|
47
47
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
48
|
+
info = [name, @endpoint, game_map]
|
49
|
+
|
50
|
+
info += if !has_spectators?
|
51
|
+
["#{numplayers}/#{maxplayers}"]
|
52
|
+
else
|
53
|
+
[
|
54
|
+
"#{numplayers}/#{maxplayers} players",
|
55
|
+
"#{numspectators}/#{maxspectators} spectators"
|
56
|
+
]
|
57
|
+
end
|
58
|
+
|
59
|
+
info.join(MSG_SNIPPET_DELIMITER)
|
60
|
+
end
|
56
61
|
|
57
|
-
|
58
|
-
|
59
|
-
@endpoint,
|
60
|
-
game_map,
|
61
|
-
"#{numplayers}/#{maxplayers} players",
|
62
|
-
"#{numspectators}/#{maxspectators} spectators"
|
63
|
-
].join(MSG_SNIPPET_DELIMITER)
|
62
|
+
def join_link
|
63
|
+
"[Join](http://phobos.baseq.fr:9999/join?url=#{@endpoint})"
|
64
64
|
end
|
65
65
|
|
66
66
|
def embed_summary
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
67
|
+
info = [@endpoint, game_map]
|
68
|
+
|
69
|
+
info += if !has_spectators?
|
70
|
+
["#{numplayers}/#{maxplayers}"]
|
71
|
+
else
|
72
|
+
[
|
73
|
+
"#{numplayers}/#{maxplayers} players",
|
74
|
+
"#{numspectators}/#{maxspectators} spectators"
|
75
|
+
]
|
76
|
+
end
|
74
77
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
"#{numplayers}/#{maxplayers} players",
|
79
|
-
"#{numspectators}/#{maxspectators} spectators"
|
80
|
-
].join(MSG_SNIPPET_DELIMITER)
|
78
|
+
info << join_link
|
79
|
+
|
80
|
+
info.join(MSG_SNIPPET_DELIMITER)
|
81
81
|
end
|
82
82
|
|
83
83
|
def is_empty?
|
@@ -115,7 +115,10 @@ class QstatRequest
|
|
115
115
|
end
|
116
116
|
|
117
117
|
def name
|
118
|
-
data['name']
|
118
|
+
name = data['name']
|
119
|
+
return address if name.empty?
|
120
|
+
|
121
|
+
name
|
119
122
|
end
|
120
123
|
|
121
124
|
def address
|
@@ -430,7 +430,7 @@ class QwtfDiscordBotPug # :nodoc:
|
|
430
430
|
).body
|
431
431
|
|
432
432
|
send_embedded_message(
|
433
|
-
description: "#{TEAM_NAMES[winning_team_no]} wins game ##{id}. `!choose` again. [Ratings](
|
433
|
+
description: "#{TEAM_NAMES[winning_team_no]} wins game ##{id}. `!choose` again. [Ratings](#{discord_channel_leaderboard_url(e.channel.id)})",
|
434
434
|
channel: e.channel
|
435
435
|
)
|
436
436
|
end
|
@@ -498,7 +498,7 @@ class QwtfDiscordBotPug # :nodoc:
|
|
498
498
|
).body
|
499
499
|
|
500
500
|
send_embedded_message(
|
501
|
-
description: "Match ##{id} drawn. `!choose` again. [Ratings](
|
501
|
+
description: "Match ##{id} drawn. `!choose` again. [Ratings](#{discord_channel_leaderboard_url(e.channel.id)})",
|
502
502
|
channel: e.channel
|
503
503
|
)
|
504
504
|
end
|
@@ -694,7 +694,10 @@ class QwtfDiscordBotPug # :nodoc:
|
|
694
694
|
channel: event.channel
|
695
695
|
)
|
696
696
|
|
697
|
-
combinations = get_fair_teams(
|
697
|
+
combinations = get_fair_teams(
|
698
|
+
channel_id: event.channel.id, players: pug.joined_players
|
699
|
+
)
|
700
|
+
|
698
701
|
teams = combinations[iteration]
|
699
702
|
|
700
703
|
if !teams
|
@@ -814,7 +817,7 @@ class QwtfDiscordBotPug # :nodoc:
|
|
814
817
|
end
|
815
818
|
|
816
819
|
def post_results(json)
|
817
|
-
uri = URI(
|
820
|
+
uri = URI([ENV['RATINGS_API_URL'], 'matches'].join('/'))
|
818
821
|
req = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')
|
819
822
|
req.body = json
|
820
823
|
|
@@ -823,9 +826,9 @@ class QwtfDiscordBotPug # :nodoc:
|
|
823
826
|
end
|
824
827
|
end
|
825
828
|
|
826
|
-
def get_fair_teams(players)
|
827
|
-
uri = URI(
|
828
|
-
params = { 'players[]' => players }
|
829
|
+
def get_fair_teams(channel_id:, players:)
|
830
|
+
uri = URI([ENV['RATINGS_API_URL'], 'fair_teams', 'new'].join('/'))
|
831
|
+
params = { :channel_id => channel_id, 'players[]' => players }
|
829
832
|
uri.query = URI.encode_www_form(params)
|
830
833
|
req = Net::HTTP::Get.new(uri)
|
831
834
|
|
@@ -839,4 +842,8 @@ class QwtfDiscordBotPug # :nodoc:
|
|
839
842
|
def ten_minutes_ago
|
840
843
|
Time.now.to_i - TEN_MINUTES
|
841
844
|
end
|
845
|
+
|
846
|
+
def discord_channel_leaderboard_url(channel_id)
|
847
|
+
[ENV['RATINGS_APP_URL'], "discord_channels", channel_id].join('/')
|
848
|
+
end
|
842
849
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qwtf_discord_bot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 6.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sheldon Johnson
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-03-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: discordrb
|