qwtf_discord_bot 6.0.4 → 6.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/VERSION +1 -1
- data/lib/dashboard.rb +0 -1
- data/lib/pug.rb +54 -28
- data/lib/qstat_request.rb +19 -34
- data/lib/qwtf_discord_bot/qwtf_discord_bot_pug.rb +62 -34
- data/lib/qwtf_discord_bot/qwtf_discord_bot_server.rb +38 -53
- 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: 402ebf8fe6c235b94f6e1db48b228f13d0bdece3628873edf943f66f26c9d05c
|
4
|
+
data.tar.gz: 69c5fdad3c21f133a315a1f87ac9b92dc068efd13750e33f144bfdf64bf9ea8f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fd4aa01e8a86d1e0e82b658c26e9f6bbfce16786e00c61bd6069c4be1a03a3a63ab8a05a497bb287cf861d8d0f37f210cf8f52510be5e812a47eba34f728d1a2
|
7
|
+
data.tar.gz: c2c25e668f9de93662ee2ddac5ac43d058c50d49be42647c1c1ec33046b10220cfcb1b3f5678b7d4a52899e99bad8092098f2159478b7435217de86263cea1c8
|
data/Gemfile.lock
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
6.
|
1
|
+
6.1.4
|
data/lib/dashboard.rb
CHANGED
data/lib/pug.rb
CHANGED
@@ -11,17 +11,28 @@ class Pug
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def join(player_id)
|
14
|
-
|
15
|
-
redis.
|
14
|
+
timestamp = Time.now.to_i
|
15
|
+
redis.setnx(pug_key, timestamp)
|
16
|
+
redis.zadd(queue_key, timestamp, player_id, nx: true)
|
16
17
|
end
|
17
18
|
|
18
19
|
def join_team(team_no:, player_id:)
|
19
|
-
|
20
|
-
|
20
|
+
join(player_id)
|
21
|
+
unteam(player_id)
|
21
22
|
redis.sadd(team_key(team_no), player_id)
|
22
23
|
end
|
23
24
|
|
24
|
-
def
|
25
|
+
def up_now_players
|
26
|
+
players[0, maxplayers]
|
27
|
+
end
|
28
|
+
|
29
|
+
def destroy_teams
|
30
|
+
teamed_players.each do |player_id|
|
31
|
+
unteam(player_id)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def teamed_players
|
25
36
|
teams_keys.inject([]) do |players, team|
|
26
37
|
players + redis.smembers(team).map(&:to_i)
|
27
38
|
end
|
@@ -55,16 +66,24 @@ class Pug
|
|
55
66
|
redis.set(teamsize_key, teamsize)
|
56
67
|
end
|
57
68
|
|
69
|
+
def total_player_count
|
70
|
+
players.count
|
71
|
+
end
|
72
|
+
|
58
73
|
def full?
|
59
|
-
|
74
|
+
total_player_count >= maxplayers
|
75
|
+
end
|
76
|
+
|
77
|
+
def has_exactly_maxplayers?
|
78
|
+
total_player_count == maxplayers
|
60
79
|
end
|
61
80
|
|
62
81
|
def empty?
|
63
|
-
|
82
|
+
total_player_count.zero?
|
64
83
|
end
|
65
84
|
|
66
|
-
def
|
67
|
-
|
85
|
+
def teamed_player_count
|
86
|
+
teamed_players.count
|
68
87
|
end
|
69
88
|
|
70
89
|
def team_player_count(team_no)
|
@@ -72,11 +91,11 @@ class Pug
|
|
72
91
|
end
|
73
92
|
|
74
93
|
def player_slots
|
75
|
-
"#{
|
94
|
+
"#{total_player_count}/#{maxplayers}"
|
76
95
|
end
|
77
96
|
|
78
97
|
def slots_left
|
79
|
-
maxplayers -
|
98
|
+
maxplayers - total_player_count
|
80
99
|
end
|
81
100
|
|
82
101
|
def game_map=(map)
|
@@ -104,7 +123,8 @@ class Pug
|
|
104
123
|
end
|
105
124
|
|
106
125
|
def leave(player_id)
|
107
|
-
|
126
|
+
leave_queue(player_id)
|
127
|
+
unteam(player_id)
|
108
128
|
end
|
109
129
|
|
110
130
|
def end_pug
|
@@ -114,13 +134,17 @@ class Pug
|
|
114
134
|
end
|
115
135
|
|
116
136
|
def joined?(player_id)
|
117
|
-
|
137
|
+
redis.zrank(queue_key, player_id)
|
118
138
|
end
|
119
139
|
|
120
140
|
def maxplayers
|
121
141
|
teamsize * no_of_teams
|
122
142
|
end
|
123
143
|
|
144
|
+
def queued_players
|
145
|
+
players - teamed_players
|
146
|
+
end
|
147
|
+
|
124
148
|
def teams
|
125
149
|
all_teams = teams_keys.inject({}) do |teams, team|
|
126
150
|
teams.merge({ team.split(':').last.to_i => redis.smembers(team).map(&:to_i) })
|
@@ -129,16 +153,6 @@ class Pug
|
|
129
153
|
all_teams.sort.to_h
|
130
154
|
end
|
131
155
|
|
132
|
-
def actual_teams
|
133
|
-
teams.tap { |team| team.delete(0) }
|
134
|
-
end
|
135
|
-
|
136
|
-
def unteam_all_players
|
137
|
-
joined_players.each do |player_id|
|
138
|
-
join_team(team_no: 0, player_id: player_id)
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
156
|
def update_last_result_time
|
143
157
|
redis.set(last_result_time_key, Time.now.to_i)
|
144
158
|
end
|
@@ -148,25 +162,37 @@ class Pug
|
|
148
162
|
end
|
149
163
|
|
150
164
|
def equal_number_of_players_on_each_team?
|
151
|
-
team_player_counts =
|
165
|
+
team_player_counts = teams.map do |_name, players|
|
152
166
|
players.size
|
153
167
|
end
|
154
168
|
|
155
169
|
team_player_counts.uniq.size == 1
|
156
170
|
end
|
157
171
|
|
158
|
-
|
159
|
-
|
160
|
-
def leave_teams(player_id)
|
172
|
+
def unteam(player_id)
|
161
173
|
teams_keys.each do |team|
|
162
174
|
redis.srem(team, player_id)
|
163
175
|
end
|
164
176
|
end
|
165
177
|
|
178
|
+
def players
|
179
|
+
redis.zrange(queue_key, 0, -1).map(&:to_i)
|
180
|
+
end
|
181
|
+
|
182
|
+
private
|
183
|
+
|
184
|
+
def leave_queue(player_id)
|
185
|
+
redis.zrem(queue_key, player_id)
|
186
|
+
end
|
187
|
+
|
166
188
|
def teams_keys
|
167
189
|
redis.keys([pug_key, 'teams:*'].join(':'))
|
168
190
|
end
|
169
191
|
|
192
|
+
def queue_key
|
193
|
+
[pug_key, 'queue'].join(':')
|
194
|
+
end
|
195
|
+
|
170
196
|
def team_key(team_no)
|
171
197
|
[pug_key, 'teams', team_no].join(':')
|
172
198
|
end
|
@@ -208,6 +234,6 @@ class Pug
|
|
208
234
|
end
|
209
235
|
|
210
236
|
def no_of_teams
|
211
|
-
[
|
237
|
+
[teams.count, MIN_NO_OF_TEAMS].max
|
212
238
|
end
|
213
239
|
end
|
data/lib/qstat_request.rb
CHANGED
@@ -11,28 +11,26 @@ class QstatRequest
|
|
11
11
|
@result ||= execute
|
12
12
|
end
|
13
13
|
|
14
|
-
def to_embed
|
15
|
-
return nil if is_empty?
|
16
|
-
|
17
|
-
embed = Discordrb::Webhooks::Embed.new
|
18
|
-
|
19
|
-
teams.each do |team|
|
20
|
-
embed << team.to_embed_field
|
21
|
-
end
|
22
|
-
|
23
|
-
embed
|
24
|
-
end
|
25
|
-
|
26
14
|
def to_full_embed
|
27
15
|
Discordrb::Webhooks::Embed.new.tap do |embed|
|
28
16
|
embed.add_field(
|
29
17
|
name: name,
|
30
|
-
value:
|
18
|
+
value: join_link,
|
31
19
|
)
|
32
20
|
|
33
21
|
teams.each do |team|
|
34
22
|
embed << team.to_embed_field
|
35
23
|
end
|
24
|
+
|
25
|
+
footer = [game_map, "#{numplayers}/#{maxplayers} players"]
|
26
|
+
|
27
|
+
if has_spectators?
|
28
|
+
footer << "#{numspectators}/#{maxspectators} spectators"
|
29
|
+
end
|
30
|
+
|
31
|
+
embed.footer = Discordrb::Webhooks::EmbedFooter.new(
|
32
|
+
text: footer.join(MSG_SNIPPET_DELIMITER)
|
33
|
+
)
|
36
34
|
end
|
37
35
|
end
|
38
36
|
|
@@ -43,9 +41,7 @@ class QstatRequest
|
|
43
41
|
end
|
44
42
|
|
45
43
|
def server_summary
|
46
|
-
|
47
|
-
|
48
|
-
info = [name, @endpoint, game_map]
|
44
|
+
info = [name, game_map]
|
49
45
|
|
50
46
|
info += if !has_spectators?
|
51
47
|
["#{numplayers}/#{maxplayers}"]
|
@@ -56,28 +52,13 @@ class QstatRequest
|
|
56
52
|
]
|
57
53
|
end
|
58
54
|
|
55
|
+
info << join_link
|
56
|
+
|
59
57
|
info.join(MSG_SNIPPET_DELIMITER)
|
60
58
|
end
|
61
59
|
|
62
60
|
def join_link
|
63
|
-
"
|
64
|
-
end
|
65
|
-
|
66
|
-
def embed_summary
|
67
|
-
info = [@endpoint, game_map]
|
68
|
-
|
69
|
-
info += if !has_spectators?
|
70
|
-
["#{numplayers}/#{maxplayers}"]
|
71
|
-
else
|
72
|
-
[
|
73
|
-
"#{numplayers}/#{maxplayers} players",
|
74
|
-
"#{numspectators}/#{maxspectators} spectators"
|
75
|
-
]
|
76
|
-
end
|
77
|
-
|
78
|
-
info << join_link
|
79
|
-
|
80
|
-
info.join(MSG_SNIPPET_DELIMITER)
|
61
|
+
"<qw://#{@endpoint}>"
|
81
62
|
end
|
82
63
|
|
83
64
|
def is_empty?
|
@@ -92,6 +73,10 @@ class QstatRequest
|
|
92
73
|
numplayers && numplayers > 0
|
93
74
|
end
|
94
75
|
|
76
|
+
def live_server?
|
77
|
+
!game_map.nil?
|
78
|
+
end
|
79
|
+
|
95
80
|
private
|
96
81
|
|
97
82
|
def has_spectators?
|
@@ -9,6 +9,7 @@ class QwtfDiscordBotPug # :nodoc:
|
|
9
9
|
MSG_SNIPPET_DELIMITER = ' · '
|
10
10
|
TEAM_NAMES = { 1 => "Blue", 2 => "Red" }
|
11
11
|
TEN_MINUTES = 10 * 60
|
12
|
+
VALID_MENTION = /<@!?\d+>/
|
12
13
|
|
13
14
|
def run
|
14
15
|
bot = Discordrb::Commands::CommandBot.new(
|
@@ -40,22 +41,15 @@ class QwtfDiscordBotPug # :nodoc:
|
|
40
41
|
end
|
41
42
|
|
42
43
|
join_pug(e, pug)
|
43
|
-
start_pug(pug, e) if pug.
|
44
|
+
start_pug(pug, e) if pug.has_exactly_maxplayers?
|
44
45
|
end
|
45
46
|
end
|
46
47
|
|
47
48
|
bot.command :choose do |event, *args|
|
48
49
|
setup_pug(event) do |e, pug|
|
49
|
-
if pug.
|
50
|
-
return send_embedded_message(
|
51
|
-
description: "Too many players, increase `!teamsize` or `!kick` extras",
|
52
|
-
channel: event.channel
|
53
|
-
)
|
54
|
-
end
|
55
|
-
|
56
|
-
if pug.joined_players.count.odd?
|
50
|
+
if !pug.full?
|
57
51
|
return send_embedded_message(
|
58
|
-
description: "
|
52
|
+
description: "Not enough players, reduce !teamsize",
|
59
53
|
channel: event.channel
|
60
54
|
)
|
61
55
|
end
|
@@ -177,17 +171,17 @@ class QwtfDiscordBotPug # :nodoc:
|
|
177
171
|
)
|
178
172
|
end
|
179
173
|
|
180
|
-
args.each do |
|
181
|
-
unless
|
174
|
+
args.each do |mention|
|
175
|
+
unless mention.match(VALID_MENTION)
|
182
176
|
send_embedded_message(
|
183
|
-
description: "#{
|
177
|
+
description: "#{mention} isn't a valid mention",
|
184
178
|
channel: e.channel
|
185
179
|
)
|
186
180
|
next
|
187
181
|
end
|
188
182
|
|
189
|
-
user_id = mention_to_user_id(
|
190
|
-
display_name = e.display_name_for(user_id) ||
|
183
|
+
user_id = mention_to_user_id(mention)
|
184
|
+
display_name = e.display_name_for(user_id) || mention
|
191
185
|
|
192
186
|
unless pug.joined?(user_id)
|
193
187
|
send_embedded_message(
|
@@ -257,16 +251,16 @@ class QwtfDiscordBotPug # :nodoc:
|
|
257
251
|
)
|
258
252
|
else
|
259
253
|
args[1..-1].each do |mention|
|
260
|
-
unless mention.match(
|
254
|
+
unless mention.match(VALID_MENTION)
|
261
255
|
send_embedded_message(
|
262
|
-
description: "#{
|
256
|
+
description: "#{mention} isn't a valid mention",
|
263
257
|
channel: e.channel
|
264
258
|
)
|
265
259
|
next
|
266
260
|
end
|
267
261
|
|
268
262
|
user_id = mention_to_user_id(mention)
|
269
|
-
display_name = e.display_name_for(user_id) ||
|
263
|
+
display_name = e.display_name_for(user_id) || mention
|
270
264
|
pug.join_team(team_no: team_no, player_id: user_id)
|
271
265
|
|
272
266
|
send_embedded_message(
|
@@ -279,7 +273,7 @@ class QwtfDiscordBotPug # :nodoc:
|
|
279
273
|
end
|
280
274
|
end
|
281
275
|
|
282
|
-
start_pug(pug, e) if !pug_already_full && pug.
|
276
|
+
start_pug(pug, e) if !pug_already_full && pug.has_exactly_maxplayers?
|
283
277
|
end
|
284
278
|
end
|
285
279
|
|
@@ -302,14 +296,14 @@ class QwtfDiscordBotPug # :nodoc:
|
|
302
296
|
)
|
303
297
|
end
|
304
298
|
|
305
|
-
if pug.
|
299
|
+
if !pug.teamed_players.include?(user_id)
|
306
300
|
return send_embedded_message(
|
307
301
|
description: "You aren't in a team",
|
308
302
|
channel: e.channel
|
309
303
|
)
|
310
304
|
end
|
311
305
|
|
312
|
-
pug.
|
306
|
+
pug.unteam(user_id)
|
313
307
|
|
314
308
|
send_embedded_message(
|
315
309
|
description: "#{e.display_name} leaves team",
|
@@ -317,17 +311,25 @@ class QwtfDiscordBotPug # :nodoc:
|
|
317
311
|
)
|
318
312
|
else
|
319
313
|
args.each do |mention|
|
320
|
-
unless mention.match(
|
314
|
+
unless mention.match(VALID_MENTION)
|
321
315
|
send_embedded_message(
|
322
|
-
description: "#{
|
316
|
+
description: "#{mention} isn't a valid mention",
|
323
317
|
channel: e.channel
|
324
318
|
)
|
325
319
|
next
|
326
320
|
end
|
327
321
|
|
328
322
|
user_id = mention_to_user_id(mention)
|
329
|
-
display_name = e.display_name_for(user_id) ||
|
330
|
-
|
323
|
+
display_name = e.display_name_for(user_id) || mention
|
324
|
+
|
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
|
+
)
|
330
|
+
end
|
331
|
+
|
332
|
+
pug.unteam(user_id)
|
331
333
|
|
332
334
|
send_embedded_message(
|
333
335
|
description: "#{display_name} leaves team",
|
@@ -384,14 +386,14 @@ class QwtfDiscordBotPug # :nodoc:
|
|
384
386
|
|
385
387
|
winning_team_no = args.first.to_i
|
386
388
|
|
387
|
-
if pug.
|
389
|
+
if pug.teams.count < 2
|
388
390
|
return send_embedded_message(
|
389
391
|
description: "There must be at least two teams with players to submit a result",
|
390
392
|
channel: e.channel
|
391
393
|
)
|
392
394
|
end
|
393
395
|
|
394
|
-
team_results = pug.
|
396
|
+
team_results = pug.teams.inject({}) do |teams, (name, player_ids)|
|
395
397
|
players = player_ids.inject({}) do |memo, id|
|
396
398
|
memo.merge({ id => e.display_name_for(id) })
|
397
399
|
end
|
@@ -444,7 +446,7 @@ class QwtfDiscordBotPug # :nodoc:
|
|
444
446
|
)
|
445
447
|
end
|
446
448
|
|
447
|
-
if pug.
|
449
|
+
if pug.teams.count < 2
|
448
450
|
return send_embedded_message(
|
449
451
|
description: "There must be at least two teams with players to submit a result",
|
450
452
|
channel: e.channel
|
@@ -460,7 +462,7 @@ class QwtfDiscordBotPug # :nodoc:
|
|
460
462
|
)
|
461
463
|
end
|
462
464
|
|
463
|
-
team_results = pug.
|
465
|
+
team_results = pug.teams.inject({}) do |teams, (name, player_ids)|
|
464
466
|
players = player_ids.inject({}) do |memo, id|
|
465
467
|
memo.merge({ id => e.display_name_for(id) })
|
466
468
|
end
|
@@ -644,7 +646,7 @@ class QwtfDiscordBotPug # :nodoc:
|
|
644
646
|
def join_pug(e, pug)
|
645
647
|
pug.join(e.user_id)
|
646
648
|
|
647
|
-
if pug.
|
649
|
+
if pug.total_player_count == 1
|
648
650
|
snippets = ["#{e.display_name} creates a PUG", "#{pug.player_slots} joined"]
|
649
651
|
message = pug.notify_roles
|
650
652
|
else
|
@@ -669,7 +671,7 @@ class QwtfDiscordBotPug # :nodoc:
|
|
669
671
|
def choose_fair_teams(pug:, event:, iteration: 0)
|
670
672
|
if !pug.full?
|
671
673
|
return send_embedded_message(
|
672
|
-
description: "
|
674
|
+
description: "Not enough players, reduce !teamsize",
|
673
675
|
channel: event.channel
|
674
676
|
) && nil
|
675
677
|
end
|
@@ -680,7 +682,7 @@ class QwtfDiscordBotPug # :nodoc:
|
|
680
682
|
)
|
681
683
|
|
682
684
|
combinations = get_fair_teams(
|
683
|
-
channel_id: event.channel.id, players: pug.
|
685
|
+
channel_id: event.channel.id, players: pug.up_now_players
|
684
686
|
)
|
685
687
|
|
686
688
|
teams = combinations[iteration]
|
@@ -693,6 +695,8 @@ class QwtfDiscordBotPug # :nodoc:
|
|
693
695
|
) && nil
|
694
696
|
end
|
695
697
|
|
698
|
+
pug.destroy_teams
|
699
|
+
|
696
700
|
teams.each do |team_no, player_ids|
|
697
701
|
player_ids.each do |player_id|
|
698
702
|
pug.join_team(team_no: team_no, player_id: player_id)
|
@@ -717,6 +721,18 @@ class QwtfDiscordBotPug # :nodoc:
|
|
717
721
|
text: footer
|
718
722
|
)
|
719
723
|
|
724
|
+
if pug.queued_players.any?
|
725
|
+
queue_display_names = pug.queued_players.map do |player_id|
|
726
|
+
event.display_name_for(player_id)
|
727
|
+
end
|
728
|
+
|
729
|
+
embed.add_field(
|
730
|
+
inline: true,
|
731
|
+
name: "Queue",
|
732
|
+
value: queue_display_names.join("\n")
|
733
|
+
)
|
734
|
+
end
|
735
|
+
|
720
736
|
pug.teams.each do |team_no, player_ids|
|
721
737
|
team_display_names = player_ids.map do |player_id|
|
722
738
|
event.display_name_for(player_id)
|
@@ -732,14 +748,14 @@ class QwtfDiscordBotPug # :nodoc:
|
|
732
748
|
end
|
733
749
|
|
734
750
|
def start_pug(pug, event)
|
735
|
-
choose_fair_teams(pug: pug, event: event) unless pug.
|
751
|
+
choose_fair_teams(pug: pug, event: event) unless pug.teams.any?
|
736
752
|
|
737
753
|
footer = [
|
738
754
|
pug.game_map,
|
739
755
|
"#{pug.player_slots} joined",
|
740
756
|
].compact.join(MSG_SNIPPET_DELIMITER)
|
741
757
|
|
742
|
-
mentions = pug.
|
758
|
+
mentions = pug.players.map do |player_id|
|
743
759
|
event.mention_for(player_id)
|
744
760
|
end
|
745
761
|
|
@@ -753,6 +769,18 @@ class QwtfDiscordBotPug # :nodoc:
|
|
753
769
|
text: footer
|
754
770
|
)
|
755
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
|
+
|
756
784
|
pug.teams.each do |team_no, player_ids|
|
757
785
|
team_mentions = player_ids.map do |player_id|
|
758
786
|
event.display_name_for(player_id)
|
@@ -16,20 +16,17 @@ class QwtfDiscordBotServer
|
|
16
16
|
message = 'Provide a server address e.g. `!server ' \
|
17
17
|
'sydney.fortressone.org` or use `!active` or `!all`'
|
18
18
|
event.channel.send_message(message)
|
19
|
-
|
19
|
+
|
20
|
+
return puts message
|
21
|
+
end
|
22
|
+
|
23
|
+
endpoint = args.first
|
24
|
+
request = QstatRequest.new(endpoint)
|
25
|
+
|
26
|
+
if !request.live_server?
|
27
|
+
event.channel.send_message("#{endpoint} isn't responding")
|
20
28
|
else
|
21
|
-
|
22
|
-
qstat_response = QstatRequest.new(endpoint)
|
23
|
-
message = qstat_response.server_summary
|
24
|
-
embed = qstat_response.to_embed
|
25
|
-
|
26
|
-
if embed
|
27
|
-
event.channel.send_embed(message, embed)
|
28
|
-
puts message
|
29
|
-
else
|
30
|
-
event.channel.send_message(message)
|
31
|
-
puts message
|
32
|
-
end
|
29
|
+
event.channel.send_embed(nil, request.to_full_embed)
|
33
30
|
end
|
34
31
|
end
|
35
32
|
|
@@ -43,20 +40,16 @@ class QwtfDiscordBotServer
|
|
43
40
|
if endpoints_for_this_channel.empty?
|
44
41
|
message = 'There are no servers associated with this channel'
|
45
42
|
event.channel.send_message(message)
|
46
|
-
puts message
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
else
|
57
|
-
event.channel.send_message(message)
|
58
|
-
puts message
|
59
|
-
end
|
43
|
+
return puts message
|
44
|
+
end
|
45
|
+
|
46
|
+
endpoints_for_this_channel.each do |endpoint|
|
47
|
+
request = QstatRequest.new(endpoint.address)
|
48
|
+
|
49
|
+
if !request.live_server?
|
50
|
+
event.channel.send_message("#{endpoint} isn't responding")
|
51
|
+
else
|
52
|
+
event.channel.send_embed(nil, request.to_full_embed)
|
60
53
|
end
|
61
54
|
end
|
62
55
|
|
@@ -73,35 +66,27 @@ class QwtfDiscordBotServer
|
|
73
66
|
if endpoints_for_this_channel.empty?
|
74
67
|
message = 'There are no servers associated with this channel'
|
75
68
|
event.channel.send_message(message)
|
76
|
-
puts message
|
77
|
-
|
78
|
-
qstat_requests = endpoints_for_this_channel.map do |endpoint|
|
79
|
-
QstatRequest.new(endpoint.address)
|
80
|
-
end
|
69
|
+
return puts message
|
70
|
+
end
|
81
71
|
|
82
|
-
|
83
|
-
|
84
|
-
|
72
|
+
qstat_requests = endpoints_for_this_channel.map do |endpoint|
|
73
|
+
QstatRequest.new(endpoint.address)
|
74
|
+
end
|
85
75
|
|
86
|
-
|
87
|
-
|
88
|
-
event.channel.send_message(message)
|
89
|
-
puts message
|
90
|
-
else
|
91
|
-
servers_with_players.each do |server|
|
92
|
-
message = server.server_summary
|
93
|
-
embed = server.to_embed
|
94
|
-
|
95
|
-
if embed
|
96
|
-
event.channel.send_embed(message, embed)
|
97
|
-
puts message
|
98
|
-
else
|
99
|
-
event.channel.send_message(message)
|
100
|
-
puts message
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
76
|
+
servers_with_players = qstat_requests.reject do |server|
|
77
|
+
server.is_empty?
|
104
78
|
end
|
79
|
+
|
80
|
+
if servers_with_players.empty?
|
81
|
+
message = "All ##{event.channel.name} servers are empty"
|
82
|
+
event.channel.send_message(message)
|
83
|
+
return puts message
|
84
|
+
end
|
85
|
+
|
86
|
+
servers_with_players.each do |server|
|
87
|
+
event.channel.send_embed(nil, server.to_full_embed)
|
88
|
+
end
|
89
|
+
|
105
90
|
return nil
|
106
91
|
end
|
107
92
|
|
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.
|
4
|
+
version: 6.1.4
|
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-06-
|
11
|
+
date: 2021-06-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: discordrb
|