qwtf_discord_bot 5.3.7 → 5.4.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: 4ac8fe73d3dd003dd07f87fdfcbdafd11641af03cbebacb1181b3fa0f579bc45
4
- data.tar.gz: e8a954d514218d8817ee9f2c6dbebf081e6d2e6138c20c953d086db2f3ed8297
3
+ metadata.gz: 483a4220fb3dd783224fad769534ecb77812428dfb75dd070ce5a2299d50a6c0
4
+ data.tar.gz: 7fb143e346b0afa23f0af56d1282309d560855c41d302016514e434f01839445
5
5
  SHA512:
6
- metadata.gz: 562a7b2393565703a390938a2da2468af526cb239349472eaa93f69f31d6d00d1a5eb6f389cb949e181615ce56786d96fe96d220acc60d10cc1afffa9401ca86
7
- data.tar.gz: 7f8e88bf439e2d8faeea68440549ea09e0519e4607ff2899d5c7ae5deff6d9bd29ede1dae0c55d219966518ffcdf25f2c71adf9ea992ac54c7e68838366fc273
6
+ metadata.gz: 75f5981bfa1c28dea2d79011de86ac2bf5610ae7791e147b85fb1f1819d2a332098b06695d689944d400880ac8d54469f2a153508310613d5a1ea1125b790d6e
7
+ data.tar.gz: def0724c06d819f0ffcdf49f2447562c261d48b0d2875c091df9b4f47500af28411b9aa62e62f924d1a57f1f71d3345b8634ba65d8935f64a5ca591335f60383
data/VERSION CHANGED
@@ -1 +1 @@
1
- 5.3.7
1
+ 5.4.0
@@ -386,6 +386,16 @@ class QwtfDiscordBotPug # :nodoc:
386
386
  end
387
387
 
388
388
  def start_pug(pug, event)
389
+ if !pug.actual_teams.any?
390
+ teams = get_fair_teams(pug.joined_players)
391
+
392
+ teams.each do |team_no, player_ids|
393
+ player_ids.each do |player_id|
394
+ pug.join_team(team_no: team_no, player_id: player_id)
395
+ end
396
+ end
397
+ end
398
+
389
399
  pug_teams = pug.teams.map do |team_no, player_ids|
390
400
  team_mentions = player_ids.map do |player_id|
391
401
  event.mention_for(player_id)
@@ -452,4 +462,15 @@ class QwtfDiscordBotPug # :nodoc:
452
462
  http.request(req)
453
463
  end
454
464
  end
465
+
466
+ def get_fair_teams(players)
467
+ uri = URI("#{ENV['RATINGS_API_URL']}fair_teams/new")
468
+ params = { 'players[]' => players }
469
+ uri.query = URI.encode_www_form(params)
470
+ req = Net::HTTP::Get.new(uri)
471
+ res = Net::HTTP.start(uri.hostname, uri.port) do |http|
472
+ http.request(req)
473
+ end
474
+ JSON.parse(res.body).first.to_h
475
+ end
455
476
  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: 5.3.7
4
+ version: 5.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sheldon Johnson
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-10-11 00:00:00.000000000 Z
11
+ date: 2020-10-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: discordrb