qwtf_discord_bot 5.5.24 → 6.0.3
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/qstat_request.rb +32 -29
- data/lib/qwtf_discord_bot/qwtf_discord_bot_pug.rb +14 -15
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 151d77adaf69b8f02ce8cba749eee97bdc6927956169d673d72917563bb07b91
|
4
|
+
data.tar.gz: 781ddacc6d1f792df33553581cdc9a00f583872de3ed6f4581f2024fab7a83bd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b034cd067bc60caaa168f175debfb55f607416a7b7a4efd37f9a0e00b49a693a9722d021989fd3518c8e56134ada4379c9273106fac0a0d8083d493f01d040ec
|
7
|
+
data.tar.gz: 74436d2a147f42297fa21f7e20429c8e902bda52535089a6dd8f97ac452686d19ff78702ee413efc69c4f2e1248691456de78c84ba779e79819a04bb077d1363
|
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.3
|
data/docker-compose.yml
CHANGED
data/lib/qstat_request.rb
CHANGED
@@ -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
|
@@ -73,7 +73,6 @@ class QwtfDiscordBotPug # :nodoc:
|
|
73
73
|
0
|
74
74
|
end
|
75
75
|
|
76
|
-
|
77
76
|
message_obj = choose_fair_teams(pug: pug, event: e, iteration: iteration)
|
78
77
|
status(pug: pug, event: e, message_obj: message_obj) if message_obj
|
79
78
|
end
|
@@ -247,13 +246,6 @@ class QwtfDiscordBotPug # :nodoc:
|
|
247
246
|
)
|
248
247
|
end
|
249
248
|
|
250
|
-
if pug.team(team_no).size >= pug.teamsize
|
251
|
-
return send_embedded_message(
|
252
|
-
description: "Team is full",
|
253
|
-
channel: e.channel
|
254
|
-
)
|
255
|
-
end
|
256
|
-
|
257
249
|
pug.join_team(team_no: team_no, player_id: user_id)
|
258
250
|
|
259
251
|
send_embedded_message(
|
@@ -430,7 +422,7 @@ class QwtfDiscordBotPug # :nodoc:
|
|
430
422
|
).body
|
431
423
|
|
432
424
|
send_embedded_message(
|
433
|
-
description: "#{TEAM_NAMES[winning_team_no]} wins game ##{id}. `!choose` again. [Ratings](
|
425
|
+
description: "#{TEAM_NAMES[winning_team_no]} wins game ##{id}. `!choose` again. [Ratings](#{discord_channel_leaderboard_url(e.channel.id)})",
|
434
426
|
channel: e.channel
|
435
427
|
)
|
436
428
|
end
|
@@ -498,7 +490,7 @@ class QwtfDiscordBotPug # :nodoc:
|
|
498
490
|
).body
|
499
491
|
|
500
492
|
send_embedded_message(
|
501
|
-
description: "Match ##{id} drawn. `!choose` again. [Ratings](
|
493
|
+
description: "Match ##{id} drawn. `!choose` again. [Ratings](#{discord_channel_leaderboard_url(e.channel.id)})",
|
502
494
|
channel: e.channel
|
503
495
|
)
|
504
496
|
end
|
@@ -694,7 +686,10 @@ class QwtfDiscordBotPug # :nodoc:
|
|
694
686
|
channel: event.channel
|
695
687
|
)
|
696
688
|
|
697
|
-
combinations = get_fair_teams(
|
689
|
+
combinations = get_fair_teams(
|
690
|
+
channel_id: event.channel.id, players: pug.joined_players
|
691
|
+
)
|
692
|
+
|
698
693
|
teams = combinations[iteration]
|
699
694
|
|
700
695
|
if !teams
|
@@ -814,7 +809,7 @@ class QwtfDiscordBotPug # :nodoc:
|
|
814
809
|
end
|
815
810
|
|
816
811
|
def post_results(json)
|
817
|
-
uri = URI(
|
812
|
+
uri = URI([ENV['RATINGS_API_URL'], 'matches'].join('/'))
|
818
813
|
req = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')
|
819
814
|
req.body = json
|
820
815
|
|
@@ -823,9 +818,9 @@ class QwtfDiscordBotPug # :nodoc:
|
|
823
818
|
end
|
824
819
|
end
|
825
820
|
|
826
|
-
def get_fair_teams(players)
|
827
|
-
uri = URI(
|
828
|
-
params = { 'players[]' => players }
|
821
|
+
def get_fair_teams(channel_id:, players:)
|
822
|
+
uri = URI([ENV['RATINGS_API_URL'], 'fair_teams', 'new'].join('/'))
|
823
|
+
params = { :channel_id => channel_id, 'players[]' => players }
|
829
824
|
uri.query = URI.encode_www_form(params)
|
830
825
|
req = Net::HTTP::Get.new(uri)
|
831
826
|
|
@@ -839,4 +834,8 @@ class QwtfDiscordBotPug # :nodoc:
|
|
839
834
|
def ten_minutes_ago
|
840
835
|
Time.now.to_i - TEN_MINUTES
|
841
836
|
end
|
837
|
+
|
838
|
+
def discord_channel_leaderboard_url(channel_id)
|
839
|
+
[ENV['RATINGS_APP_URL'], "discord_channels", channel_id].join('/')
|
840
|
+
end
|
842
841
|
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.3
|
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-05-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: discordrb
|
@@ -61,6 +61,7 @@ extensions: []
|
|
61
61
|
extra_rdoc_files: []
|
62
62
|
files:
|
63
63
|
- ".dockerignore"
|
64
|
+
- ".env.example"
|
64
65
|
- ".gitignore"
|
65
66
|
- ".rspec"
|
66
67
|
- ".travis.yml"
|