qwtf_discord_bot 5.1.9 → 5.1.11

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: 874aab5dba875e61f9dfd5500d91a25149a7b08a8a91854402080d4775cc1b24
4
- data.tar.gz: e68aa880053d9bffbfb563fa6bcdaa060b89d91051e6955615f89543a30e1530
3
+ metadata.gz: 9f929cda85f6a53ffc63d04e3a85b6ca4bcbcadf72b2c0ab70eab8a1a549843a
4
+ data.tar.gz: 45b0e4b9bba67fdfb8139d3904176ce3443d43ea7cb74c750588f4eb6ea1fb8d
5
5
  SHA512:
6
- metadata.gz: aae1ed1e4fa7e631a4903fb7fdfb933b51bf127ee3de0d3b8497f39d3d6d36c16dcd23db18664a724375bb454ac60bca7467ce0f34bfbcfe7c55b278ece01660
7
- data.tar.gz: 7426320e57d72affc5170ed20a7cd4a0d0ff1711c2103cfe88c85d8c646e5900725860d4c8644653cc53ce610a8f0b18cd88e1db8550d96c80df05e271532f72
6
+ metadata.gz: cca2b1392fbbdca102e22ea27e79774da07478e5cfa2a9a2ee14c4b6ae48ae1ea3c8e4c8906461d123a1f32f3e2e0cef519f107a3b7abf42d1853a5e870bf342
7
+ data.tar.gz: d29bd7a09c9ffed879429965497118d0f63332bac8084c83ea498601d924d11227adad67694de73f97658b73ed9c7c90236fc855bb8c82a809a522fe0ecb78f6
data/VERSION CHANGED
@@ -1 +1 @@
1
- 5.1.9
1
+ 5.1.11
@@ -34,7 +34,7 @@ class EventDecorator
34
34
  end
35
35
 
36
36
  def display_name_for(user_id)
37
- find_user(user_id).display_name
37
+ find_user(user_id) && find_user(user_id).display_name
38
38
  end
39
39
 
40
40
  private
@@ -16,31 +16,18 @@ class QwtfDiscordBotPug # :nodoc:
16
16
 
17
17
  bot.command :join do |event, *args|
18
18
  setup_pug(event) do |e, pug|
19
- return message("You've already joined", e.channel) if pug.joined?(e.user_id)
19
+ return send_msg("You've already joined", e.channel) if pug.joined?(e.user_id)
20
20
 
21
21
  pug.join(e.user_id)
22
22
 
23
- message = if pug.joined_player_count == 1
24
- [
25
- "#{e.display_name} creates a PUG",
26
- pug.player_slots,
27
- pug.notify_roles
28
- ].join(' | ')
29
- elsif pug.slots_left.between?(1, 3)
30
- [
31
- "#{e.display_name} joins the PUG",
32
- pug.player_slots,
33
- "#{pug.slots_left} more",
34
- pug.notify_roles
35
- ].join(' | ')
36
- else
37
- [
38
- "#{e.display_name} joins the PUG",
39
- pug.player_slots
40
- ].join(' | ')
41
- end
42
-
43
- message(message, e.channel)
23
+ if pug.joined_player_count == 1
24
+ snippets = ["#{e.display_name} creates a PUG", pug.player_slots, pug.notify_roles]
25
+ else
26
+ snippets = ["#{e.display_name} joins the PUG", pug.player_slots]
27
+ snippets << "#{pug.slots_left} more #{pug.notify_roles}" if pug.slots_left.between?(1, 3)
28
+ end
29
+
30
+ send_msg(snippets.join(' | '), e.channel)
44
31
 
45
32
  start_pug(pug, e) if pug.full?
46
33
  end
@@ -48,16 +35,16 @@ class QwtfDiscordBotPug # :nodoc:
48
35
 
49
36
  bot.command :status do |event, *args|
50
37
  setup_pug(event) do |e, pug|
51
- message = if pug.active?
52
- [
53
- "#{e.display_names_for(pug.joined_players).join(', ')} joined",
54
- pug.player_slots
55
- ].join(' | ')
56
- else
57
- 'No PUG has been started. `!join` to create'
58
- end
59
-
60
- message(message, e.channel)
38
+ msg = if pug.active?
39
+ [
40
+ "#{e.display_names_for(pug.joined_players).join(', ')} joined",
41
+ pug.player_slots
42
+ ].join(' | ')
43
+ else
44
+ 'No PUG has been started. `!join` to create'
45
+ end
46
+
47
+ send_msg(msg, e.channel)
61
48
  end
62
49
  end
63
50
 
@@ -67,13 +54,15 @@ class QwtfDiscordBotPug # :nodoc:
67
54
 
68
55
  if new_teamsize
69
56
  pug.teamsize = new_teamsize
