qwtf_discord_bot 5.1.8 → 5.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/VERSION +1 -1
- data/lib/event_decorator.rb +3 -1
- data/lib/pug.rb +25 -7
- data/lib/qwtf_discord_bot/qwtf_discord_bot_pug.rb +25 -25
- 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: 874aab5dba875e61f9dfd5500d91a25149a7b08a8a91854402080d4775cc1b24
|
4
|
+
data.tar.gz: e68aa880053d9bffbfb563fa6bcdaa060b89d91051e6955615f89543a30e1530
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aae1ed1e4fa7e631a4903fb7fdfb933b51bf127ee3de0d3b8497f39d3d6d36c16dcd23db18664a724375bb454ac60bca7467ce0f34bfbcfe7c55b278ece01660
|
7
|
+
data.tar.gz: 7426320e57d72affc5170ed20a7cd4a0d0ff1711c2103cfe88c85d8c646e5900725860d4c8644653cc53ce610a8f0b18cd88e1db8550d96c80df05e271532f72
|
data/README.md
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
5.1.
|
1
|
+
5.1.9
|
data/lib/event_decorator.rb
CHANGED
data/lib/pug.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
class Pug
|
2
|
-
|
2
|
+
DEFAULT_teamsize = 4
|
3
|
+
NO_OF_TEAMS = 2
|
3
4
|
|
4
5
|
def self.for(channel_id)
|
5
6
|
new(channel_id)
|
@@ -18,6 +19,15 @@ class Pug
|
|
18
19
|
redis.smembers(players_key).map(&:to_i)
|
19
20
|
end
|
20
21
|
|
22
|
+
def team(no)
|
23
|
+
index = no - 1
|
24
|
+
joined_players.each_slice(teamsize).to_a[index]
|
25
|
+
end
|
26
|
+
|
27
|
+
def teamsize=(teamsize)
|
28
|
+
redis.set(teamsize_key, teamsize)
|
29
|
+
end
|
30
|
+
|
21
31
|
def full?
|
22
32
|
joined_player_count >= maxplayers
|
23
33
|
end
|
@@ -42,12 +52,12 @@ class Pug
|
|
42
52
|
redis.get(notify_roles_key) || "@here"
|
43
53
|
end
|
44
54
|
|
45
|
-
def
|
46
|
-
redis.set(
|
55
|
+
def teamsize=(teamsize)
|
56
|
+
redis.set(teamsize_key, teamsize)
|
47
57
|
end
|
48
58
|
|
49
|
-
def
|
50
|
-
(redis.get(
|
59
|
+
def teamsize
|
60
|
+
(redis.get(teamsize_key) || DEFAULT_teamsize).to_i
|
51
61
|
end
|
52
62
|
|
53
63
|
def active?
|
@@ -68,14 +78,18 @@ class Pug
|
|
68
78
|
joined_players.include?(player_id)
|
69
79
|
end
|
70
80
|
|
81
|
+
def maxplayers
|
82
|
+
teamsize * NO_OF_TEAMS
|
83
|
+
end
|
84
|
+
|
71
85
|
private
|
72
86
|
|
73
87
|
def empty?
|
74
88
|
joined_player_count.zero?
|
75
89
|
end
|
76
90
|
|
77
|
-
def
|
78
|
-
[pug_key, "
|
91
|
+
def teamsize_key
|
92
|
+
[pug_key, "teamsize"].join(":")
|
79
93
|
end
|
80
94
|
|
81
95
|
def players_key
|
@@ -90,6 +104,10 @@ class Pug
|
|
90
104
|
[pug_key, "role"].join(":")
|
91
105
|
end
|
92
106
|
|
107
|
+
def teamsize_key
|
108
|
+
[pug_key, "teamsize"].join(":")
|
109
|
+
end
|
110
|
+
|
93
111
|
def redis
|
94
112
|
Redis.current
|
95
113
|
end
|
@@ -42,14 +42,7 @@ class QwtfDiscordBotPug # :nodoc:
|
|
42
42
|
|
43
43
|
message(message, e.channel)
|
44
44
|
|
45
|
-
if pug.full?
|
46
|
-
message = start_pug_message(
|
47
|
-
player_slots: pug.player_slots,
|
48
|
-
mentions: e.mentions_for(pug.joined_players)
|
49
|
-
)
|
50
|
-
|
51
|
-
message(message, e.channel)
|
52
|
-
end
|
45
|
+
start_pug(pug, e) if pug.full?
|
53
46
|
end
|
54
47
|
end
|
55
48
|
|
@@ -68,26 +61,22 @@ class QwtfDiscordBotPug # :nodoc:
|
|
68
61
|
end
|
69
62
|
end
|
70
63
|
|
71
|
-
bot.command :
|
64
|
+
bot.command :teamsize do |event, *args|
|
72
65
|
setup_pug(event) do |e, pug|
|
73
|
-
|
66
|
+
new_teamsize = args[0]
|
74
67
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
player_slots: pug.player_slots,
|
87
|
-
mentions: e.mentions_for(pug.joined_players)
|
68
|
+
if new_teamsize
|
69
|
+
pug.teamsize = new_teamsize
|
70
|
+
message(
|
71
|
+
"Team size set to #{pug.teamsize} | #{pug.player_slots} joined",
|
72
|
+
e.channel
|
73
|
+
)
|
74
|
+
start_pug(pug, e) if pug.full?
|
75
|
+
else
|
76
|
+
message(
|
77
|
+
"Current team size is #{pug.teamsize} | #{pug.player_slots} joined",
|
78
|
+
e.channel
|
88
79
|
)
|
89
|
-
|
90
|
-
message(message, e.channel)
|
91
80
|
end
|
92
81
|
end
|
93
82
|
end
|
@@ -174,6 +163,17 @@ class QwtfDiscordBotPug # :nodoc:
|
|
174
163
|
nil # stop discordrb printing return value
|
175
164
|
end
|
176
165
|
|
166
|
+
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
|
+
)
|
175
|
+
end
|
176
|
+
|
177
177
|
def start_pug_message(player_slots:, mentions:)
|
178
178
|
['Time to play!', player_slots, mentions.join(' ')].join(' | ')
|
179
179
|
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.
|
4
|
+
version: 5.1.9
|
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-
|
11
|
+
date: 2020-08-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: discordrb
|