qwtf_discord_bot 5.5.12 → 5.5.17

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: c2014003c3eb073a45807b356a6605217fefbd0527b87f1fcb0a56f920d12086
4
- data.tar.gz: 2f0a418cb8f54908c249cbec6d4a2382cefb1b8fed4d3d33698031497542cf61
3
+ metadata.gz: 55bf454fa327aa5bf7d0b29bd63829ae2c2b93de601e15de209f8deff570869f
4
+ data.tar.gz: f12ee66e6996bfee4400dba504de6227179595a84576cc195611a6ea3f79f2c8
5
5
  SHA512:
6
- metadata.gz: 7fb0372d9c0a6bc2117af66080a0fe19ca77d4a7035463e651f09b01db3c19edca6d93c5b5da706c0cdfff67da7ff3dffe2f8fda18a66958b83b6a01d7a604ca
7
- data.tar.gz: 4a2a97d48484ef821c08eb115831500c82aafd3134e7675571871da84413df493c5764ba0afb8ea4900105a8d39f7eff75b0e7a89e372781f74e2478876fb48d
6
+ metadata.gz: 9de0be068be49dfed25b62b8d1d45c4c380aadb67f7abe05384d606a25967814350b8ba026ecd1936e1d4e0bbd9adda3bc8c4c91a2e5f1c6d6e4635bf9ff8d03
7
+ data.tar.gz: 77454e92741377506ffaaea1c81a206cfd5902c7e0896515c1e67df2fe514aaee2b498be773650b4fc2c537b33ebf0866b77561b2ac7e07257723a4026f8ba66
data/VERSION CHANGED
@@ -1 +1 @@
1
- 5.5.12
1
+ 5.5.17
data/lib/pug.rb CHANGED
@@ -148,7 +148,11 @@ class Pug
148
148
  end
149
149
 
150
150
  def equal_number_of_players_on_each_team?
151
- actual_teams.map(&:size).uniq.size == 1
151
+ team_player_counts = actual_teams.map do |_name, players|
152
+ players.size
153
+ end
154
+
155
+ team_player_counts.uniq.size == 1
152
156
  end
153
157
 
154
158
  private
@@ -8,7 +8,7 @@ class QwtfDiscordBotPug # :nodoc:
8
8
 
9
9
  MSG_SNIPPET_DELIMITER = ' · '
10
10
  TEAM_NAMES = { 1 => "Blue", 2 => "Red" }
11
- ONE_MINUTE = 60
11
+ TEN_MINUTES = 10 * 60
12
12
 
13
13
  def run
14
14
  bot = Discordrb::Commands::CommandBot.new(
@@ -46,6 +46,13 @@ class QwtfDiscordBotPug # :nodoc:
46
46
 
47
47
  bot.command :choose do |event, *args|
48
48
  setup_pug(event) do |e, pug|
49
+ if pug.joined_players.count > pug.maxplayers
50
+ return send_embedded_message(
51
+ description: "Too many players, increase `!teamsize` or `!kick` extras",
52
+ channel: event.channel
53
+ )
54
+ end
55
+
49
56
  if pug.joined_players.count.odd?
50
57
  return send_embedded_message(
51
58
  description: "Can't choose teams with odd number of players",
@@ -240,7 +247,13 @@ class QwtfDiscordBotPug # :nodoc:
240
247
  )
241
248
  end
242
249
 
243
- join_pug(e, pug) unless pug.joined?(user_id)
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
+
244
257
  pug.join_team(team_no: team_no, player_id: user_id)
245
258
 
246
259
  send_embedded_message(
@@ -252,6 +265,13 @@ class QwtfDiscordBotPug # :nodoc:
252
265
  )
253
266
  else
254
267
  args[1..-1].each do |mention|
268
+ if pug.team(team_no).size >= pug.teamsize
269
+ return send_embedded_message(
270
+ description: "Team is full",
271
+ channel: e.channel
272
+ )
273
+ end
274
+
255
275
  unless mention.match(/<@!\d+>/)
256
276
  send_embedded_message(
257
277
  description: "#{arg} isn't a valid mention",
@@ -356,7 +376,7 @@ class QwtfDiscordBotPug # :nodoc:
356
376
  )
357
377
  end
358
378
 
359
- if pug.equal_number_of_players_on_each_team?
379
+ if !pug.equal_number_of_players_on_each_team?
360
380
  return send_embedded_message(
361
381
  description: "Can't report unless teams have same number of players",
362
382
  channel: event.channel
@@ -370,11 +390,9 @@ class QwtfDiscordBotPug # :nodoc:
370
390
  )
371
391
  end
372
392
 
373
- if pug.last_result_time && pug.last_result_time > one_minute_ago
374
- time_ago = Time.now.to_i - pug.last_result_time
375
-
393
+ if pug.last_result_time && pug.last_result_time > ten_minutes_ago
376
394
  return send_embedded_message(
377
- description: "Please wait #{ONE_MINUTE - time_ago} more seconds before reporting",
395
+ description: "A match was reported less than 10 minutes ago",
378
396
  channel: event.channel
379
397
  )
380
398
  end
@@ -411,8 +429,6 @@ class QwtfDiscordBotPug # :nodoc:
411
429
  }.to_json
