diff options
-rw-r--r-- | bot/exts/help_channels/_channel.py | 11 | ||||
-rw-r--r-- | bot/exts/help_channels/_cog.py | 5 |
2 files changed, 9 insertions, 7 deletions
diff --git a/bot/exts/help_channels/_channel.py b/bot/exts/help_channels/_channel.py index 9497cb4fb..22966dbe0 100644 --- a/bot/exts/help_channels/_channel.py +++ b/bot/exts/help_channels/_channel.py @@ -36,17 +36,20 @@ async def get_closing_time(channel: discord.TextChannel, init_done: bool) -> t.T else: idle_minutes = constants.HelpChannels.idle_minutes_claimant - non_claimant_last_message_time = await _caches.non_claimant_last_message_times.get(channel.id) claimant_last_message_time = await _caches.claimant_last_message_times.get(channel.id) + non_claimant_last_message_time = await _caches.non_claimant_last_message_times.get(channel.id) + if non_claimant_last_message_time is None: + # A non-claimant hasn't messaged since session start, set to min timestamp so only claimant + # idle period is considered when getting the closing time. + non_claimant_last_message_time = datetime.min.timestamp() if ( is_empty or not init_done - or non_claimant_last_message_time is None or claimant_last_message_time is None ): - # if the current help channel has no messages, the help system cog is starting or - # at least one of the caches is empty use the last message in the channel to determine closing time instead. + # If the current help channel has no messages, the help system cog is starting or + # the claimant cache is empty, use the last message in the channel to determine closing time instead. msg = await _message.get_last_message(channel) diff --git a/bot/exts/help_channels/_cog.py b/bot/exts/help_channels/_cog.py index a8828348c..d9b288280 100644 --- a/bot/exts/help_channels/_cog.py +++ b/bot/exts/help_channels/_cog.py @@ -116,9 +116,8 @@ class HelpChannels(commands.Cog): await _caches.claim_times.set(message.channel.id, message.created_at) await _caches.claimant_last_message_times.set(message.channel.id, message.created_at) - # non_claimant needs to be set too, to satisfy the condition in `_channel.get_closing_time` the first time. - # Otherwise it will fall back to the old method if no other messages are sent. - await _caches.non_claimant_last_message_times.set(message.channel.id, message.created_at) + # Reset thie non_claimant cache for this channel to indicate that this session has yet to be answered. + await _caches.non_claimant_last_message_times.delete(message.channel.id) # Not awaited because it may indefinitely hold the lock while waiting for a channel. scheduling.create_task(self.move_to_available(), name=f"help_claim_{message.id}") |