qwtf_discord_bot 6.1.5 → 6.3.0

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: b502dce9e5188d2ac6cb3695ff9f9af13953fc8ad97b3d7aaafaa8802df788c1
4
- data.tar.gz: 0fa775500df5d9cf58f05600a89a82ff09a6764d1cdf9f9bbd5a0f22a3486dbd
3
+ metadata.gz: 5080bf7689a79bfcaf97063a08ccf320ae2f0e4ecac5893942fdbd5ad57c30e1
4
+ data.tar.gz: ece59c6ebdd427edcf5696869253a28f9e0f9314b81acc6f30dfc5c03fc54ee2
5
5
  SHA512:
6
- metadata.gz: 4e4e48deace1b6f3565de55f1da7ccc611198bfe1ed231161948c801a6d4b9b592ffa0163a523b473dcb10199b6f34fab74b022fe3898ffdad7c6b4c1a42da4f
7
- data.tar.gz: eedf346d74132c50aa36b37caa40f82e140e6bcaa28e5dac980a07312d56f9c20d5fd937fb95db2ea8218a74702585bdeb30ce141e11d0f67e3ebbae8d106128
6
+ metadata.gz: ece71fc54296e11cb5fff3a25be24d279822aaebd4220fa88ab9e0fa15dc3c55eb53b9bc4dd786f783f59a9f280ef72553bafc74b111bb06b435c0cd8048e84d
7
+ data.tar.gz: 11ba983d2cc5d68098c6cadfda0ec45f9e94b8d8b956b4e5ee67f0a0cfb74c3be4cc1f597a11a8cb5e5b6c00a7cd39282e5518647789151754ee394ae5ff3e9e
data/.env.example CHANGED
@@ -1,2 +1,2 @@
1
- export RATINGS_API_URL=http://ratings.fortressone.org/api/v1
2
- export RATINGS_APP_URL=http://ratings.fortressone.org
1
+ export RESULTS_API_URL="https://fortressone.org/results/api/v1"
2
+ export RESULTS_APP_URL="https://fortressone.org/results"
data/Gemfile CHANGED
@@ -6,9 +6,11 @@ gem 'bundler'
6
6
  gem 'discordrb', '3.4.0'
7
7
  gem 'redis'
8
8
  gem 'thor'
9
+ gem 'activesupport'
9
10
 
10
11
  group :development do
11
12
  gem 'pry'
13
+ gem 'dotenv'
12
14
  end
13
15
 
14
16
  group :test do
data/Gemfile.lock CHANGED
@@ -1,7 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- qwtf_discord_bot (6.1.4)
4
+ qwtf_discord_bot (6.3.0)
5
+ activesupport (~> 6.1)
5
6
  discordrb (= 3.4.0)
6
7
  redis (~> 4.2)
7
8
  thor (~> 1.1)
@@ -28,6 +29,7 @@ GEM
28
29
  rest-client (>= 2.1.0.rc1)
29
30
  domain_name (0.5.20190701)
30
31
  unf (>= 0.0.5, < 1.0.0)
32
+ dotenv (2.7.6)
31
33
  event_emitter (0.2.6)
32
34
  factory_bot (6.1.0)
33
35
  activesupport (>= 5.0.0)
@@ -83,8 +85,10 @@ PLATFORMS
83
85
  x86_64-linux
84
86
 
85
87
  DEPENDENCIES
88
+ activesupport
86
89
  bundler
87
90
  discordrb (= 3.4.0)
91
+ dotenv
88
92
  factory_bot
89
93
  pry
90
94
  qwtf_discord_bot!
data/README.md CHANGED
@@ -105,6 +105,7 @@ This responds to discord messages:
105
105
  - `!maps`
106
106
  - `!map [map_name]`
107
107
  - `!choose [n]`
108
+ - `!shuffle`
108
109
  - `!win <team_no>`
109
110
  - `!draw`
110
111
  - `!notify <@role>`
data/VERSION CHANGED
@@ -1 +1 @@
1
- 6.1.5
1
+ 6.3.0
data/docker-compose.yml CHANGED
@@ -34,8 +34,8 @@ services:
34
34
  - redis
35
35
  environment:
36
36
  - REDIS_URL=redis://redis
37
- - RATINGS_API_URL
38
- - RATINGS_APP_URL
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
- - RATINGS_API_URL
51
+ - RESULTS_API_URL
52
52
  volumes:
