Compare commits

...

4 Commits
main ... python

1 changed files with 25 additions and 22 deletions

View File

@ -109,7 +109,9 @@ async def countdown(channel):
with open('config.json') as f:
config = json.load(f)
client = discord.Client()
intents = discord.Intents.default()
intents.members = True
client = discord.Client(intents=intents)
async def handle_guild_message(message):
if not message.content.startswith('!waggle'):
@ -181,33 +183,34 @@ async def handle_guild_message(message):
await message.channel.send("{} Welcome to pollination! You'll be randomly paired up, moved into separate voice channels, spend some time chatting, and then move to a new channel and meet somebody else. Each round will last 5 minutes, and there'll be {} rounds total. I'll announce when your time is nearly up so you can wrap up your conversations, and I'll automatically move you to a different voice channel at the start of each new round. If you keep this text channel open, you'll get audible countdowns via text-to-speech at the end of each round. **Feel free to leave at any time if you need to. You won't get moved into new voice channels if you disconnect from voice.** If you find yourself alone in a channel, the person you were paired with for that round may have left; just relax and take a break for 5 minutes. Have fun!".format(mention_all, len(schedule)))
first_round = True
for matching in schedule:
announcement = 'Next round starting in 30 seconds:\n'
announcement += '\n'.join('{0} and {1} in {2}'.format(a.mention, b.mention, c.name) for ((a, b), c) in zip(matching, pollination_channels))
await message.channel.send(announcement)
await countdown(message.channel)
await message.channel.send('Next round starting in 30 seconds:')
for ((a, b), c) in zip(matching, pollination_channels):
try:
await a.move_to(c)
except discord.DiscordException as e:
print('failed to move participant {}: {}'.format(a, e), file=sys.stderr)
try:
await b.move_to(c)
except discord.DiscordException as e:
print('failed to move participant {}: {}'.format(b, e), file=sys.stderr)
await message.channel.send('{0} and {1} in {2}'.format(a.mention, b.mention, c.name))
await countdown(message.channel)
for (pair, c) in zip(matching, pollination_channels):
for u in pair:
if u.voice is not None and ((first_round and u.voice.channel == main_voice_channel) or u.voice.channel in pollination_channels):
try:
await u.move_to(c)
except discord.DiscordException as e:
print('failed to move participant {}: {}'.format(u, e), file=sys.stderr)
await asyncio.sleep(60*3)
await message.channel.send('Round ending in 2 minutes {}'.format(mention_all))
await asyncio.sleep(60)
await message.channel.send('Round ending in 1 minute {}'.format(mention_all))
await asyncio.sleep(30)
first_round = False
await message.channel.send('Returning to main channel in 30 seconds {}'.format(mention_all))
await countdown(message.channel)
for u in participants:
try:
await u.move_to(main_voice_channel)
except discord.DiscordException as e:
print('failed to move participant {}: {}'.format(u, e), file=sys.stderr)
if u.voice is not None and u.voice.channel in pollination_channels:
try:
await u.move_to(main_voice_channel)
except discord.DiscordException as e:
print('failed to move participant {}: {}'.format(u, e), file=sys.stderr)
await delete_if_possible(pollination_channels)
@ -220,22 +223,22 @@ async def handle_dm(message):
discriminator = match.group(2)
matching_users = [u for u in client.users if u.name == name and u.discriminator == discriminator]
if len(matching_users) == 0:
await message.channel.send("sorry, I can't find user {}, it looks like they're not in any of the discords I'm in".format(handle))
await message.channel.send("sorry, I can't find user {}, it looks like they're not in any of the discords I'm in".format(handle), allowed_mentions=discord.AllowedMentions.none())
else:
target = matching_users[0].id
if target in get_blocks().get(requester, []):
await message.channel.send("removing {} from your list of blocked users for pollination".format(handle))
await message.channel.send("removing {} from your list of blocked users for pollination".format(handle), allowed_mentions=discord.AllowedMentions.none())
remove_block(requester, target)
else:
await message.channel.send("adding {} to your list of blocked users for pollination".format(handle))
await message.channel.send("adding {} to your list of blocked users for pollination".format(handle), allowed_mentions=discord.AllowedMentions.none())
add_block(requester, target)
blocks = get_blocks().get(requester, [])
if len(blocks) == 0:
await message.channel.send("you currently don't have anyone blocked for pollination")
else:
await message.channel.send("your current list of blocked users for pollination is:\n{}".format('\n'.join('@{}#{}'.format(u.name, u.discriminator) for u in [client.get_user(uid) for uid in blocks] if u is not None)))
await message.channel.send("to block or unblock a user, DM me their handle, like @creep#0000. to see this message and your list of blocked users, DM me something random. buzz buzz!")
await message.channel.send("your current list of blocked users for pollination is:\n{}".format('\n'.join('@{}#{}'.format(u.name, u.discriminator) for u in [client.get_user(uid) for uid in blocks] if u is not None)), allowed_mentions=discord.AllowedMentions.none())
await message.channel.send("to block or unblock a user, DM me their handle, like @creep#0000. to see this message and your list of blocked users, DM me something random. buzz buzz!", allowed_mentions=discord.AllowedMentions.none())
@client.event
async def on_ready():