Compare commits
17 commits
mdiluz-pat
...
main
Author | SHA1 | Date | |
---|---|---|---|
647c0266e1 | |||
c8bfa837aa | |||
20b0ba08cd | |||
f07d52bf19 | |||
84f18bceec | |||
e8f5350b8e | |||
e0e927fead | |||
fb4647c4e0 | |||
66d3fe3e5c | |||
77d533fbcb | |||
86d0075e5d | |||
10e3dd3b36 | |||
472f67b3f6 | |||
f7898892e6 | |||
455f202364 | |||
367d12578c | |||
dabd0d9b18 |
3 changed files with 62 additions and 6 deletions
|
@ -210,15 +210,28 @@ class MatcherCog(commands.Cog):
|
||||||
async def run_hourly_tasks(self):
|
async def run_hourly_tasks(self):
|
||||||
"""Run any hourly tasks we have"""
|
"""Run any hourly tasks we have"""
|
||||||
|
|
||||||
|
# Send a reminder for anything that will be active in 1 day
|
||||||
|
for (channel, _) in state.State.get_active_match_tasks(datetime.now() + timedelta(days=1)):
|
||||||
|
logger.info("Reminding about scheduled task in %s", channel)
|
||||||
|
msg_channel = self.bot.get_channel(int(channel))
|
||||||
|
await msg_channel.send(strings.reminder())
|
||||||
|
|
||||||
|
# Match groups for anything active right now
|
||||||
for (channel, min) in state.State.get_active_match_tasks():
|
for (channel, min) in state.State.get_active_match_tasks():
|
||||||
logger.info("Scheduled match task triggered in %s", channel)
|
logger.info("Scheduled match task triggered in %s", channel)
|
||||||
msg_channel = self.bot.get_channel(int(channel))
|
msg_channel = self.bot.get_channel(int(channel))
|
||||||
await match_groups_in_channel(msg_channel, min)
|
await match_groups_in_channel(msg_channel, min)
|
||||||
|
|
||||||
for (channel, _) in state.State.get_active_match_tasks(datetime.now() + timedelta(days=1)):
|
# Send a reminder to threads for a match that happened two days ago
|
||||||
logger.info("Reminding about scheduled task in %s", channel)
|
for (channel, _) in state.State.get_active_match_tasks(datetime.now() - timedelta(days=2)):
|
||||||
|
logger.info("Sending reminders to threads in %s", channel)
|
||||||
msg_channel = self.bot.get_channel(int(channel))
|
msg_channel = self.bot.get_channel(int(channel))
|
||||||
await msg_channel.send(strings.reminder())
|
# Find any threads that need
|
||||||
|
for thread in msg_channel.threads:
|
||||||
|
# Only regard threads the bot created
|
||||||
|
# And that have no additional messages
|
||||||
|
if thread.owner.id == self.bot.user.id and thread.message_count <= 1:
|
||||||
|
await thread.send(strings.thread_reminder())
|
||||||
|
|
||||||
|
|
||||||
# Increment when adjusting the custom_id so we don't confuse old users
|
# Increment when adjusting the custom_id so we don't confuse old users
|
||||||
|
@ -272,11 +285,14 @@ async def match_groups_in_channel(channel: discord.channel, min: int):
|
||||||
strings.matched_up([m.mention for m in group]))
|
strings.matched_up([m.mention for m in group]))
|
||||||
# Set up a thread for this match if the bot has permissions to do so
|
# Set up a thread for this match if the bot has permissions to do so
|
||||||
if channel.permissions_for(channel.guild.me).create_public_threads:
|
if channel.permissions_for(channel.guild.me).create_public_threads:
|
||||||
await channel.create_thread(
|
thread = await channel.create_thread(
|
||||||
name=strings.thread_title([m.display_name for m in group]),
|
name=strings.thread_title([m.display_name for m in group]),
|
||||||
message=message,
|
message=message,
|
||||||
reason="Creating a matching thread")
|
reason="Creating a matching thread")
|
||||||
|
|
||||||
|
# Send a message with a suggested time to the channel
|
||||||
|
await thread.send(f"{strings.thread_message()} {strings.time_suggestion()}")
|
||||||
|
|
||||||
# Close off with a message
|
# Close off with a message
|
||||||
await channel.send(strings.matching_done())
|
await channel.send(strings.matching_done())
|
||||||
# Save the groups to the history
|
# Save the groups to the history
|
||||||
|
|
|
@ -145,6 +145,16 @@ Make sure you're /pause'd if you need to be, or /join in ASAP!""",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@randomised
|
||||||
|
def thread_reminder(): return [
|
||||||
|
"Hey friends, just checking in! No worries if you're too busy this week",
|
||||||
|
"Bork bork, quick reminder in case y'all forgot!",
|
||||||
|
"Hey matchees, how's your week going?",
|
||||||
|
"Hey everyone, don't forget to check in with eachother!",
|
||||||
|
"Quick friendly nudge, how're you all doing?",
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
@randomised
|
@randomised
|
||||||
def matching(): return [
|
def matching(): return [
|
||||||
"Matchy is matching matchees...",
|
"Matchy is matching matchees...",
|
||||||
|
@ -174,6 +184,36 @@ def matched_up(ms): return [
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@randomised
|
||||||
|
def thread_message(): return [
|
||||||
|
"Hey peeps :)",
|
||||||
|
"How is everyone?",
|
||||||
|
"Bork!",
|
||||||
|
"Hey kiddos :)",
|
||||||
|
"Ahoy!",
|
||||||
|
"Great to see y'all here.",
|
||||||
|
"Icebreaker! What's your favourite pokemon?",
|
||||||
|
"I'm hungry, would a lasagna count as a sandwich?",
|
||||||
|
"What's your favourite keyboard key?",
|
||||||
|
"I'm confused thinking... Is a train just a sideways elevator?",
|
||||||
|
"Humans are weird, why do you have moustaches above your eyes?"
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@randomised
|
||||||
|
def time_suggestion(): return [
|
||||||
|
"Can I suggest a quick call on Wednesday?",
|
||||||
|
"Remember to organise a chat if you're up for it!",
|
||||||
|
"How about throwing something in the calendar for Friday?",
|
||||||
|
"Would 10am on Thursday work for people?",
|
||||||
|
"How about a call this afternoon?",
|
||||||
|
"Would a chat the start of a weekday work?",
|
||||||
|
"How's about organising a quick call sometime this week?",
|
||||||
|
"When's everyone available for a short hangout?",
|
||||||
|
"It's best to pick a time to drop in a call or meet up, if everyone is up for it!",
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
@randomised
|
@randomised
|
||||||
def thread_title(ms): return [
|
def thread_title(ms): return [
|
||||||
f"{format_list(ms)}",
|
f"{format_list(ms)}",
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
coverage==7.6.1
|
coverage==7.6.10
|
||||||
discord.py==2.4.0
|
discord.py==2.4.0
|
||||||
dpytest==0.7.0
|
dpytest==0.7.0
|
||||||
flake8==7.1.1
|
flake8==7.1.1
|
||||||
pytest==8.3.3
|
pytest==8.3.3
|
||||||
pytest-asyncio==0.24.0
|
pytest-asyncio==0.25.2
|
||||||
pytest-cov==5.0.0
|
pytest-cov==5.0.0
|
||||||
schema==0.7.7
|
schema==0.7.7
|
Loading…
Add table
Reference in a new issue