53
53
  - type: bind
54
54
  source: "/home/ubuntu/.config/qwtf_discord_bot/config.yaml"
data/exe/qwtf_discord_bot CHANGED
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ require 'dotenv/load'
3
4
  require 'qwtf_discord_bot'
4
5
  require 'thor'
5
6
  require 'pry'
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'pug'
4
4
  require 'event_decorator'
5
+ require 'active_support/core_ext/array/conversions'
5
6
 
6
7
  class QwtfDiscordBotPug # :nodoc:
7
8
  include QwtfDiscordBot
@@ -11,6 +12,28 @@ class QwtfDiscordBotPug # :nodoc:
11
12
  TEN_MINUTES = 10 * 60
12
13
  VALID_MENTION = /<@!?\d+>/
13
14
 
15
+ COMMANDS = <<~MESSAGE
16
+ `!status` Shows who has joined
17
+ `!join [@player1] [@player2]` Join PUG. Can also join other players
18
+ `!leave` Leave PUG
19
+ `!kick <@player> [@player2]` Kick one or more other players
20
+ `!team <team_no> [@player1] [@player2]` Join team
21
+ `!unteam [@player1] [@player2]` Leave team and go to front of queue
22
+ `!choose [n]` Choose fair teams. Pass number for nth fairest team
23
+ `!shuffle` Choose random teams.
24
+ `!win <team_no>` Report winning team
25
+ `!draw` Report draw
26
+ `!end` End PUG. Kicks all players
27
+ `!teamsize <no_of_players>` Set number of players in a team
28
+ `!addmap <map_name>` Add map to map list
29
+ `!removemap <map_name>` Remove map from map list
30
+ `!maps` Show map list
31
+ `!map [map_name]` Show or set map
32
+ `!notify <@role>` Set @role for alerts
33
+ MESSAGE
34
+
35
+ HELP = { commands: COMMANDS, footer: "!command <required> [optional]" }
36
+
14
37
  def run
15
38
  bot = Discordrb::Commands::CommandBot.new(
16
39
  token: QwtfDiscordBot.config.token,
@@ -28,19 +51,79 @@ class QwtfDiscordBotPug # :nodoc:
28
51
  )
29
52
 
30
53
  bot.command :help do |event, *args|
31
- "Pug commands: `!status`, `!join`, `!team <team_no> [@player1] [@player2]`, `!unteam`, `!leave`, `!kick <@player>`, `!win <team_no>`, `!draw`, `!end`, `!teamsize <no_of_players>`, `!addmap <map_name>`, `!removemap <map_name>`, `!maps`, `!map [map_name]`, `!choose [n]`, `!notify <@role>`"
54
+ send_embedded_message(
55
+ description: HELP[:commands],
56
+ channel: event.channel
57
+ ) do |embed|
58
+ embed.footer = Discordrb::Webhooks::EmbedFooter.new(
59
+ text: HELP[:footer]
60
+ )
61
+ end
32
62
  end
33
63
 
34
64
  bot.command :join do |event, *args|
35
65
  setup_pug(event) do |e, pug|
