diff options
| author | 2021-03-17 18:45:51 +0000 | |
|---|---|---|
| committer | 2021-03-17 18:45:51 +0000 | |
| commit | 12a73f2b29ac2b2f43b488109fc66216a739f056 (patch) | |
| tree | 888720efda140939c47042304adac9b692933561 | |
| parent | Improve availible channel embed footer (diff) | |
Improve docs strings and variable names within the help channel system
| -rw-r--r-- | bot/exts/help_channels/_caches.py | 4 | ||||
| -rw-r--r-- | bot/exts/help_channels/_channel.py | 18 | ||||
| -rw-r--r-- | bot/exts/help_channels/_cog.py | 18 |
3 files changed, 20 insertions, 20 deletions
diff --git a/bot/exts/help_channels/_caches.py b/bot/exts/help_channels/_caches.py index c790a37b1..d4676df87 100644 --- a/bot/exts/help_channels/_caches.py +++ b/bot/exts/help_channels/_caches.py @@ -10,11 +10,11 @@ claimants = RedisCache(namespace="HelpChannels.help_channel_claimants") # Stores the timestamp of the last message in a help channel # RedisCache[discord.TextChannel.id, UtcPosixTimestamp] -last_message = RedisCache(namespace="HelpChannels.last_message") +last_message_times = RedisCache(namespace="HelpChannels.last_message_times") # Stores the timestamp of the last message from the claimant of a help channel # RedisCache[discord.TextChannel.id, UtcPosixTimestamp] -claimant_last_message = RedisCache(namespace="HelpChannels.claimant_last_message") +claimant_last_message_times = RedisCache(namespace="HelpChannels.claimant_last_message_times") # This cache maps a help channel to original question message in same channel. # RedisCache[discord.TextChannel.id, discord.Message.id] diff --git a/bot/exts/help_channels/_channel.py b/bot/exts/help_channels/_channel.py index 8db6e7617..6c17a26e0 100644 --- a/bot/exts/help_channels/_channel.py +++ b/bot/exts/help_channels/_channel.py @@ -34,10 +34,10 @@ async def get_closing_time(channel: discord.TextChannel) -> t.Optional[int]: else: idle_minutes = constants.HelpChannels.idle_minutes_others - last_message = await _caches.last_message.get(channel.id) - claimant_last_message = await _caches.claimant_last_message.get(channel.id) + last_message_time = await _caches.last_message_times.get(channel.id) + claimant_last_message_time = await _caches.claimant_last_message_times.get(channel.id) - if not (last_message or claimant_last_message): + if not (last_message_time or claimant_last_message_time): # Using the old method if we can't get cached info. msg = await _message.get_last_message(channel) if not msg: @@ -51,15 +51,15 @@ async def get_closing_time(channel: discord.TextChannel) -> t.Optional[int]: return closing_time # We want to get the time at which a channel should be closed. - last_message = datetime.fromtimestamp(last_message) - claimant = datetime.fromtimestamp(claimant_last_message) + last_message_time = datetime.fromtimestamp(last_message_time) + claimant_last_message_time = datetime.fromtimestamp(claimant_last_message_time) - last_message += timedelta(minutes=idle_minutes) - claimant += timedelta(minutes=constants.HelpChannels.idle_minutes_claimant) + last_message_time += timedelta(minutes=idle_minutes) + claimant_last_message_time += timedelta(minutes=constants.HelpChannels.idle_minutes_claimant) # The further away closing time is what we should use. - closing_time = max(claimant, last_message) - log.trace(f"claimant closing time: {claimant}, last_message closing time: {last_message}") + closing_time = max(claimant_last_message_time, last_message_time) + log.trace(f"claimant closing time: {claimant_last_message_time}, last_message closing time: {last_message_time}") log.trace(f"#{channel} ({channel.id}) should be closed at {closing_time}.") return closing_time diff --git a/bot/exts/help_channels/_cog.py b/bot/exts/help_channels/_cog.py index db14ce0ef..bac9aa9dd 100644 --- a/bot/exts/help_channels/_cog.py +++ b/bot/exts/help_channels/_cog.py @@ -43,9 +43,9 @@ class HelpChannels(commands.Cog): In Use Category * Contains all channels which are occupied by someone needing help - * Channel moves to dormant category after `constants.HelpChannels.idle_minutes_other` minutes - since the last user message, or `constants.HelpChannels.idle_minutes_claimant` minutes - since the last claimant message. + * Channel moves to dormant category after + - `constants.HelpChannels.idle_minutes_other` minutes since the last user message, or + - `constants.HelpChannels.idle_minutes_claimant` minutes since the last claimant message. * Command can prematurely mark a channel as dormant * Channel claimant is allowed to use the command * Allowed roles for the command are configurable with `constants.HelpChannels.cmd_whitelist` @@ -419,8 +419,8 @@ class HelpChannels(commands.Cog): """ Move an available channel to the In Use category and replace it with a dormant one. - Also updates the `message_times` cache based on the current timestamp. If the message - author is the claimant of this channel, also update the claimant_last_message. + Also updates the `last_message_times` cache based on the current timestamp. If the message + author is the claimant of this channel, also update the `claimant_last_message_times` cache. """ if message.author.bot: return # Ignore messages sent by bots. @@ -431,20 +431,20 @@ class HelpChannels(commands.Cog): if not _channel.is_excluded_channel(message.channel): await self.claim_channel(message) # Initialise the cache for this channel - await _caches.claimant_last_message.set( + await _caches.claimant_last_message_times.set( message.channel.id, message.created_at.timestamp() ) - await _caches.last_message.set( + await _caches.last_message_times.set( message.channel.id, message.created_at.timestamp() ) elif channel_utils.is_in_category(message.channel, constants.Categories.help_in_use): # Overwrite the claimant message time, if its from the claimant. if message.author == await _caches.claimants.get(message.channel.id): - await _caches.claimant_last_message(message.channel.id, message.created_at.timestamp()) + await _caches.claimant_last_message_times(message.channel.id, message.created_at.timestamp()) - await _caches.last_message.set(message.channel.id, message.created_at.timestamp()) + await _caches.last_message_times.set(message.channel.id, message.created_at.timestamp()) else: await _message.check_for_answer(message) |