412
430
  ).body
413
431
 
414
- pug.unteam_all_players
415
-
416
432
  send_embedded_message(
417
433
  description: "#{TEAM_NAMES[winning_team_no]} wins game ##{id}. `!choose` again. [Ratings](http://ratings.fortressone.org)",
418
434
  channel: e.channel
@@ -436,7 +452,7 @@ class QwtfDiscordBotPug # :nodoc:
436
452
  )
437
453
  end
438
454
 
439
- if pug.equal_number_of_players_on_each_team?
455
+ if !pug.equal_number_of_players_on_each_team?
440
456
  return send_embedded_message(
441
457
  description: "Can't report unless teams have same number of players",
442
458
  channel: event.channel
@@ -450,11 +466,11 @@ class QwtfDiscordBotPug # :nodoc:
450
466
  )
451
467
  end
452
468
 
453
- if pug.last_result_time && pug.last_result_time > one_minute_ago
469
+ if pug.last_result_time && pug.last_result_time > ten_minutes_ago
454
470
  time_ago = Time.now.to_i - pug.last_result_time
455
471
 
456
472
  return send_embedded_message(
457
- description: "Please wait #{ONE_MINUTE - time_ago} more seconds before reporting",
473
+ description: "A match was reported less than 10 minutes ago",
458
474
  channel: event.channel
459
475
  )
460
476
  end
@@ -481,8 +497,6 @@ class QwtfDiscordBotPug # :nodoc:
481
497
  }.to_json
482
498
  ).body
483
499
 
484
- pug.unteam_all_players
485
-
486
500
  send_embedded_message(
487
501
  description: "Match ##{id} drawn. `!choose` again. [Ratings](http://ratings.fortressone.org)",
488
502
  channel: e.channel
@@ -633,7 +647,7 @@ class QwtfDiscordBotPug # :nodoc:
633
647
  private
634
648
 
635
649
  def team_name(team_no)
636
- return "No team" if team_no == 0
650
+ return "Queue" if team_no == 0
637
651
 
638
652
  [team_no, TEAM_NAMES[team_no]].join(" ")
639
653
  end
@@ -830,7 +844,7 @@ class QwtfDiscordBotPug # :nodoc:
830
844
  JSON.parse(res.body).map(&:to_h)
831
845
  end
832
846
 
833
- def one_minute_ago
834
- Time.now.to_i - ONE_MINUTE
847
+ def ten_minutes_ago
848
+ Time.now.to_i - TEN_MINUTES
835
849
  end
836
850
  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.5.12
4
+ version: 5.5.17
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-12-06 00:00:00.000000000 Z
11
+ date: 2020-12-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: discordrb