summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNatrixAeria <upezu@student.kit.edu>2020-10-15 21:33:14 +0200
committerNatrixAeria <upezu@student.kit.edu>2020-10-15 21:33:59 +0200
commit4c5f5101265238707c584979b25cdbd01bcf0d18 (patch)
tree6e7e35eca0dcefc62c39a363e32d29ea090feaf0
parent7a5778de58e371ff7f96f3dc1d2dc58854a3eb1d (diff)
Add a panel for game members
-rw-r--r--bot.py14
-rw-r--r--commands.py14
-rw-r--r--config.py6
3 files changed, 31 insertions, 3 deletions
diff --git a/bot.py b/bot.py
index bf27e58..f29af92 100644
--- a/bot.py
+++ b/bot.py
@@ -78,8 +78,18 @@ class Cupido(commands.Bot):
except discord.errors.NotFound:
return False
- async def send_panel(self, ctx, user):
- pass
+ async def send_panel(self, ctx, user, members):
+ channel = user.dm_channel or await user.create_dm()
+ text = config.PANEL_TEXT
+ n = 0
+ for member in members:
+ if member == user:
+ continue
+ name = discord.utils.escape_markdown(discord.utils.escape_mentions(member.nick), ignore_links=False)
+ text += f'\n * {config.EMOJI_POOL[n]} {name}'
+ n += 1
+ embed = discord.Embed(title=config.PANEL_TITLE, type="rich", description=text, colour=discord.Colour.purple())
+ await channel.send(embed=embed)
async def destroy_pair_channels(self, ctx, meta_channel):
await await_n(map(self.try_delete_channel, self.get_pair_channels_no_cache(ctx, meta_channel)))
diff --git a/commands.py b/commands.py
index 5bef7fa..2739445 100644
--- a/commands.py
+++ b/commands.py
@@ -36,6 +36,7 @@ async def init(ctx: commands.Context):
@commands.command(help=f'destruct all {config.NAME} channels', aliases=('kill', 'desctruction', 'genocide', '-'))
async def destroy(ctx: commands.Context):
+ await stop(ctx)
futures = []
meta_channel = ctx.bot.get_meta_channel(ctx)
for channel in (ctx.bot.get_lobby_channel(ctx, meta_channel), meta_channel):
@@ -70,7 +71,18 @@ async def shuffle(ctx: commands.Context, channel_size=2):
for i, _ in enumerate(ctx.bot.pair_channels):
slots.extend([i] * channel_size)
random.shuffle(slots)
- futures = [members.pop().move_to(ctx.bot.pair_channels[slot]) for slot in slots]
+ futures = []
+ group_members = [[] for _ in ctx.bot.pair_channels]
+ slot_members = []
+ for slot in slots:
+ member = members.pop()
+ channel = ctx.bot.pair_channels[slot]
+ futures.append(member.move_to(channel))
+ group_members[slot].append(member)
+ slot_members.append(member)
+ for member, slot in zip(slot_members, slots):
+ group = group_members[slot]
+ await ctx.bot.send_panel(ctx, member, group)
if members:
await answer(ctx, 'warning: not all members got shuffeled')
await await_n(futures)
diff --git a/config.py b/config.py
index 0b7987a..f59cb71 100644
--- a/config.py
+++ b/config.py
@@ -18,3 +18,9 @@ LOBBY_CHANNEL_TOPIC = "You wanna get shuffled? You're at the right place!"
DEFAULT_LOOP_TIME = 120
# time that cycles, that "loop" passes
DEFAULT_LOOP_COUNT = 3
+
+EMOJI_POOL = [':mouse:', ':broccoli:', ':archery:', ':tent:', ':coffee:']
+PANEL_TITLE = f'{NAME.title()} control panel'
+PANEL_TEXT = '''
+You have the choice!
+If you think, there are imposters among us, add a reaction with the corresponding emoji:'''