Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 8 additions & 31 deletions bot/cogs/help_channels.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,8 @@
MAX_CHANNELS_PER_CATEGORY = 50
EXCLUDED_CHANNELS = (constants.Channels.how_to_get_help,)

AVAILABLE_TOPIC = """
This channel is available. Feel free to ask a question in order to claim this channel!
"""

IN_USE_TOPIC = """
This channel is currently in use. If you'd like to discuss a different problem, please claim a new \
channel from the Help: Available category.
"""

DORMANT_TOPIC = """
This channel is temporarily archived. If you'd like to ask a question, please use one of the \
channels in the Help: Available category.
HELP_CHANNEL_TOPIC = """
This is a Python help channel. You can claim your own help channel in the Python Help: Available category.
"""

AVAILABLE_MSG = f"""
Expand Down Expand Up @@ -64,11 +54,6 @@
through our guide for [asking a good question]({ASKING_GUIDE_URL}).
"""

AVAILABLE_EMOJI = "✅"
IN_USE_ANSWERED_EMOJI = "⌛"
IN_USE_UNANSWERED_EMOJI = "⏳"
NAME_SEPARATOR = "|"

CoroutineFunc = t.Callable[..., t.Coroutine]


Expand Down Expand Up @@ -196,7 +181,7 @@ async def create_dormant(self) -> t.Optional[discord.TextChannel]:
return None

log.debug(f"Creating a new dormant channel named {name}.")
return await self.dormant_category.create_text_channel(name)
return await self.dormant_category.create_text_channel(name, topic=HELP_CHANNEL_TOPIC)

def create_name_queue(self) -> deque:
"""Return a queue of element names to use for creating new channels."""
Expand Down Expand Up @@ -542,8 +527,6 @@ async def move_to_available(self) -> None:
await self.move_to_bottom_position(
channel=channel,
category_id=constants.Categories.help_available,
name=f"{AVAILABLE_EMOJI}{NAME_SEPARATOR}{self.get_clean_channel_name(channel)}",
topic=AVAILABLE_TOPIC,
)

self.report_stats()
Expand All @@ -559,8 +542,6 @@ async def move_to_dormant(self, channel: discord.TextChannel, caller: str) -> No
await self.move_to_bottom_position(
channel=channel,
category_id=constants.Categories.help_dormant,
name=self.get_clean_channel_name(channel),
topic=DORMANT_TOPIC,
)

self.bot.stats.incr(f"help.dormant_calls.{caller}")
Expand Down Expand Up @@ -593,8 +574,6 @@ async def move_to_in_use(self, channel: discord.TextChannel) -> None:
await self.move_to_bottom_position(
channel=channel,
category_id=constants.Categories.help_in_use,
name=f"{IN_USE_UNANSWERED_EMOJI}{NAME_SEPARATOR}{self.get_clean_channel_name(channel)}",
topic=IN_USE_TOPIC,
)

timeout = constants.HelpChannels.idle_minutes * 60
Expand Down Expand Up @@ -660,18 +639,16 @@ async def check_for_answer(self, message: discord.Message) -> None:

# Check if there is an entry in unanswered (does not persist across restarts)
if channel.id in self.unanswered:
claimant_id = self.help_channel_claimants[channel].id
claimant = self.help_channel_claimants.get(channel)
if not claimant:
# The mapping for this channel was lost, we can't do anything.
return

# Check the message did not come from the claimant
if claimant_id != message.author.id:
if claimant.id != message.author.id:
# Mark the channel as answered
self.unanswered[channel.id] = False

# Change the emoji in the channel name to signify activity
log.trace(f"#{channel} ({channel.id}) has been answered; changing its emoji")
name = self.get_clean_channel_name(channel)
await channel.edit(name=f"{IN_USE_ANSWERED_EMOJI}{NAME_SEPARATOR}{name}")

@commands.Cog.listener()
async def on_message(self, message: discord.Message) -> None:
"""Move an available channel to the In Use category and replace it with a dormant one."""
Expand Down