qwtf_discord_bot 5.4.7 → 5.4.12
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/VERSION +1 -1
- data/lib/qwtf_discord_bot/qwtf_discord_bot_pug.rb +47 -28
- 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: 4b277234b785000212e913859cac63c94fc2c125bf6c2723ed5b7df6ba7419a7
|
4
|
+
data.tar.gz: b55f4861185865fb3b7bb8ceb19ddad26ebaef334aa02cc7e7504e0b6bf74a20
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db1415cd7144dbf88b0343cabf2d05daed1fc8da377a25c2d32117d7d84be9f7cb4fdbd96d16c5084a2abf00d78d7318baaff8accd96a6723657867fdcfb7422
|
7
|
+
data.tar.gz: 5af029b8abd9cf20438ae815ca4e6234b23c0d2279c3884bc0d267d31e06f7a91de523b0276719a7a37e6c373d14795b39e2e5b6774d84956828490834d5fc47
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
5.4.
|
1
|
+
5.4.12
|
@@ -65,8 +65,9 @@ class QwtfDiscordBotPug # :nodoc:
|
|
65
65
|
0
|
66
66
|
end
|
67
67
|
|
68
|
-
|
69
|
-
|
68
|
+
|
69
|
+
message_obj = choose_fair_teams(pug: pug, event: e, iteration: iteration)
|
70
|
+
status(pug: pug, event: e, message_obj: message_obj) if message_obj
|
70
71
|
end
|
71
72
|
end
|
72
73
|
|
@@ -260,15 +261,6 @@ class QwtfDiscordBotPug # :nodoc:
|
|
260
261
|
|
261
262
|
user_id = mention_to_user_id(mention)
|
262
263
|
display_name = e.display_name_for(user_id) || arg
|
263
|
-
|
264
|
-
unless pug.joined?(user_id)
|
265
|
-
send_embedded_message(
|
266
|
-
description: "#{display_name} isn't in the PUG",
|
267
|
-
channel: e.channel
|
268
|
-
)
|
269
|
-
next
|
270
|
-
end
|
271
|
-
|
272
264
|
pug.join_team(team_no: team_no, player_id: user_id)
|
273
265
|
|
274
266
|
send_embedded_message(
|
@@ -328,6 +320,13 @@ class QwtfDiscordBotPug # :nodoc:
|
|
328
320
|
)
|
329
321
|
end
|
330
322
|
|
323
|
+
if !pug.full?
|
324
|
+
return send_embedded_message(
|
325
|
+
description: "Can't report unless PUG is full",
|
326
|
+
channel: event.channel
|
327
|
+
)
|
328
|
+
end
|
329
|
+
|
331
330
|
unless args.any?
|
332
331
|
return send_embedded_message(
|
333
332
|
description: "Specify winning team; e.g. `!win 1`",
|
@@ -360,7 +359,7 @@ class QwtfDiscordBotPug # :nodoc:
|
|
360
359
|
teams.merge({ name => { players: players, result: result } })
|
361
360
|
end
|
362
361
|
|
363
|
-
post_results(
|
362
|
+
id = post_results(
|
364
363
|
{
|
365
364
|
match: {
|
366
365
|
map: pug.game_map,
|
@@ -371,10 +370,10 @@ class QwtfDiscordBotPug # :nodoc:
|
|
371
370
|
}
|
372
371
|
}
|
373
372
|
}.to_json
|
374
|
-
)
|
373
|
+
).body
|
375
374
|
|
376
375
|
send_embedded_message(
|
377
|
-
description: "#{TEAM_NAMES[winning_team_no]} wins. [Ratings](http://ratings.fortressone.org)",
|
376
|
+
description: "#{TEAM_NAMES[winning_team_no]} wins game ##{id}. [Ratings](http://ratings.fortressone.org)",
|
378
377
|
channel: e.channel
|
379
378
|
)
|
380
379
|
end
|
@@ -389,6 +388,13 @@ class QwtfDiscordBotPug # :nodoc:
|
|
389
388
|
)
|
390
389
|
end
|
391
390
|
|
391
|
+
if !pug.full?
|
392
|
+
return send_embedded_message(
|
393
|
+
description: "Can't report unless PUG is full",
|
394
|
+
channel: event.channel
|
395
|
+
)
|
396
|
+
end
|
397
|
+
|
392
398
|
if pug.actual_teams.count < 2
|
393
399
|
return send_embedded_message(
|
394
400
|
description: "There must be at least two teams with players to submit a result",
|
@@ -404,7 +410,7 @@ class QwtfDiscordBotPug # :nodoc:
|
|
404
410
|
teams.merge({ name => { players: players, result: 0 } })
|
405
411
|
end
|
406
412
|
|
407
|
-
post_results(
|
413
|
+
id = post_results(
|
408
414
|
{
|
409
415
|
match: {
|
410
416
|
map: pug.game_map,
|
@@ -415,10 +421,10 @@ class QwtfDiscordBotPug # :nodoc:
|
|
415
421
|
}
|
416
422
|
}
|
417
423
|
}.to_json
|
418
|
-
)
|
424
|
+
).body
|
419
425
|
|
420
426
|
send_embedded_message(
|
421
|
-
description: "Match drawn. [Ratings](http://ratings.fortressone.org)",
|
427
|
+
description: "Match ##{id} drawn. [Ratings](http://ratings.fortressone.org)",
|
422
428
|
channel: e.channel
|
423
429
|
)
|
424
430
|
end
|
@@ -605,11 +611,11 @@ class QwtfDiscordBotPug # :nodoc:
|
|
605
611
|
if !pug.full?
|
606
612
|
return send_embedded_message(
|
607
613
|
description: "Can't choose teams until PUG is full",
|
608
|
-
channel:
|
609
|
-
)
|
614
|
+
channel: event.channel
|
615
|
+
) && nil
|
610
616
|
end
|
611
617
|
|
612
|
-
send_embedded_message(
|
618
|
+
message_obj = send_embedded_message(
|
613
619
|
description: "Choosing fair teams...",
|
614
620
|
channel: event.channel
|
615
621
|
)
|
@@ -620,8 +626,9 @@ class QwtfDiscordBotPug # :nodoc:
|
|
620
626
|
if !teams
|
621
627
|
return send_embedded_message(
|
622
628
|
description: "There are only #{combinations.count} possible combinations",
|
623
|
-
channel: event.channel
|
624
|
-
|
629
|
+
channel: event.channel,
|
630
|
+
message_obj: message_obj
|
631
|
+
) && nil
|
625
632
|
end
|
626
633
|
|
627
634
|
teams.each do |team_no, player_ids|
|
@@ -629,17 +636,20 @@ class QwtfDiscordBotPug # :nodoc:
|
|
629
636
|
pug.join_team(team_no: team_no, player_id: player_id)
|
630
637
|
end
|
631
638
|
end
|
639
|
+
|
640
|
+
message_obj
|
632
641
|
end
|
633
642
|
|
634
|
-
def status(pug:, event:)
|
643
|
+
def status(pug:, event:, message_obj: nil)
|
635
644
|
footer = [
|
636
|
-
pug.game_map,
|
637
|
-
"#{pug.player_slots} joined"
|
645
|
+
pug.game_map || "No map selected",
|
646
|
+
"#{pug.player_slots} joined",
|
638
647
|
].compact.join(MSG_SNIPPET_DELIMITER)
|
639
648
|
|
640
649
|
send_embedded_message(
|
641
650
|
description: nil,
|
642
|
-
channel: event.channel
|
651
|
+
channel: event.channel,
|
652
|
+
message_obj: message_obj
|
643
653
|
) do |embed|
|
644
654
|
embed.footer = Discordrb::Webhooks::EmbedFooter.new(
|
645
655
|
text: footer
|
@@ -716,11 +726,20 @@ class QwtfDiscordBotPug # :nodoc:
|
|
716
726
|
"There's no active PUG"
|
717
727
|
end
|
718
728
|
|
719
|
-
def send_embedded_message(message: nil, description: nil, channel:)
|
729
|
+
def send_embedded_message(message: nil, description: nil, channel:, message_obj: nil)
|
720
730
|
embed = Discordrb::Webhooks::Embed.new
|
721
731
|
embed.description = description
|
722
732
|
yield(embed) if block_given?
|
723
|
-
|
733
|
+
|
734
|
+
if message_obj
|
735
|
+
message_obj.edit(message, embed).tap do
|
736
|
+
puts(message)
|
737
|
+
end
|
738
|
+
else
|
739
|
+
channel.send_embed(message, embed).tap do
|
740
|
+
puts(message)
|
741
|
+
end
|
742
|
+
end
|
724
743
|
end
|
725
744
|
|
726
745
|
def post_results(json)
|
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.4.
|
4
|
+
version: 5.4.12
|
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-
|
11
|
+
date: 2020-11-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: discordrb
|