qwtf_discord_bot 6.2.0 → 6.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.env.example +2 -2
- data/Gemfile.lock +1 -1
- data/VERSION +1 -1
- data/docker-compose.yml +3 -3
- data/lib/qwtf_discord_bot/qwtf_discord_bot_pug.rb +30 -43
- 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: 830dfa1fe17a37277449dc28e03d087e19549ac32ef73c89a3ac21ec1f9df8f0
|
4
|
+
data.tar.gz: e7ff2a206436df599927ceee87d5f6e6e25015d671325c2c7fb5ed943a36d9db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8adc188312e8ffa68713eaa010d29774ddb10ec3a82f3f2bb81f5f8871cb8cf39ab8c35f2d45b4c581c7efacba4c749b40660b33ac5978c864bf6446e0b03cde
|
7
|
+
data.tar.gz: be5af4763b77e9f94f4fd27f9a40bbc36750ffe1f13883979fa150d6bdb65fd2539b4b6d095887b6d2a50dc83fa7f476b377290d7a87dfd3e44301a5525cc214
|
data/.env.example
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
export
|
2
|
-
export
|
1
|
+
export RESULTS_API_URL="https://fortressone.org/results/api/v1"
|
2
|
+
export RESULTS_APP_URL="https://fortressone.org/results"
|
data/Gemfile.lock
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
6.
|
1
|
+
6.3.1
|
data/docker-compose.yml
CHANGED
@@ -34,8 +34,8 @@ services:
|
|
34
34
|
- redis
|
35
35
|
environment:
|
36
36
|
- REDIS_URL=redis://redis
|
37
|
-
-
|
38
|
-
-
|
37
|
+
- RESULTS_API_URL
|
38
|
+
- RESULTS_APP_URL
|
39
39
|
volumes:
|
40
40
|
- type: bind
|
41
41
|
source: "/home/ubuntu/.config/qwtf_discord_bot/config.yaml"
|
@@ -48,7 +48,7 @@ services:
|
|
48
48
|
- redis
|
49
49
|
environment:
|
50
50
|
- REDIS_URL=redis://redis
|
51
|
-
-
|
51
|
+
- RESULTS_API_URL
|
52
52
|
volumes:
|
53
53
|
- type: bind
|
54
54
|
source: "/home/ubuntu/.config/qwtf_discord_bot/config.yaml"
|
@@ -117,7 +117,6 @@ class QwtfDiscordBotPug # :nodoc:
|
|
117
117
|
pug.maxplayers
|
118
118
|
].join("/")
|
119
119
|
|
120
|
-
|
121
120
|
send_embedded_message(
|
122
121
|
message: message,
|
123
122
|
description: [errors, description.join(MSG_SNIPPET_DELIMITER)].join("\n"),
|
@@ -825,7 +824,23 @@ class QwtfDiscordBotPug # :nodoc:
|
|
825
824
|
) && nil
|
826
825
|
end
|
827
826
|
else
|
828
|
-
|
827
|
+
weighted_combinations = combinations.map.with_index do |combination, index|
|
828
|
+
{ weight: 1/(index+1.0), combination: combination }
|
829
|
+
end
|
830
|
+
|
831
|
+
total = weighted_combinations.inject(0) do |sum, wt|
|
832
|
+
sum + wt[:weight]
|
833
|
+
end
|
834
|
+
|
835
|
+
chosen_weighted_team_index = rand(0..total)
|
836
|
+
counter = 0.0
|
837
|
+
|
838
|
+
weighted_combination = weighted_combinations.find do |wt|
|
839
|
+
counter += wt[:weight]
|
840
|
+
chosen_weighted_team_index <= counter
|
841
|
+
end
|
842
|
+
|
843
|
+
teams = weighted_combination[:combination]
|
829
844
|
end
|
830
845
|
|
831
846
|
pug.destroy_teams
|
@@ -881,49 +896,17 @@ class QwtfDiscordBotPug # :nodoc:
|
|
881
896
|
end
|
882
897
|
|
883
898
|
def start_pug(pug, event)
|
884
|
-
footer = [
|
885
|
-
pug.game_map,
|
886
|
-
"#{pug.player_slots} joined",
|
887
|
-
].compact.join(MSG_SNIPPET_DELIMITER)
|
888
|
-
|
889
899
|
mentions = pug.players.map do |player_id|
|
890
900
|
event.mention_for(player_id)
|
891
901
|
end
|
892
902
|
|
893
|
-
mention_line =
|
903
|
+
mention_line = mentions.join(" ")
|
894
904
|
|
895
905
|
send_embedded_message(
|
896
906
|
message: mention_line,
|
897
|
-
channel: event.channel
|
898
|
-
|
899
|
-
|
900
|
-
text: footer
|
901
|
-
)
|
902
|
-
|
903
|
-
if pug.queued_players.any?
|
904
|
-
queue_display_names = pug.queued_players.map do |player_id|
|
905
|
-
event.display_name_for(player_id)
|
906
|
-
end
|
907
|
-
|
908
|
-
embed.add_field(
|
909
|
-
inline: true,
|
910
|
-
name: "Queue",
|
911
|
-
value: queue_display_names.join("\n")
|
912
|
-
)
|
913
|
-
end
|
914
|
-
|
915
|
-
pug.teams.each do |team_no, player_ids|
|
916
|
-
team_mentions = player_ids.map do |player_id|
|
917
|
-
event.display_name_for(player_id)
|
918
|
-
end
|
919
|
-
|
920
|
-
embed.add_field(
|
921
|
-
inline: true,
|
922
|
-
name: team_name(team_no),
|
923
|
-
value: team_mentions.join("\n")
|
924
|
-
)
|
925
|
-
end
|
926
|
-
end
|
907
|
+
channel: event.channel,
|
908
|
+
description: "Time to play. `!choose`, `!shuffle` or `!team` up."
|
909
|
+
)
|
927
910
|
end
|
928
911
|
|
929
912
|
def end_pug(pug, channel_id)
|
@@ -961,22 +944,26 @@ class QwtfDiscordBotPug # :nodoc:
|
|
961
944
|
end
|
962
945
|
|
963
946
|
def post_results(json)
|
964
|
-
uri = URI([ENV['
|
947
|
+
uri = URI([ENV['RESULTS_API_URL'], 'matches'].join('/'))
|
965
948
|
req = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')
|
966
949
|
req.body = json
|
967
950
|
|
968
|
-
|
951
|
+
is_https = uri.scheme == "https"
|
952
|
+
|
953
|
+
Net::HTTP.start(uri.hostname, uri.port, use_ssl: is_https) do |http|
|
969
954
|
http.request(req)
|
970
955
|
end
|
971
956
|
end
|
972
957
|
|
973
958
|
def get_fair_teams(channel_id:, players:)
|
974
|
-
uri = URI([ENV['
|
959
|
+
uri = URI([ENV['RESULTS_API_URL'], 'fair_teams', 'new'].join('/'))
|
975
960
|
params = { :channel_id => channel_id, 'players[]' => players }
|
976
961
|
uri.query = URI.encode_www_form(params)
|
977
962
|
req = Net::HTTP::Get.new(uri)
|
978
963
|
|
979
|
-
|
964
|
+
is_https = uri.scheme == "https"
|
965
|
+
|
966
|
+
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: is_https) do |http|
|
980
967
|
http.request(req)
|
981
968
|
end
|
982
969
|
|
@@ -988,6 +975,6 @@ class QwtfDiscordBotPug # :nodoc:
|
|
988
975
|
end
|
989
976
|
|
990
977
|
def discord_channel_leaderboard_url(channel_id)
|
991
|
-
[ENV['
|
978
|
+
[ENV['RESULTS_APP_URL'], "discord_channels", channel_id].join('/')
|
992
979
|
end
|
993
980
|
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: 6.
|
4
|
+
version: 6.3.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-09-
|
11
|
+
date: 2021-09-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: discordrb
|