36
- if pug.joined?(e.user_id)
37
- return send_embedded_message(
38
- description: "You've already joined",
66
+ if args.empty?
67
+ if pug.joined?(e.user_id)
68
+ return send_embedded_message(
69
+ description: "You've already joined",
70
+ channel: e.channel
71
+ )
72
+ end
73
+
74
+ join_pug(e, pug)
75
+ else
76
+ errors = []
77
+ joiners = []
78
+
79
+ args.each do |mention|
80
+ if !mention.match(VALID_MENTION)
81
+ errors << "#{mention} isn't a valid mention"
82
+ next
83
+ end
84
+
85
+ user_id = mention_to_user_id(mention)
86
+ display_name = e.display_name_for(user_id) || mention
87
+
88
+ if pug.joined?(user_id)
89
+ errors << "#{display_name} is already in this PUG"
90
+ next
91
+ end
92
+
93
+ pug.join(user_id)
94
+ joiners << display_name
95
+ end
96
+
97
+ message = ""
98
+ description = []
99
+
100
+ if pug.total_player_count == 0
101
+ message = "#{pug.notify_roles} PUG started"
102
+ description << "#{e.display_name} creates a PUG"
103
+ elsif pug.slots_left.between?(1, 3)
104
+ message = "#{pug.slots_left} more #{pug.notify_roles}"
105
+ end
106
+
107
+ if joiners.any?
108
+ description << [
109
+ joiners.to_sentence,
110
+ joiners.count == 1 ? "joins" : "join",
111
+ "the PUG"
112
+ ].join(" ")
113
+ end
114
+
115
+ description << [
116
+ pug.total_player_count,
117
+ pug.maxplayers
118
+ ].join("/")
119
+
120
+ send_embedded_message(
121
+ message: message,
122
+ description: [errors, description.join(MSG_SNIPPET_DELIMITER)].join("\n"),
39
123
  channel: e.channel
40
124
  )
41
125
  end
42
126
 
43
- join_pug(e, pug)
44
127
  start_pug(pug, e) if pug.has_exactly_maxplayers?
45
128
  end
46
129
  end
@@ -67,7 +150,21 @@ class QwtfDiscordBotPug # :nodoc:
67
150
  0
68
151
  end
69
152
 
70
- message_obj = choose_fair_teams(pug: pug, event: e, iteration: iteration)
153
+ message_obj = choose_teams(pug: pug, event: e, iteration: iteration)
154
+ status(pug: pug, event: e, message_obj: message_obj) if message_obj
155
+ end
156
+ end
157
+
158
+ bot.command :shuffle do |event|
159
+ setup_pug(event) do |e, pug|
160
+ if !pug.full?
161
+ return send_embedded_message(
162
+ description: "Not enough players, reduce !teamsize",
163
+ channel: event.channel
164
+ )
165
+ end
166
+
167
+ message_obj = choose_teams(pug: pug, event: e)
71
168
  status(pug: pug, event: e, message_obj: message_obj) if message_obj
72
169
  end
73
170
  end
@@ -171,12 +268,12 @@ class QwtfDiscordBotPug # :nodoc:
171
268
  )
172
269
  end
173
270
 
271
+ errors = []
272
+ kickees = []
273
+
174
274
  args.each do |mention|
175
- unless mention.match(VALID_MENTION)
176
- send_embedded_message(
177
- description: "#{mention} isn't a valid mention",
178
- channel: e.channel
179
- )
275
+ if !mention.match(VALID_MENTION)
276
+ errors << "#{mention} isn't a valid mention"
180
277
  next
181
278
  end
182
279
 
@@ -184,43 +281,57 @@ class QwtfDiscordBotPug # :nodoc:
184
281
  display_name = e.display_name_for(user_id) || mention
185
282
 
186
283
  unless pug.joined?(user_id)
187
- send_embedded_message(
188
- description: "#{display_name} isn't in the PUG",
189
- channel: e.channel
190
- )
284
+ errors << "#{display_name} isn't in the PUG"
191
285
  next
192
286
  end
193
287
 
194
288
  pug.leave(user_id)
195
289
 
196
- snippets = [
197
- "#{display_name} is kicked from the PUG",
198
- "#{pug.player_slots} remain"
199
- ]
290
+ kickees << display_name
291
+ end
200
292
 
201
- message = "#{pug.slots_left} more #{pug.notify_roles}" if pug.slots_left == 1
293
+ message = ""
294
+ description = []
202
295
 
203
- send_embedded_message(
204
- message: message,
205
- description: snippets.join(MSG_SNIPPET_DELIMITER),
206
- channel: e.channel
207
- )
296
+ if pug.slots_left == 1
297
+ message = "#{pug.slots_left} more #{pug.notify_roles}"
298
+ end
208
299
 
209
- break end_pug(pug, e.channel) if pug.empty?
300
+ if kickees.any?
301
+ description << [
302
+ kickees.to_sentence,
303
+ kickees.count == 1 ? "is" : "are",
304
+ "kicked from the PUG"
305
+ ].join(" ")
210
306
  end
307
+
308
+ description << [
309
+ [pug.total_player_count, pug.maxplayers].join("/"),
310
+ "remain"
311
+ ].join(" ")
312
+
313
+ description = [errors, description.join(MSG_SNIPPET_DELIMITER)].join("\n")
314
+
315
+ send_embedded_message(
316
+ message: message,
317
+ description: description,
318
+ channel: e.channel
319
+ )
320
+
321
+ end_pug(pug, e.channel) if pug.empty?
211
322
  end
212
323
  end
213
324
 
