qwtf_discord_bot 5.4.1 → 5.4.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a1d4b0223feae05745b7050dc8dc25193136bac78bee3fca74818559dad0dd7c
4
- data.tar.gz: 8a7b7a27d72b759ffa4111bdf85f73c0effae38c4db7c8164f5abca357912dd1
3
+ metadata.gz: a0ecc26e71f4325677ded724c87d1f3496d1207d2cbd662146c09caba5c0d397
4
+ data.tar.gz: 3b5392f1a58fbbad660b17f2d88f8f8d29220e637069a353745963fc264ad0f4
5
5
  SHA512:
6
- metadata.gz: b621a49eefc9ab5c83c93e771a00d609aa72be3b675e627aa9f502cd1646832e4cd892e67b0864bdea9a9dbcaf9f0b691a6f3df71f852179d21a28d760312c28
7
- data.tar.gz: 91ce0148eeb1a80d127bb722204153031087eb88b8460b64fab9004d834e0f96615bf605f35d3ef06a8df17ed23fdf4d863c1cbd0b2231070beb23e9b2b52dd7
6
+ metadata.gz: 45a536a9334a9caf56358b0b66aeffcdf9fc419e57e5ef09b33e0994b510e398bbeed76c9ba61d7513cc22dd4c3ebeca9c34e33de20aa70b8c5c340ae46c29d3
7
+ data.tar.gz: '018d569f3f282455e0e22cf73dac28f4dfb716242911a4130a7edefe41d598709da09d05efd086de5c41078eceb7ca8a4130f124926118f359480094c73b9015'
data/VERSION CHANGED
@@ -1 +1 @@
1
- 5.4.1
1
+ 5.4.2
@@ -13,7 +13,15 @@ class QwtfDiscordBotPug # :nodoc:
13
13
  token: QwtfDiscordBot.config.token,
14
14
  client_id: QwtfDiscordBot.config.client_id,
15
15
  help_command: false,
16
- prefix: '!'
16
+ prefix: proc do |message|
17
+ match = /^\!(\w+)(.*)/.match(message.content)
18
+ if match
19
+ first = match[1]
20
+ rest = match[2]
21
+ # Return the modified string with the first word lowercase:
22
+ "#{first.downcase}#{rest}"
23
+ end
24
+ end
17
25
  )
18
26
 
19
27
  bot.command :help do |event, *args|
@@ -22,7 +30,7 @@ class QwtfDiscordBotPug # :nodoc:
22
30
 
23
31
  bot.command :join do |event, *args|
24
32
  setup_pug(event) do |e, pug|
25
- return send_msg("You've already joined", e.channel) if pug.joined?(e.user_id)
33
+ return send_embedded_message("You've already joined", e.channel) if pug.joined?(e.user_id)
26
34
 
27
35
  join_pug(e, pug)
28
36
  start_pug(pug, e) if pug.full?
@@ -31,9 +39,9 @@ class QwtfDiscordBotPug # :nodoc:
31
39
 
32
40
  bot.command :status do |event, *args|
33
41
  setup_pug(event) do |e, pug|
34
- return send_msg('No PUG has been started. `!join` to create', e.channel) unless pug.active?
42
+ return send_embedded_message('No PUG has been started. `!join` to create', e.channel) unless pug.active?
35
43
 
