Skip to content

Commit

Permalink
Merge pull request #251 from danparizher/czar.refactor
Browse files Browse the repository at this point in the history
Small Refactor
  • Loading branch information
danparizher authored Sep 30, 2023
2 parents 300a2d5 + 8f62e21 commit 505f98f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
19 changes: 8 additions & 11 deletions cogs/moderation.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ class MessageFingerprint:
attachment_urls: list[
str
] # the discord content URLs for each of the message's uploaded attachments
cached_attachment_hashes: set[
Hash
] | None = None # populated on the first call to `get_attachment_hashes`
cached_attachment_hashes: (
set[Hash] | None
) = None # populated on the first call to `get_attachment_hashes`

content_hash: Hash | None = (
None # hash of the message body, after being passed through `filter_content`
)
content_hash: (
Hash | None
) = None # hash of the message body, after being passed through `filter_content`

# shortcut to build a fingerprint given a message
@classmethod
Expand Down Expand Up @@ -166,11 +166,8 @@ async def is_multipost_of(self, other: MessageFingerprint) -> bool:
class Moderation(commands.Cog):
def __init__(self, bot: commands.Bot) -> None:
self.bot = bot
self.fingerprints: list[
MessageFingerprint
] = (
[]
) # stores all user messages sent in the last minute (recent messages near the end)
# stores all user messages sent in the last minute (recent messages near the end)
self.fingerprints: list[MessageFingerprint] = []
self.multipost_warnings: dict[
Annotated[int, "Multiposted Message ID"],
tuple[
Expand Down
3 changes: 2 additions & 1 deletion cogs/pubchem.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

import asyncio
import string

import pubchempy as pcp
from discord import ApplicationContext, option
Expand Down Expand Up @@ -49,7 +50,7 @@ def to_subscript(self, number: str) -> str:
:type number: int
:return: The subscripted version of the number.
"""
return number.translate(str.maketrans("0123456789", "₀₁₂₃₄₅₆₇₈₉"))
return number.translate(str.maketrans(string.digits, "₀₁₂₃₄₅₆₇₈₉"))

@commands.slash_command(
name="chemsearch",
Expand Down
2 changes: 1 addition & 1 deletion cogs/staffapps_frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ async def apply(self, ctx: discord.ApplicationContext) -> None:

# check app status
status = any(
x in [1, 3, 4, 5, 6, 7, 8] for x in applicant.status
x in (1, 3, 4, 5, 6, 7, 8) for x in applicant.status
) # 2 and 8 are closed applications, others are open
if status:
await ctx.respond(embed=embeds().ongoing(), ephemeral=True)
Expand Down

0 comments on commit 505f98f

Please sign in to comment.