Compare commits
No commits in common. "ea5f51892ae92bfd5d18ac038f26461dcab1751f" and "4ad73ec6ee8f4cadb1836305b9d70f9a86eac546" have entirely different histories.
ea5f51892a
...
4ad73ec6ee
8 changed files with 39 additions and 45 deletions
|
@ -183,7 +183,7 @@ class Backup(commands.Cog):
|
|||
continue
|
||||
cog_modules.append(cog_module)
|
||||
|
||||
for cog in {cog.name for cog in cog_modules}:
|
||||
for cog in set(cog.name for cog in cog_modules):
|
||||
poss_installed_path = (await downloader.cog_install_path()) / cog
|
||||
if poss_installed_path.exists():
|
||||
with contextlib.suppress(commands.ExtensionNotLoaded):
|
||||
|
|
|
@ -91,11 +91,11 @@ class Bible(commands.Cog):
|
|||
response.status,
|
||||
)
|
||||
if response.status == 401:
|
||||
raise bible.errors.UnauthorizedError
|
||||
raise bible.errors.UnauthorizedError()
|
||||
if response.status == 403:
|
||||
raise bible.errors.BibleAccessError
|
||||
raise bible.errors.BibleAccessError()
|
||||
if response.status == 503:
|
||||
raise bible.errors.ServiceUnavailableError
|
||||
raise bible.errors.ServiceUnavailableError()
|
||||
return Version(
|
||||
bible_id=bible_id,
|
||||
abbreviation=data["data"]["abbreviation"],
|
||||
|
@ -135,15 +135,15 @@ class Bible(commands.Cog):
|
|||
response.status,
|
||||
)
|
||||
if response.status == 400:
|
||||
raise bible.errors.InexplicableError
|
||||
raise bible.errors.InexplicableError()
|
||||
if response.status == 401:
|
||||
raise bible.errors.UnauthorizedError
|
||||
raise bible.errors.UnauthorizedError()
|
||||
if response.status == 403:
|
||||
raise bible.errors.BibleAccessError
|
||||
raise bible.errors.BibleAccessError()
|
||||
if response.status == 404:
|
||||
raise bible.errors.NotFoundError
|
||||
raise bible.errors.NotFoundError()
|
||||
if response.status == 503:
|
||||
raise bible.errors.ServiceUnavailableError
|
||||
raise bible.errors.ServiceUnavailableError()
|
||||
|
||||
fums_url = "https://fums.api.bible/f3"
|
||||
fums_params = {
|
||||
|
@ -176,11 +176,11 @@ class Bible(commands.Cog):
|
|||
response.status,
|
||||
)
|
||||
if response.status == 401:
|
||||
raise bible.errors.UnauthorizedError
|
||||
raise bible.errors.UnauthorizedError()
|
||||
if response.status == 403:
|
||||
raise bible.errors.BibleAccessError
|
||||
raise bible.errors.BibleAccessError()
|
||||
if response.status == 503:
|
||||
raise bible.errors.ServiceUnavailableError
|
||||
raise bible.errors.ServiceUnavailableError()
|
||||
return data["data"]
|
||||
|
||||
async def _get_chapters(self, bible_id: str, book_id: str) -> dict:
|
||||
|
@ -195,11 +195,11 @@ class Bible(commands.Cog):
|
|||
response.status,
|
||||
)
|
||||
if response.status == 401:
|
||||
raise bible.errors.UnauthorizedError
|
||||
raise bible.errors.UnauthorizedError()
|
||||
if response.status == 403:
|
||||
raise bible.errors.BibleAccessError
|
||||
raise bible.errors.BibleAccessError()
|
||||
if response.status == 503:
|
||||
raise bible.errors.ServiceUnavailableError
|
||||
raise bible.errors.ServiceUnavailableError()
|
||||
return data["data"]
|
||||
|
||||
async def _get_verses(self, bible_id: str, book_id: str, chapter: int) -> dict:
|
||||
|
@ -214,11 +214,11 @@ class Bible(commands.Cog):
|
|||
response.status,
|
||||
)
|
||||
if response.status == 401:
|
||||
raise bible.errors.UnauthorizedError
|
||||
raise bible.errors.UnauthorizedError()
|
||||
if response.status == 403:
|
||||
raise bible.errors.BibleAccessError
|
||||
raise bible.errors.BibleAccessError()
|
||||
if response.status == 503:
|
||||
raise bible.errors.ServiceUnavailableError
|
||||
raise bible.errors.ServiceUnavailableError()
|
||||
return data["data"]
|
||||
|
||||
@commands.group(autohelp=True)
|
||||
|
|
|
@ -40,7 +40,8 @@ class EmojiInfo(commands.Cog):
|
|||
emoji_codepoint = "-".join([hex(ord(char))[2:] for char in unicode_emoji])
|
||||
segments = emoji_codepoint.split("-")
|
||||
valid_segments = [seg for seg in segments if len(seg) >= 4]
|
||||
return f"{base_url}{valid_segments[0]}.png"
|
||||
emoji_url = f"{base_url}{valid_segments[0]}.png"
|
||||
return emoji_url
|
||||
|
||||
async def fetch_primary_color(self, emoji_url: str) -> discord.Color | None:
|
||||
async with aiohttp.ClientSession() as session:
|
||||
|
@ -49,7 +50,8 @@ class EmojiInfo(commands.Cog):
|
|||
return None
|
||||
image = await response.read()
|
||||
dominant_color = ColorThief(io.BytesIO(image)).get_color(quality=1)
|
||||
return discord.Color.from_rgb(*dominant_color)
|
||||
color = discord.Color.from_rgb(*dominant_color)
|
||||
return color
|
||||
|
||||
async def get_emoji_info(self, emoji: PartialEmoji) -> tuple[str, str]:
|
||||
if emoji.is_unicode_emoji():
|
||||
|
@ -96,9 +98,8 @@ class EmojiInfo(commands.Cog):
|
|||
embed.set_thumbnail(url=emoji_url)
|
||||
|
||||
await interaction.followup.send(embed=embed)
|
||||
return None
|
||||
await interaction.followup.send(content=string)
|
||||
return None
|
||||
else:
|
||||
await interaction.followup.send(content=string)
|
||||
|
||||
@commands.command(name="emoji")
|
||||
async def emoji(self, ctx: commands.Context, *, emoji: str) -> None:
|
||||
|
@ -118,6 +119,5 @@ class EmojiInfo(commands.Cog):
|
|||
embed.set_thumbnail(url=emoji_url)
|
||||
|
||||
await ctx.send(embed=embed)
|
||||
return None
|
||||
await ctx.send(content=string)
|
||||
return None
|
||||
else:
|
||||
await ctx.send(content=string)
|
||||
|
|
|
@ -105,5 +105,5 @@ class HotReloadHandler(RegexMatchingEventHandler):
|
|||
"""Reload modified cog."""
|
||||
core_logic = CoreLogic(bot=self.bot)
|
||||
self.logger.info("Reloading cogs: %s", humanize_list(cog_names, style="unit"))
|
||||
await core_logic._reload(pkg_names=cog_names) # noqa: SLF001 # We have to use this private method because there is no public API to reload other cogs
|
||||
await core_logic._reload(pkg_names=cog_names)
|
||||
self.logger.info("Reloaded cogs: %s", humanize_list(cog_names, style="unit"))
|
||||
|
|
|
@ -40,13 +40,13 @@ class Nerdify(commands.Cog):
|
|||
|
||||
@commands.command(aliases=["nerd"])
|
||||
async def nerdify(
|
||||
self, ctx: commands.Context, *, text: Optional[str] = None,
|
||||
self, ctx: commands.Context, *, text: Optional[str] = None
|
||||
) -> None:
|
||||
"""Nerdify the replied to message, previous message, or your own text."""
|
||||
if not text:
|
||||
if hasattr(ctx.message, "reference") and ctx.message.reference:
|
||||
with suppress(
|
||||
discord.Forbidden, discord.NotFound, discord.HTTPException,
|
||||
discord.Forbidden, discord.NotFound, discord.HTTPException
|
||||
):
|
||||
message_id = ctx.message.reference.message_id
|
||||
if message_id:
|
||||
|
@ -62,7 +62,7 @@ class Nerdify(commands.Cog):
|
|||
ctx.channel,
|
||||
self.nerdify_text(text),
|
||||
allowed_mentions=discord.AllowedMentions(
|
||||
everyone=False, users=False, roles=False,
|
||||
everyone=False, users=False, roles=False
|
||||
),
|
||||
)
|
||||
|
||||
|
@ -77,7 +77,7 @@ class Nerdify(commands.Cog):
|
|||
return f'"{text}" 🤓'
|
||||
|
||||
async def type_message(
|
||||
self, destination: discord.abc.Messageable, content: str, **kwargs: Any,
|
||||
self, destination: discord.abc.Messageable, content: str, **kwargs: Any
|
||||
) -> Union[discord.Message, None]:
|
||||
"""Simulate typing and sending a message to a destination.
|
||||
|
||||
|
|
|
@ -149,7 +149,7 @@ class Pterodactyl(commands.Cog):
|
|||
"P": str(response["players"]["online"]),
|
||||
"V": response["version"],
|
||||
"D": response["motd"]["clean"][0] if response["motd"]["clean"] else "unset",
|
||||
},
|
||||
}
|
||||
)
|
||||
else:
|
||||
placeholders.update(
|
||||
|
@ -159,7 +159,7 @@ class Pterodactyl(commands.Cog):
|
|||
"P": "0",
|
||||
"V": "Server Offline",
|
||||
"D": "Server Offline",
|
||||
},
|
||||
}
|
||||
)
|
||||
for key, value in placeholders.items():
|
||||
topic = topic.replace(".$" + key, value)
|
||||
|
@ -187,7 +187,6 @@ class Pterodactyl(commands.Cog):
|
|||
output_str = "\n".join(response["players"]["list"])
|
||||
return output_str, response["players"]["list"]
|
||||
return None
|
||||
return None
|
||||
|
||||
async def get_player_list_embed(self, ctx: Union[commands.Context, discord.Interaction]) -> Optional[discord.Embed]:
|
||||
player_list = await self.get_player_list()
|
||||
|
@ -221,10 +220,9 @@ class Pterodactyl(commands.Cog):
|
|||
await self.websocket.send(json.dumps({"event": "set state", "args": [action]}))
|
||||
|
||||
await message.edit(content=f"Server {action_ing}", view=None)
|
||||
return None
|
||||
|
||||
await message.edit(content="Cancelled.", view=None)
|
||||
return None
|
||||
else:
|
||||
await message.edit(content="Cancelled.", view=None)
|
||||
|
||||
async def send_command(self, ctx: Union[discord.Interaction, commands.Context], command: str):
|
||||
channel = self.bot.get_channel(await config.console_channel())
|
||||
|
|
|
@ -151,7 +151,7 @@ async def retrieve_websocket_credentials(coginstance: Pterodactyl) -> Optional[d
|
|||
Socket: %s
|
||||
Token: %s...""",
|
||||
websocket_credentials['data']['socket'],
|
||||
websocket_credentials['data']['token'][:20],
|
||||
websocket_credentials['data']['token'][:20]
|
||||
)
|
||||
return websocket_credentials
|
||||
#NOTE - The token is truncated to prevent it from being logged in its entirety, for security reasons
|
||||
|
@ -262,5 +262,6 @@ async def generate_achievement_embed(coginstance: Pterodactyl, username: str, ac
|
|||
def mask_ip(string: str) -> str:
|
||||
def check(match: re.Match[str]):
|
||||
ip = match.group(0)
|
||||
return '.'.join(r'\*' * len(octet) for octet in ip.split('.'))
|
||||
masked_ip = '.'.join(r'\*' * len(octet) for octet in ip.split('.'))
|
||||
return masked_ip
|
||||
return re.sub(r'\b(?:\d{1,3}\.){3}\d{1,3}\b', check, string)
|
||||
|
|
|
@ -87,8 +87,6 @@ select = [
|
|||
"W",
|
||||
"E",
|
||||
"G",
|
||||
"A",
|
||||
"COM",
|
||||
"INP",
|
||||
"T20",
|
||||
"PLC",
|
||||
|
@ -101,11 +99,8 @@ select = [
|
|||
"FIX",
|
||||
"PERF",
|
||||
"C4",
|
||||
"EM",
|
||||
"RET",
|
||||
"RSE",
|
||||
]
|
||||
ignore = ["PLR0912", "PLR0915", "PLR2004", "PLR0913", "EM101"]
|
||||
ignore = ["PLR0912", "PLR0915", "PLR2004", "PLR0913"]
|
||||
|
||||
# Allow fix for all enabled rules (when `--fix`) is provided.
|
||||
fixable = ["ALL"]
|
||||
|
|
Loading…
Add table
Reference in a new issue