214
325
  bot.command :team do |event, *args|
215
326
  setup_pug(event) do |e, pug|
216
- unless args.any?
327
+ if args.empty?
217
328
  return send_embedded_message(
218
329
  description: "Which team? E.G. `!team 1`",
219
330
  channel: e.channel
220
331
  )
221
332
  end
222
333
 
223
- unless ["1", "2"].any?(args.first)
334
+ if ["1", "2"].none?(args.first)
224
335
  return send_embedded_message(
225
336
  description: "Choose `!team 1`, `!team 2`, or `!unteam` to leave team",
226
337
  channel: e.channel
@@ -250,12 +361,12 @@ class QwtfDiscordBotPug # :nodoc:
250
361
  channel: e.channel
251
362
  )
252
363
  else
364
+ errors = []
365
+ teamers = []
366
+
253
367
  args[1..-1].each do |mention|
254
- unless mention.match(VALID_MENTION)
255
- send_embedded_message(
256
- description: "#{mention} isn't a valid mention",
257
- channel: e.channel
258
- )
368
+ if !mention.match(VALID_MENTION)
369
+ errors << "#{mention} isn't a valid mention"
259
370
  next
260
371
  end
261
372
 
@@ -263,14 +374,25 @@ class QwtfDiscordBotPug # :nodoc:
263
374
  display_name = e.display_name_for(user_id) || mention
264
375
  pug.join_team(team_no: team_no, player_id: user_id)
265
376
 
266
- send_embedded_message(
267
- description: [
268
- "#{display_name} joins #{TEAM_NAMES[team_no]}",
269
- "#{pug.team_player_count(team_no)}/#{pug.teamsize}"
270
- ].join(MSG_SNIPPET_DELIMITER),
271
- channel: e.channel
272
- )
377
+ teamers << display_name
273
378
  end
379
+
380
+ description = errors << [
381
+ [
382
+ teamers.to_sentence,
383
+ teamers.count == 1 ? "joins" : "join",
384
+ TEAM_NAMES[team_no]
385
+ ].join(" "),
386
+ [
387
+ pug.team_player_count(team_no),
388
+ pug.teamsize
389
+ ].join("/")
390
+ ].join(MSG_SNIPPET_DELIMITER)
391
+
392
+ send_embedded_message(
393
+ description: description.join("\n"),
394
+ channel: e.channel
395
+ )
274
396
  end
275
397
 
276
398
  start_pug(pug, e) if !pug_already_full && pug.has_exactly_maxplayers?
@@ -281,7 +403,7 @@ class QwtfDiscordBotPug # :nodoc:
281
403
  setup_pug(event) do |e, pug|
282
404
  user_id = e.user_id
283
405
 
284
- unless pug.active?
406
+ if !pug.active?
285
407
  return send_embedded_message(
286
408
  description: 'No PUG has been started. `!join` to create',
287
409
  channel: e.channel
@@ -289,7 +411,7 @@ class QwtfDiscordBotPug # :nodoc:
289
411
  end
290
412
 
291
413
  if args.empty?
292
- unless pug.joined?(user_id)
414
+ if !pug.joined?(user_id)
293
415
  return send_embedded_message(
294
416
  description: "You aren't in this PUG",
295
417
  channel: e.channel
@@ -310,32 +432,38 @@ class QwtfDiscordBotPug # :nodoc:
310
432
  channel: e.channel
311
433
  )
312
434
  else
435
+ errors = []
436
+ unteamers = []
437
+
313
438
  args.each do |mention|
314
- unless mention.match(VALID_MENTION)
315
- send_embedded_message(
316
- description: "#{mention} isn't a valid mention",
317
- channel: e.channel
318
- )
439
+ if !mention.match(VALID_MENTION)
440
+ errors << "#{mention} isn't a valid mention"
319
441
  next
320
442
  end
321
443
 
322
444
  user_id = mention_to_user_id(mention)
323
445
  display_name = e.display_name_for(user_id) || mention
324
446
 
325
- unless pug.joined?(user_id)
326
- return send_embedded_message(
327
- description: "#{display_name} isn't in this PUG",
328
- channel: e.channel
329
- )
447
+ if !pug.joined?(user_id)
448
+ errors << "#{display_name} isn't in this PUG"
449
+ next
330
450
  end
331
451
 
332
452
  pug.unteam(user_id)
333
453
 
334
- send_embedded_message(
335
- description: "#{display_name} leaves team",
336
- channel: e.channel
337
- )
454
+ unteamers << display_name
338
455
  end
456
+
457
+ description = errors << [
458
+ unteamers.to_sentence,
459
+ unteamers.count == 1 ? "goes" : "go",
460
+ "into the queue"
461
+ ].join(" ")
462
+
463
+ send_embedded_message(
464
+ description: description.join("\n"),
465
+ channel: e.channel
466
+ )
339
467
  end
340
468
  end
341
469
  end
@@ -417,7 +545,7 @@ class QwtfDiscordBotPug # :nodoc:
417
545
  ).body
