qwtf_discord_bot 5.3.2 → 5.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/qwtf_discord_bot/qwtf_discord_bot_pug.rb +50 -16
- 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: 601af47db687365971e97efd281732ed5effb977d1cd0d451aeda38be1ab27df
|
4
|
+
data.tar.gz: 2d06e9cb9f311d0b427445760a13729df7f8a59b582ed8c536e219137c930a25
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b67d9dcc35b75b0ea64dc482df3f0c2d9e180aa70288b9ebb98f2c58016e08d9eb504a542cfaf2e51e449a40e3dda33f9ed05da992c226f5a0f465dc1805f951
|
7
|
+
data.tar.gz: 3a75ce85122e1d3db1e2dc8dfa5dc7f3c614633f2506353d31cee66a7db2d09d29fe9130030f036885ed8d56fcbea776fdb5ad087251ae75698f8239ebf87e43
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
5.3.
|
1
|
+
5.3.3
|
@@ -105,7 +105,7 @@ class QwtfDiscordBotPug # :nodoc:
|
|
105
105
|
next
|
106
106
|
end
|
107
107
|
|
108
|
-
user_id = arg
|
108
|
+
user_id = mention_to_user_id(arg)
|
109
109
|
display_name = e.display_name_for(user_id) || arg
|
110
110
|
|
111
111
|
unless pug.joined?(user_id)
|
@@ -134,23 +134,53 @@ class QwtfDiscordBotPug # :nodoc:
|
|
134
134
|
|
135
135
|
bot.command :team do |event, *args|
|
136
136
|
setup_pug(event) do |e, pug|
|
137
|
+
return send_msg("Which team? E.G. `!team 1`", e.channel) unless args.any?
|
138
|
+
|
137
139
|
team_no = args[0].to_i
|
138
140
|
return send_msg("Choose a team between 1 and 4", e.channel) unless team_no.between?(1, 4)
|
139
141
|
|
140
|
-
|
141
|
-
return send_msg("You're already in team #{team_no}", e.channel) if pug.team(team_no).include?(user_id)
|
142
|
+
pug_already_full = pug.full?
|
142
143
|
|
143
|
-
|
144
|
-
|
144
|
+
if args.count == 1
|
145
|
+
user_id = e.user_id
|
146
|
+
return send_msg("You're already in team #{team_no}", e.channel) if pug.team(team_no).include?(user_id)
|
145
147
|
|
146
|
-
|
147
|
-
|
148
|
-
"#{e.display_name} joins team #{team_no}",
|
149
|
-
"#{pug.team_player_count(team_no)}/#{pug.teamsize}"
|
150
|
-
].join(MSG_SNIPPET_DELIMITER), e.channel
|
151
|
-
)
|
148
|
+
join_pug(e, pug) unless pug.joined?(user_id)
|
149
|
+
pug.join_team(team_no: team_no, player_id: user_id)
|
152
150
|
|
153
|
-
|
151
|
+
send_msg(
|
152
|
+
[
|
153
|
+
"#{e.display_name} joins team #{team_no}",
|
154
|
+
"#{pug.team_player_count(team_no)}/#{pug.teamsize}"
|
155
|
+
].join(MSG_SNIPPET_DELIMITER), e.channel
|
156
|
+
)
|
157
|
+
else
|
158
|
+
args[1..-1].each do |mention|
|
159
|
+
unless mention.match(/<@!\d+>/)
|
160
|
+
send_msg("#{arg} isn't a valid mention", e.channel)
|
161
|
+
next
|
162
|
+
end
|
163
|
+
|
164
|
+
user_id = mention_to_user_id(mention)
|
165
|
+
display_name = e.display_name_for(user_id) || arg
|
166
|
+
|
167
|
+
unless pug.joined?(user_id)
|
168
|
+
send_msg("#{display_name} isn't in the PUG", e.channel)
|
169
|
+
next
|
170
|
+
end
|
171
|
+
|
172
|
+
pug.join_team(team_no: team_no, player_id: user_id)
|
173
|
+
|
174
|
+
send_msg(
|
175
|
+
[
|
176
|
+
"#{display_name} joins team #{team_no}",
|
177
|
+
"#{pug.team_player_count(team_no)}/#{pug.teamsize}"
|
178
|
+
].join(MSG_SNIPPET_DELIMITER), e.channel
|
179
|
+
)
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
start_pug(pug, e) if !pug_already_full && pug.full?
|
154
184
|
end
|
155
185
|
end
|
156
186
|
|
@@ -179,8 +209,8 @@ class QwtfDiscordBotPug # :nodoc:
|
|
179
209
|
memo.merge({ id => e.display_name_for(id) })
|
180
210
|
end
|
181
211
|
|
182
|
-
|
183
|
-
|
212
|
+
result = winning_team_no.to_i == name.to_i ? 1 : -1
|
213
|
+
teams.merge({ name => { players: players, result: result } })
|
184
214
|
end
|
185
215
|
|
186
216
|
post_results(
|
@@ -215,7 +245,7 @@ class QwtfDiscordBotPug # :nodoc:
|
|
215
245
|
memo.merge({ id => e.display_name_for(id) })
|
216
246
|
end
|
217
247
|
|
218
|
-
|
248
|
+
teams.merge({ name => { players: players, result: 0 } })
|
219
249
|
end
|
220
250
|
|
221
251
|
post_results(
|
@@ -307,6 +337,10 @@ class QwtfDiscordBotPug # :nodoc:
|
|
307
337
|
|
308
338
|
private
|
309
339
|
|
340
|
+
def mention_to_user_id(mention)
|
341
|
+
mention[3..-2].to_i
|
342
|
+
end
|
343
|
+
|
310
344
|
def join_pug(e, pug)
|
311
345
|
pug.join(e.user_id)
|
312
346
|
|
@@ -390,7 +424,7 @@ class QwtfDiscordBotPug # :nodoc:
|
|
390
424
|
uri = URI("#{ENV['RATINGS_API_URL']}matches/")
|
391
425
|
req = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')
|
392
426
|
req.body = json
|
393
|
-
|
427
|
+
Net::HTTP.start(uri.hostname, uri.port) do |http|
|
394
428
|
http.request(req)
|
395
429
|
end
|
396
430
|
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.3.
|
4
|
+
version: 5.3.3
|
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-10-
|
11
|
+
date: 2020-10-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: discordrb
|