70
- message(
57
+
58
+ send_msg(
71
59
  "Team size set to #{pug.teamsize} | #{pug.player_slots} joined",
72
60
  e.channel
73
61
  )
62
+
74
63
  start_pug(pug, e) if pug.full?
75
64
  else
76
- message(
65
+ send_msg(
77
66
  "Current team size is #{pug.teamsize} | #{pug.player_slots} joined",
78
67
  e.channel
79
68
  )
@@ -83,56 +72,71 @@ class QwtfDiscordBotPug # :nodoc:
83
72
 
84
73
  bot.command :leave do |event, *args|
85
74
  setup_pug(event) do |e, pug|
86
- return message(no_active_pug_message, e.channel) unless pug.active?
87
- return message("You're not in the PUG", e.channel) unless pug.joined?(e.user_id)
75
+ return send_msg(no_active_pug_message, e.channel) unless pug.active?
76
+ return send_msg("You're not in the PUG", e.channel) unless pug.joined?(e.user_id)
88
77
 
89
78
  pug.leave(e.user_id)
90
79
 
91
- message(
92
- "#{e.display_name} leaves the PUG | #{pug.player_slots} remain",
80
+ snippets = [
81
+ "#{e.display_name} leaves the PUG",
82
+ "#{pug.player_slots} remain"
83
+ ]
84
+
85
+ snippets << "#{pug.slots_left} more #{pug.notify_roles}" if pug.slots_left == 1
86
+
87
+ send_msg(
88
+ snippets.join(' | '),
93
89
  e.channel
94
90
  )
95
91
 
96
- message(end_pug_message, e.channel) unless pug.active?
92
+ send_msg(end_pug_message, e.channel) unless pug.active?
97
93
  end
98
94
  end
99
95
 
100
96
  bot.command :kick do |event, *args|
101
97
  setup_pug(event) do |e, pug|
102
- return message(no_active_pug_message, e.channel) unless pug.active?
98
+ return send_msg(no_active_pug_message, e.channel) unless pug.active?
103
99
 
104
- args.each do |mention|
105
- user_id = mention[3..-2].to_i
106
- display_name = e.display_name_for(user_id)
100
+ args.each do |arg|
101
+ unless arg.match(/<@!\d+>/)
102
+ send_msg("#{arg} isn't a valid mention", e.channel)
103
+ next
104
+ end
107
105
 
108
- unless pug.joined?(user_id)
109
- message(
110
- "#{display_name} isn't in the PUG",
111
- e.channel
112
- )
106
+ user_id = arg[3..-2].to_i
107
+ display_name = e.display_name_for(user_id) || arg
113
108
 
109
+ unless pug.joined?(user_id)
110
+ send_msg("#{display_name} isn't in the PUG", e.channel)
114
111
  next
115
112
  end
116
113
 
117
114
  pug.leave(user_id)
118
115
 
119
- message(
120
- "#{display_name} is kicked from the PUG | #{pug.player_slots} remain",
116
+ snippets = [
117
+ "#{display_name} is kicked from the PUG",
118
+ "#{pug.player_slots} remain"
119
+ ]
120
+
121
+ snippets << "#{pug.slots_left} more #{pug.notify_roles}" if pug.slots_left == 1
122
+
123
+ send_msg(
124
+ snippets.join(' | '),
121
125
  e.channel
122
126
  )
123
127
 
124
- break message(end_pug_message, e.channel) unless pug.active?
128
+ break send_msg(end_pug_message, e.channel) unless pug.active?
125
129
  end
126
130
  end
127
131
  end
128
132
 
129
133
  bot.command :end do |event, *args|
130
134
  setup_pug(event) do |e, pug|
131
- return message(no_active_pug_message, e.channel) unless pug.active?
135
+ return send_msg(no_active_pug_message, e.channel) unless pug.active?
132
136
 
133
137
  pug.end_pug
134
138
 
135
- message(end_pug_message, e.channel)
139
+ send_msg(end_pug_message, e.channel)
136
140
  end
137
141
  end
138
142
 
@@ -141,13 +145,13 @@ class QwtfDiscordBotPug # :nodoc:
141
145
  roles = args.join(' ')
142
146
  pug.notify_roles = roles
143
147
 
144
- message = if roles.empty?
145
- 'Notification removed'
146
- else
147
- "Notification role set to #{roles}"
148
- end
148
+ msg = if roles.empty?
149
+ 'Notification removed'
150
+ else
151
+ "Notification role set to #{roles}"
152
+ end
149
153
 
150
- message(message, e.channel)
154
+ send_msg(msg, e.channel)
151
155
  end
152
156
  end
153
157
 
@@ -164,17 +168,16 @@ class QwtfDiscordBotPug # :nodoc:
164
168
  end
165
169
 
166
170
  def start_pug(pug, event)
167
- message(
168
- [
169
- 'Time to play!',
170
- ['Team 1:', event.mentions_for(pug.team(1)).join(' ')].join(' '),
171
- ['Team 2:', event.mentions_for(pug.team(2)).join(' ')].join(' ')
172
- ].join("\n"),
173
- event.channel
174
- )
171
+ msg = [
172
+ 'Time to play!',
173
+ ['Team 1:', event.mentions_for(pug.team(1)).join(' ')].join(' '),
174
+ ['Team 2:', event.mentions_for(pug.team(2)).join(' ')].join(' ')
175
+ ].join("\n")
176
+
177
+ send_msg(msg, event.channel)
175
178
  end
176
179
 
177
- def start_pug_message(player_slots:, mentions:)
180
+ def start_pug_send_msg(player_slots:, mentions:)
178
181
  ['Time to play!', player_slots, mentions.join(' ')].join(' | ')
179
182
  end
180
183
 
@@ -186,7 +189,7 @@ class QwtfDiscordBotPug # :nodoc:
186
189
  "There's no active PUG"
187
190
  end
188
191
 
189
- def message(message, channel)
192
+ def send_msg(message, channel)
190
193
  channel.send_message(message) && puts(message)
191
194
  end
192
195
  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.1.9
4
+ version: 5.1.11
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-08-29 00:00:00.000000000 Z
11
+ date: 2020-08-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: discordrb