418
546
 
419
547
  send_embedded_message(
420
- description: "#{TEAM_NAMES[winning_team_no]} wins game ##{id}. `!choose` again. [Ratings](#{discord_channel_leaderboard_url(e.channel.id)})",
548
+ description: "#{TEAM_NAMES[winning_team_no]} wins game ##{id}. `!choose` again. [Results](#{discord_channel_leaderboard_url(e.channel.id)})",
421
549
  channel: e.channel
422
550
  )
423
551
  end
@@ -485,7 +613,7 @@ class QwtfDiscordBotPug # :nodoc:
485
613
  ).body
486
614
 
487
615
  send_embedded_message(
488
- description: "Match ##{id} drawn. `!choose` again. [Ratings](#{discord_channel_leaderboard_url(e.channel.id)})",
616
+ description: "Match ##{id} drawn. `!choose` again. [Results](#{discord_channel_leaderboard_url(e.channel.id)})",
489
617
  channel: e.channel
490
618
  )
491
619
  end
@@ -640,7 +768,7 @@ class QwtfDiscordBotPug # :nodoc:
640
768
  end
641
769
 
642
770
  def mention_to_user_id(mention)
643
- mention[3..-2].to_i
771
+ mention[/\d+/].to_i
644
772
  end
645
773
 
646
774
  def join_pug(e, pug)
@@ -648,7 +776,7 @@ class QwtfDiscordBotPug # :nodoc:
648
776
 
649
777
  if pug.total_player_count == 1
650
778
  snippets = ["#{e.display_name} creates a PUG", "#{pug.player_slots} joined"]
651
- message = pug.notify_roles
779
+ message = "#{pug.notify_roles} PUG started"
652
780
  else
653
781
  snippets = ["#{e.display_name} joins the PUG", "#{pug.player_slots} joined"]
654
782
  message = "#{pug.slots_left} more #{pug.notify_roles}" if pug.slots_left.between?(1, 3)
@@ -668,7 +796,7 @@ class QwtfDiscordBotPug # :nodoc:
668
796
  nil # stop discordrb printing return value
669
797
  end
670
798
 
671
- def choose_fair_teams(pug:, event:, iteration: 0)
799
+ def choose_teams(pug:, event:, iteration: nil)
672
800
  if !pug.full?
673
801
  return send_embedded_message(
674
802
  description: "Not enough players, reduce !teamsize",
@@ -677,7 +805,7 @@ class QwtfDiscordBotPug # :nodoc:
677
805
  end
678
806
 
679
807
  message_obj = send_embedded_message(
680
- description: "Choosing fair teams...",
808
+ description: "Choosing teams...",
681
809
  channel: event.channel
682
810
  )
683
811
 
@@ -685,14 +813,34 @@ class QwtfDiscordBotPug # :nodoc:
685
813
  channel_id: event.channel.id, players: pug.up_now_players
686
814
  )
687
815
 
688
- teams = combinations[iteration]
816
+ if iteration
817
+ teams = combinations[iteration]
689
818
 
690
- if !teams
691
- return send_embedded_message(
692
- description: "There are only #{combinations.count} possible combinations",
693
- channel: event.channel,
694
- message_obj: message_obj
695
- ) && nil
819
+ if !teams
820
+ return send_embedded_message(
821
+ description: "There are only #{combinations.count} possible combinations",
822
+ channel: event.channel,
823
+ message_obj: message_obj
824
+ ) && nil
825
+ end
826
+ else
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]
696
844
  end
697
845
 
698
846
  pug.destroy_teams
@@ -748,51 +896,17 @@ class QwtfDiscordBotPug # :nodoc:
748
896
  end
749
897
 
750
898
  def start_pug(pug, event)