36
- send_msg(
44
+ send_embedded_message(
37
45
  [
38
46
  "#{pug.player_slots} joined",
39
47
  "Map: #{pug.game_map}",
@@ -46,15 +54,15 @@ class QwtfDiscordBotPug # :nodoc:
46
54
 
47
55
  bot.command :teamsize do |event, *args|
48
56
  setup_pug(event) do |e, pug|
49
- return send_msg("Team size is #{pug.teamsize}", e.channel) unless args.any?
57
+ return send_embedded_message("Team size is #{pug.teamsize}", e.channel) unless args.any?
50
58
 
51
59
  new_teamsize = args[0].to_i
52
- return send_msg('Team size should be a number higher than 0', e.channel) unless new_teamsize > 0
60
+ return send_embedded_message('Team size should be a number higher than 0', e.channel) unless new_teamsize > 0
53
61
 
54
62
  if new_teamsize
55
63
  pug.teamsize = new_teamsize
56
64
 
57
- send_msg(
65
+ send_embedded_message(
58
66
  [
59
67
  "Team size set to #{pug.teamsize}",
60
68
  "#{pug.player_slots} joined"
@@ -64,7 +72,7 @@ class QwtfDiscordBotPug # :nodoc:
64
72
 
65
73
  start_pug(pug, e) if pug.full?
66
74
  else
67
- send_msg(
75
+ send_embedded_message(
68
76
  [
69
77
  "Current team size is #{pug.teamsize}",
70
78
  "#{pug.player_slots} joined"
@@ -77,8 +85,8 @@ class QwtfDiscordBotPug # :nodoc:
77
85
 
78
86
  bot.command :leave do |event, *args|
79
87
  setup_pug(event) do |e, pug|
80
- return send_msg(no_active_pug_message, e.channel) unless pug.active?
81
- return send_msg("You're not in the PUG", e.channel) unless pug.joined?(e.user_id)
88
+ return send_embedded_message(no_active_pug_message, e.channel) unless pug.active?
89
+ return send_embedded_message("You're not in the PUG", e.channel) unless pug.joined?(e.user_id)
82
90
 
83
91
  pug.leave(e.user_id)
84
92
 
@@ -89,7 +97,7 @@ class QwtfDiscordBotPug # :nodoc:
89
97
 
90
98
  snippets << "#{pug.slots_left} more #{pug.notify_roles}" if pug.slots_left == 1
91
99
 
92
- send_msg(
100
+ send_embedded_message(
93
101
  snippets.join(MSG_SNIPPET_DELIMITER),
94
102
  e.channel
95
103
  )
@@ -100,12 +108,12 @@ class QwtfDiscordBotPug # :nodoc:
100
108
 
101
109
  bot.command :kick do |event, *args|
102
110
  setup_pug(event) do |e, pug|
103
- return send_msg("Kick who? e.g. `!kick @#{e.display_name}`", e.channel) unless args.any?
104
- return send_msg(no_active_pug_message, e.channel) unless pug.active?
111
+ return send_embedded_message("Kick who? e.g. `!kick @#{e.display_name}`", e.channel) unless args.any?
112
+ return send_embedded_message(no_active_pug_message, e.channel) unless pug.active?
105
113
 
106
114
  args.each do |arg|
107
115
  unless arg.match(/<@!\d+>/)
108
- send_msg("#{arg} isn't a valid mention", e.channel)
116
+ send_embedded_message("#{arg} isn't a valid mention", e.channel)
109
117
  next
110
118
  end
111
119
 
@@ -113,7 +121,7 @@ class QwtfDiscordBotPug # :nodoc:
113
121
  display_name = e.display_name_for(user_id) || arg
114
122
 
115
123
  unless pug.joined?(user_id)
116
- send_msg("#{display_name} isn't in the PUG", e.channel)
124
+ send_embedded_message("#{display_name} isn't in the PUG", e.channel)
117
125
  next
118
126
  end
119
127
 
@@ -126,7 +134,7 @@ class QwtfDiscordBotPug # :nodoc:
126
134
 
127
135
  snippets << "#{pug.slots_left} more #{pug.notify_roles}" if pug.slots_left == 1
128
136
 
129
- send_msg(
137
+ send_embedded_message(
130
138
  snippets.join(MSG_SNIPPET_DELIMITER),
131
139
  e.channel
132
140
  )
@@ -138,20 +146,20 @@ class QwtfDiscordBotPug # :nodoc:
138
146
 
139
147
  bot.command :team do |event, *args|
140
148
  setup_pug(event) do |e, pug|
141
- return send_msg("Which team? E.G. `!team 1`", e.channel) unless args.any?
142
- return send_msg("Choose a team between 0 and 2", e.channel) unless ["0", "1", "2"].any?(args.first)
149
+ return send_embedded_message("Which team? E.G. `!team 1`", e.channel) unless args.any?
150
+ return send_embedded_message("Choose a team between 0 and 2", e.channel) unless ["0", "1", "2"].any?(args.first)
143
151
 
144
152
  team_no = args.first.to_i
145
153
  pug_already_full = pug.full?
146
154
 
147
155
  if args.count == 1
148
156
  user_id = e.user_id
149
- return send_msg("You're already in team #{team_no}", e.channel) if pug.team(team_no).include?(user_id)
157
+ return send_embedded_message("You're already in team #{team_no}", e.channel) if pug.team(team_no).include?(user_id)
150
158
 
151
159
  join_pug(e, pug) unless pug.joined?(user_id)
152
160
  pug.join_team(team_no: team_no, player_id: user_id)
153
161
 
154
- send_msg(
162
+ send_embedded_message(
155
163
  [
156
164
  "#{e.display_name} joins team #{team_no}",
157
165
  "#{pug.team_player_count(team_no)}/#{pug.teamsize}"
@@ -160,7 +168,7 @@ class QwtfDiscordBotPug # :nodoc:
160
168
  else
161
169
  args[1..-1].each do |mention|
162
170
  unless mention.match(/<@!\d+>/)
163
- send_msg("#{arg} isn't a valid mention", e.channel)
171
+ send_embedded_message("#{arg} isn't a valid mention", e.channel)
164
172
  next
165
173
  end
166
174
 
@@ -168,13 +176,13 @@ class QwtfDiscordBotPug # :nodoc:
168
176
  display_name = e.display_name_for(user_id) || arg
169
177
 
170
178
  unless pug.joined?(user_id)
171
- send_msg("#{display_name} isn't in the PUG", e.channel)
179
+ send_embedded_message("#{display_name} isn't in the PUG", e.channel)
172
180
  next
173
181
  end
174
182
 
175
183
  pug.join_team(team_no: team_no, player_id: user_id)
176
184
 
177
- send_msg(
185
+ send_embedded_message(
178
186
  [
179
187
  "#{display_name} joins team #{team_no}",
180
188
  "#{pug.team_player_count(team_no)}/#{pug.teamsize}"
@@ -190,25 +198,25 @@ class QwtfDiscordBotPug # :nodoc:
190
198
  bot.command :unteam do |event, *args|
191
199
  setup_pug(event) do |e, pug|
192
200
  user_id = e.user_id
193
- return send_msg('No PUG has been started. `!join` to create', e.channel) unless pug.active?
194
- return send_msg("You aren't in this PUG", e.channel) unless pug.joined?(user_id)
195
- return send_msg("You aren't in a team", e.channel) if pug.team(0).include?(user_id)
201
+ return send_embedded_message('No PUG has been started. `!join` to create', e.channel) unless pug.active?
202
+ return send_embedded_message("You aren't in this PUG", e.channel) unless pug.joined?(user_id)
203
+ return send_embedded_message("You aren't in a team", e.channel) if pug.team(0).include?(user_id)
196
204
 
197
205
  pug.join_team(team_no: 0, player_id: user_id)
198
- send_msg("#{e.display_name} has no team", e.channel)
206
+ send_embedded_message("#{e.display_name} has no team", e.channel)
199
207
  end
200
208
  end
201
209
 
202
210
  bot.command :win do |event, *args|
203
211
  setup_pug(event) do |e, pug|
204
- return send_msg(no_active_pug_message, e.channel) unless pug.active?
212
+ return send_embedded_message(no_active_pug_message, e.channel) unless pug.active?
205
213
 
206
214
  winning_team_no = args[0]
207
215
 
208
- return send_msg("Not a valid team", e.channel) unless pug.team(winning_team_no).any?
216
+ return send_embedded_message("Not a valid team", e.channel) unless pug.team(winning_team_no).any?
209
217
 
210
218
  if pug.actual_teams.count < 2
211
- return send_msg(
219
+ return send_embedded_message(
212
220
  "There must be at least two teams with players to submit a result", e.channel
213
221
  )
214
222
  end
@@ -245,16 +253,16 @@ class QwtfDiscordBotPug # :nodoc:
245
253
  # e.display_name_for(player_id)
246
254
  # end
247
255
 
248
- send_msg("Team #{winning_team_no} wins", e.channel)
256
+ send_embedded_message("Team #{winning_team_no} wins", e.channel)
249
257
  end
250
258
  end
251
259
 
252
260
  bot.command :draw do |event, *args|
253
261
  setup_pug(event) do |e, pug|
254
- return send_msg(no_active_pug_message, e.channel) unless pug.active?
262
+ return send_embedded_message(no_active_pug_message, e.channel) unless pug.active?
255
263
 
256
264
  if pug.actual_teams.count < 2
257
- return send_msg(
265
+ return send_embedded_message(
258
266
  "There must be at least two teams with players to submit a result", e.channel
259
267
  )
260
268
  end
@@ -280,13 +288,13 @@ class QwtfDiscordBotPug # :nodoc:
280
288
  }.to_json
281
289
  )
282
290
 
283
- send_msg("Match drawn", e.channel)
291
+ send_embedded_message("Match drawn", e.channel)
284
292
  end
285
293
  end
286
294
 
287
295
  bot.command :end do |event, *args|
288
296
  setup_pug(event) do |e, pug|
289
- return send_msg(no_active_pug_message, e.channel) unless pug.active?
297
+ return send_embedded_message(no_active_pug_message, e.channel) unless pug.active?
290
298
 
291
299
  end_pug(pug, e.channel)
292
300
  end
@@ -295,47 +303,47 @@ class QwtfDiscordBotPug # :nodoc:
295
303
  bot.command :addmap do |event, *args|
296
304
  setup_pug(event) do |e, pug|
297
305
  maps = args
298
- return send_msg("What map? e.g. `!addmap 2fort5r`", e.channel) unless maps.any?
306
+ return send_embedded_message("What map? e.g. `!addmap 2fort5r`", e.channel) unless maps.any?
299
307
 
300
308
  pug.add_maps(maps)
301
- send_msg("#{maps.join(', ')} added to maps", e.channel)
309
+ send_embedded_message("#{maps.join(', ')} added to maps", e.channel)
302
310
  end
303
311
  end
304
312
 
305
313
  bot.command :removemap do |event, *args|
306
314
  setup_pug(event) do |e, pug|
307
315
  maps = args
308
- return send_msg("What map? e.g. `!removemap 2fort5r`", e.channel) unless maps.any?
316
+ return send_embedded_message("What map? e.g. `!removemap 2fort5r`", e.channel) unless maps.any?
309
317
 
310
318
  pug.remove_maps(maps)
311
- send_msg("#{maps.join(', ')} removed from maps", e.channel)
319
+ send_embedded_message("#{maps.join(', ')} removed from maps", e.channel)
312
320
  end
313
321
  end
314
322
 
315
323
  bot.command :maps do |event, *args|
316
324
  setup_pug(event) do |e, pug|
317
325
  maps = pug.maps
318
- return send_msg('No maps have been added. `!addmap`', e.channel) unless maps.any?
326
+ return send_embedded_message('No maps have been added. `!addmap`', e.channel) unless maps.any?
319
327
 
320
- send_msg(maps.join(', '), e.channel)
328
+ send_embedded_message(maps.join(', '), e.channel)
321
329
  end
322
330
  end
323
331
 
324
332
  bot.command :map do |event, *args|
325
333
  setup_pug(event) do |e, pug|
326
334
  maps = pug.maps
327
- return send_msg('No maps have been added. `!addmap`', e.channel) unless maps.any?
328
- return send_msg(no_active_pug_message, e.channel) unless pug.active?
335
+ return send_embedded_message('No maps have been added. `!addmap`', e.channel) unless maps.any?
336
+ return send_embedded_message(no_active_pug_message, e.channel) unless pug.active?
329
337
 
330
338
  if args.empty?
331
- return send_msg('No map has been set for the current PUG', e.channel) unless pug.game_map
332
- send_msg("Current map is #{pug.game_map}", e.channel)
339
+ return send_embedded_message('No map has been set for the current PUG', e.channel) unless pug.game_map
340
+ send_embedded_message("Current map is #{pug.game_map}", e.channel)
333
341
  else
334
342
  game_map = args.first
335
- return send_msg("#{game_map} isn't in the map list. `!addmap` to add it.", e.channel) unless maps.include?(game_map)
343
+ return send_embedded_message("#{game_map} isn't in the map list. `!addmap` to add it.", e.channel) unless maps.include?(game_map)
336
344
 
337
345
  pug.game_map = game_map
338
- send_msg("Map set to #{game_map}", e.channel)
346
+ send_embedded_message("Map set to #{game_map}", e.channel)
339
347
  end
340
348
  end
341
349
  end
@@ -351,7 +359,7 @@ class QwtfDiscordBotPug # :nodoc:
351
359
  "Notification role set to #{roles}"
352
360
  end
353
361
 
354
- send_msg(msg, e.channel)
362
+ send_embedded_message(msg, e.channel)
355
363
  end
356
364
  end
357
365
 
@@ -374,7 +382,7 @@ class QwtfDiscordBotPug # :nodoc:
374
382
  snippets << "#{pug.slots_left} more #{pug.notify_roles}" if pug.slots_left.between?(1, 3)
375
383
  end
376
384
 
377
- send_msg(snippets.join(MSG_SNIPPET_DELIMITER), e.channel)
385
+ send_embedded_message(snippets.join(MSG_SNIPPET_DELIMITER), e.channel)
378
386
  end
379
387
 
380
388
  def setup_pug(event)
@@ -412,7 +420,7 @@ class QwtfDiscordBotPug # :nodoc:
412
420
  pug_teams
413
421
  ].join("\n")
414
422
 
415
- send_msg(msg, event.channel)
423
+ send_embedded_message(msg, event.channel)
416
424
  end
417
425
 
418
426
  def pug_teams_message(pug, event)
@@ -442,15 +450,17 @@ class QwtfDiscordBotPug # :nodoc:
442
450
 
443
451
  def end_pug(pug, channel_id)
444
452
  pug.end_pug
445
- send_msg('PUG ended', channel_id)
453
+ send_embedded_message('PUG ended', channel_id)
446
454
  end
447
455
 
448
456
  def no_active_pug_message
449
457
  "There's no active PUG"
450
458
  end
451
459
 
452
- def send_msg(message, channel)
453
- channel.send_message(message) && puts(message)
460
+ def send_embedded_message(message, channel)
461
+ embed = Discordrb::Webhooks::Embed.new
462
+ embed.description = message
463
+ channel.send_embed(nil, embed) && puts(message)
454
464
  end
455
465
 
456
466
  def post_results(json)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qwtf_discord_bot
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.4.1
4
+ version: 5.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sheldon Johnson