qwtf_discord_bot 5.5.13 → 5.5.18
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/Dockerfile +2 -1
- data/Gemfile.lock +39 -43
- data/README.md +1 -1
- data/VERSION +1 -1
- data/lib/dashboard.rb +26 -21
- data/lib/qwtf_discord_bot/qwtf_discord_bot_pug.rb +31 -17
- data/qwtf_discord_bot.gemspec +3 -3
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: edf725dbe10cf8dd1f3a44adb214ccd9ebca849a86c898dc5012b180301da3eb
|
4
|
+
data.tar.gz: 3c2dff10129f4f73b4b16337ed7413207d5aa2695457fa046158b5a8bf4a5240
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f9a5f0e994c6ffd34c93af96d8b5b7ac9bcf80005532a6fa9e1918da72a05c42c74ab079cc7ab34bd03f5f0bf6a51d12c5a7510f10a692146dcb96dc6d35da47
|
7
|
+
data.tar.gz: a6d3460b139e0386de4c5685ea978c8e98fafcd1fcdb9988ff620628e37df0ef5854d5adc5d72403cff072168c138e4fc8120f62f82f90f24a9cc7f822ec3a43
|
data/Dockerfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,90 +1,86 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
qwtf_discord_bot (5.
|
5
|
-
discordrb
|
6
|
-
redis
|
7
|
-
thor
|
4
|
+
qwtf_discord_bot (5.5.18)
|
5
|
+
discordrb
|
6
|
+
redis
|
7
|
+
thor
|
8
8
|
|
9
9
|
GEM
|
10
10
|
remote: https://rubygems.org/
|
11
11
|
specs:
|
12
|
-
activesupport (6.
|
12
|
+
activesupport (6.1.3)
|
13
13
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
14
|
-
i18n (>=
|
15
|
-
minitest (
|
16
|
-
tzinfo (~>
|
17
|
-
zeitwerk (~> 2.
|
14
|
+
i18n (>= 1.6, < 2)
|
15
|
+
minitest (>= 5.1)
|
16
|
+
tzinfo (~> 2.0)
|
17
|
+
zeitwerk (~> 2.3)
|
18
18
|
coderay (1.1.3)
|
19
|
-
concurrent-ruby (1.1.
|
19
|
+
concurrent-ruby (1.1.8)
|
20
20
|
diff-lcs (1.4.4)
|
21
|
-
discordrb (3.
|
22
|
-
discordrb-webhooks (~> 3.
|
21
|
+
discordrb (3.4.2)
|
22
|
+
discordrb-webhooks (~> 3.4.2)
|
23
23
|
ffi (>= 1.9.24)
|
24
24
|
opus-ruby
|
25
|
-
|
26
|
-
rest-client (>= 2.1.0.rc1)
|
25
|
+
rest-client (>= 2.0.0)
|
27
26
|
websocket-client-simple (>= 0.3.0)
|
28
|
-
discordrb-webhooks (3.
|
29
|
-
rest-client (>= 2.
|
27
|
+
discordrb-webhooks (3.4.2)
|
28
|
+
rest-client (>= 2.0.0)
|
30
29
|
domain_name (0.5.20190701)
|
31
30
|
unf (>= 0.0.5, < 1.0.0)
|
32
31
|
event_emitter (0.2.6)
|
33
32
|
factory_bot (6.1.0)
|
34
33
|
activesupport (>= 5.0.0)
|
35
|
-
ffi (1.
|
34
|
+
ffi (1.14.2)
|
36
35
|
http-accept (1.7.0)
|
37
36
|
http-cookie (1.0.3)
|
38
37
|
domain_name (~> 0.5)
|
39
|
-
i18n (1.8.
|
38
|
+
i18n (1.8.9)
|
40
39
|
concurrent-ruby (~> 1.0)
|
41
40
|
method_source (1.0.0)
|
42
41
|
mime-types (3.3.1)
|
43
42
|
mime-types-data (~> 3.2015)
|
44
|
-
mime-types-data (3.
|
45
|
-
minitest (5.14.
|
43
|
+
mime-types-data (3.2021.0212)
|
44
|
+
minitest (5.14.3)
|
46
45
|
netrc (0.11.0)
|
47
46
|
opus-ruby (1.0.1)
|
48
47
|
ffi
|
49
|
-
pry (0.
|
48
|
+
pry (0.14.0)
|
50
49
|
coderay (~> 1.1)
|
51
50
|
method_source (~> 1.0)
|
52
|
-
|
53
|
-
ffi
|
54
|
-
redis (4.2.1)
|
51
|
+
redis (4.2.5)
|
55
52
|
rest-client (2.1.0)
|
56
53
|
http-accept (>= 1.7.0, < 2.0)
|
57
54
|
http-cookie (>= 1.0.2, < 2.0)
|
58
55
|
mime-types (>= 1.16, < 4.0)
|
59
56
|
netrc (~> 0.8)
|
60
|
-
rspec (3.
|
61
|
-
rspec-core (~> 3.
|
62
|
-
rspec-expectations (~> 3.
|
63
|
-
rspec-mocks (~> 3.
|
64
|
-
rspec-core (3.
|
65
|
-
rspec-support (~> 3.
|
66
|
-
rspec-expectations (3.
|
57
|
+
rspec (3.10.0)
|
58
|
+
rspec-core (~> 3.10.0)
|
59
|
+
rspec-expectations (~> 3.10.0)
|
60
|
+
rspec-mocks (~> 3.10.0)
|
61
|
+
rspec-core (3.10.1)
|
62
|
+
rspec-support (~> 3.10.0)
|
63
|
+
rspec-expectations (3.10.1)
|
67
64
|
diff-lcs (>= 1.2.0, < 2.0)
|
68
|
-
rspec-support (~> 3.
|
69
|
-
rspec-mocks (3.
|
65
|
+
rspec-support (~> 3.10.0)
|
66
|
+
rspec-mocks (3.10.2)
|
70
67
|
diff-lcs (>= 1.2.0, < 2.0)
|
71
|
-
rspec-support (~> 3.
|
72
|
-
rspec-support (3.
|
73
|
-
thor (
|
74
|
-
|
75
|
-
|
76
|
-
thread_safe (~> 0.1)
|
68
|
+
rspec-support (~> 3.10.0)
|
69
|
+
rspec-support (3.10.2)
|
70
|
+
thor (1.1.0)
|
71
|
+
tzinfo (2.0.4)
|
72
|
+
concurrent-ruby (~> 1.0)
|
77
73
|
unf (0.1.4)
|
78
74
|
unf_ext
|
79
75
|
unf_ext (0.0.7.7)
|
80
|
-
websocket (1.2.
|
76
|
+
websocket (1.2.9)
|
81
77
|
websocket-client-simple (0.3.0)
|
82
78
|
event_emitter
|
83
79
|
websocket
|
84
|
-
zeitwerk (2.4.
|
80
|
+
zeitwerk (2.4.2)
|
85
81
|
|
86
82
|
PLATFORMS
|
87
|
-
|
83
|
+
x86_64-linux
|
88
84
|
|
89
85
|
DEPENDENCIES
|
90
86
|
bundler
|
@@ -97,4 +93,4 @@ DEPENDENCIES
|
|
97
93
|
thor
|
98
94
|
|
99
95
|
BUNDLED WITH
|
100
|
-
|
96
|
+
2.2.8
|
data/README.md
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
5.5.
|
1
|
+
5.5.18
|
data/lib/dashboard.rb
CHANGED
@@ -2,7 +2,6 @@ class Dashboard
|
|
2
2
|
def initialize(dashboard_config, bot)
|
3
3
|
@server = bot.server(dashboard_config["server_id"])
|
4
4
|
@endpoints = dashboard_config["endpoints"]
|
5
|
-
@messages = {}
|
6
5
|
|
7
6
|
channel_name = dashboard_config["name"]
|
8
7
|
|
@@ -11,31 +10,37 @@ class Dashboard
|
|
11
10
|
end
|
12
11
|
|
13
12
|
@channel = if old_dashboard_channel
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
13
|
+
old_messages = JSON.parse(
|
14
|
+
Discordrb::API::Channel.messages(
|
15
|
+
"Bot #{QwtfDiscordBot.config.token}",
|
16
|
+
old_dashboard_channel.id,
|
17
|
+
100
|
18
|
+
)
|
19
|
+
)
|
20
|
+
|
21
|
+
old_messages.each do |old_message|
|
22
|
+
sleep 2
|
23
|
+
old_dashboard_channel.message(old_message['id']).delete
|
24
|
+
end
|
25
|
+
|
26
|
+
old_dashboard_channel
|
27
|
+
else
|
28
|
+
@server.create_channel(channel_name).tap do |channel|
|
29
|
+
channel.topic = "QWTF Bot Dashboard"
|
30
|
+
end
|
31
|
+
end
|
29
32
|
end
|
30
33
|
|
31
34
|
def update
|
35
|
+
messages = {}
|
36
|
+
|
32
37
|
@endpoints.each do |endpoint|
|
33
38
|
qstat_request = QstatRequest.new(endpoint)
|
34
39
|
|
35
40
|
if qstat_request.is_empty?
|
36
|
-
if
|
37
|
-
|
38
|
-
|
41
|
+
if messages[endpoint]
|
42
|
+
messages[endpoint].delete
|
43
|
+
messages.delete(endpoint)
|
39
44
|
end
|
40
45
|
|
41
46
|
next
|
@@ -43,8 +48,8 @@ class Dashboard
|
|
43
48
|
|
44
49
|
embed = qstat_request.to_full_embed
|
45
50
|
|
46
|
-
|
47
|
-
|
51
|
+
messages[endpoint] = if messages[endpoint]
|
52
|
+
messages[endpoint].edit(nil, embed)
|
48
53
|
else
|
49
54
|
@channel.send_embed(nil, embed)
|
50
55
|
end
|
@@ -8,7 +8,7 @@ class QwtfDiscordBotPug # :nodoc:
|
|
8
8
|
|
9
9
|
MSG_SNIPPET_DELIMITER = ' · '
|
10
10
|
TEAM_NAMES = { 1 => "Blue", 2 => "Red" }
|
11
|
-
|
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
|
-
|
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 >
|
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: "
|
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 >
|
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: "
|
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 "
|
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
|
834
|
-
Time.now.to_i -
|
847
|
+
def ten_minutes_ago
|
848
|
+
Time.now.to_i - TEN_MINUTES
|
835
849
|
end
|
836
850
|
end
|
data/qwtf_discord_bot.gemspec
CHANGED
@@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
28
|
spec.require_paths = ['lib']
|
29
29
|
|
30
|
-
spec.add_runtime_dependency 'discordrb', '~> 3.
|
31
|
-
spec.add_runtime_dependency 'redis', '~> 4.
|
32
|
-
spec.add_runtime_dependency 'thor', '~>
|
30
|
+
spec.add_runtime_dependency 'discordrb', '~> 3.4'
|
31
|
+
spec.add_runtime_dependency 'redis', '~> 4.2'
|
32
|
+
spec.add_runtime_dependency 'thor', '~>1.1'
|
33
33
|
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.
|
4
|
+
version: 5.5.18
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sheldon Johnson
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-02-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: discordrb
|
@@ -16,42 +16,42 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '3.
|
19
|
+
version: '3.4'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '3.
|
26
|
+
version: '3.4'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: redis
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '4.
|
33
|
+
version: '4.2'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '4.
|
40
|
+
version: '4.2'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: thor
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '1.1'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '1.1'
|
55
55
|
description: A Discord bot for reporting on QuakeWorld Team Fortress game servers
|
56
56
|
email:
|
57
57
|
- shayolden@hotmail.com
|
@@ -140,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
140
140
|
- !ruby/object:Gem::Version
|
141
141
|
version: '0'
|
142
142
|
requirements: []
|
143
|
-
rubygems_version: 3.
|
143
|
+
rubygems_version: 3.2.3
|
144
144
|
signing_key:
|
145
145
|
specification_version: 4
|
146
146
|
summary: Works by wrapping the excellent CLI server query tool qstat. Accepts !server,
|