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
17 changes: 14 additions & 3 deletions techsupport_bot/functions/xp.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ async def setup(bot: bot.TechSupportBot) -> None:
description="List of category IDs to count for XP",
default=[],
)
config.add(
key="excluded_channels",
datatype="list",
title="List of channel IDs to exclude for XP",
description="List of channel IDs to exclude for XP",
default=[],
)
config.add(
key="level_roles",
datatype="dict",
Expand Down Expand Up @@ -68,13 +75,17 @@ async def match(
return False

# Ignore anyone in the ineligible list
if ctx.author.id in self.ineligible:
if f"{ctx.guild.id}:{ctx.author.id}" in self.ineligible:
return False

# Ignore messages outside of tracked categories
if ctx.channel.category_id not in config.extensions.xp.categories_counted.value:
return False

# Ignore messages in exlucded channels
if ctx.channel.id in config.extensions.xp.excluded_channels.value:
return False

# Ignore messages that are too short
if len(ctx.message.clean_content) < 20:
return False
Expand All @@ -87,7 +98,7 @@ async def match(

# Ignore messages that are factoid calls
if "factoids" in config.enabled_extensions:
factoid_prefix = prefix = config.extensions.factoids.prefix.value
factoid_prefix = config.extensions.factoids.prefix.value
if ctx.message.clean_content.startswith(factoid_prefix):
return False

Expand Down Expand Up @@ -120,7 +131,7 @@ async def response(

await self.apply_level_ups(ctx.author, (current_XP + new_XP))

self.ineligible[ctx.author.id] = True
self.ineligible[f"{ctx.guild.id}:{ctx.author.id}"] = True

async def apply_level_ups(self: Self, user: discord.Member, new_xp: int) -> None:
"""This function will determine if a user leveled up and apply the proper roles
Expand Down
Loading