751
- choose_fair_teams(pug: pug, event: event) unless pug.teams.any?
752
-
753
- footer = [
754
- pug.game_map,
755
- "#{pug.player_slots} joined",
756
- ].compact.join(MSG_SNIPPET_DELIMITER)
757
-
758
899
  mentions = pug.players.map do |player_id|
759
900
  event.mention_for(player_id)
760
901
  end
761
902
 
762
- mention_line = "Time to play! #{mentions.join(" ")}"
903
+ mention_line = mentions.join(" ")
763
904
 
764
905
  send_embedded_message(
765
906
  message: mention_line,
766
- channel: event.channel
767
- ) do |embed|
768
- embed.footer = Discordrb::Webhooks::EmbedFooter.new(
769
- text: footer
770
- )
771
-
772
- if pug.queued_players.any?
773
- queue_display_names = pug.queued_players.map do |player_id|
774
- event.display_name_for(player_id)
775
- end
776
-
777
- embed.add_field(
778
- inline: true,
779
- name: "Queue",
780
- value: queue_display_names.join("\n")
781
- )
782
- end
783
-
784
- pug.teams.each do |team_no, player_ids|
785
- team_mentions = player_ids.map do |player_id|
786
- event.display_name_for(player_id)
787
- end
788
-
789
- embed.add_field(
790
- inline: true,
791
- name: team_name(team_no),
792
- value: team_mentions.join("\n")
793
- )
794
- end
795
- end
907
+ channel: event.channel,
908
+ description: "Time to play. `!choose`, `!shuffle` or `!team` up."
909
+ )
796
910
  end
797
911
 
798
912
  def end_pug(pug, channel_id)
@@ -830,22 +944,26 @@ class QwtfDiscordBotPug # :nodoc:
830
944
  end
831
945
 
832
946
  def post_results(json)
833
- uri = URI([ENV['RATINGS_API_URL'], 'matches'].join('/'))
947
+ uri = URI([ENV['RESULTS_API_URL'], 'matches'].join('/'))
834
948
  req = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')
835
949
  req.body = json
836
950
 
837
- Net::HTTP.start(uri.hostname, uri.port) do |http|
951
+ https? = uri.scheme == "https"
952
+
953
+ Net::HTTP.start(uri.hostname, uri.port, use_ssl: https?) do |http|
838
954
  http.request(req)
839
955
  end
840
956
  end
841
957
 
842
958
  def get_fair_teams(channel_id:, players:)
843
- uri = URI([ENV['RATINGS_API_URL'], 'fair_teams', 'new'].join('/'))
959
+ uri = URI([ENV['RESULTS_API_URL'], 'fair_teams', 'new'].join('/'))
844
960
  params = { :channel_id => channel_id, 'players[]' => players }
845
961
  uri.query = URI.encode_www_form(params)
846
962
  req = Net::HTTP::Get.new(uri)
847
963
 
848
- res = Net::HTTP.start(uri.hostname, uri.port) do |http|
964
+ https? = uri.scheme == "https"
965
+
966
+ res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: https?) do |http|
849
967
  http.request(req)
850
968
  end
851
969
 
@@ -857,6 +975,6 @@ class QwtfDiscordBotPug # :nodoc:
857
975
  end
858
976
 
859
977
  def discord_channel_leaderboard_url(channel_id)
860
- [ENV['RATINGS_APP_URL'], "discord_channels", channel_id].join('/')
978
+ [ENV['RESULTS_APP_URL'], "discord_channels", channel_id].join('/')
861
979
  end
862
980
  end
@@ -30,4 +30,5 @@ Gem::Specification.new do |spec|
30
30
  spec.add_runtime_dependency 'discordrb', '3.4.0'
31
31
  spec.add_runtime_dependency 'redis', '~> 4.2'
32
32
  spec.add_runtime_dependency 'thor', '~>1.1'
33
+ spec.add_runtime_dependency 'activesupport', '~>6.1'
33
34
  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.1.5
4
+ version: 6.3.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: 2021-07-24 00:00:00.000000000 Z
11
+ date: 2021-09-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: discordrb
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1.1'
55
+ - !ruby/object:Gem::Dependency
56
+ name: activesupport
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '6.1'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '6.1'
55
69
  description: A Discord bot for reporting on QuakeWorld Team Fortress game servers
56
70
  email:
57
71
  - shayolden@hotmail.com