diff --git a/poetry.lock b/poetry.lock index 8b55f5b..a3c9de0 100644 --- a/poetry.lock +++ b/poetry.lock @@ -426,13 +426,13 @@ tornado = ["tornado"] [[package]] name = "humanize" -version = "4.11.0" +version = "4.12.1" description = "Python humanize utilities" optional = false python-versions = ">=3.9" files = [ - {file = "humanize-4.11.0-py3-none-any.whl", hash = "sha256:b53caaec8532bcb2fff70c8826f904c35943f8cecaca29d272d9df38092736c0"}, - {file = "humanize-4.11.0.tar.gz", hash = "sha256:e66f36020a2d5a974c504bd2555cf770621dbdbb6d82f94a6857c0b1ea2608be"}, + {file = "humanize-4.12.1-py3-none-any.whl", hash = "sha256:86014ca5c52675dffa1d404491952f1f5bf03b07c175a51891a343daebf01fea"}, + {file = "humanize-4.12.1.tar.gz", hash = "sha256:1338ba97415c96556758a6e2f65977ed406dddf4620d4c6db9bbdfd07f0f1232"}, ] [package.extras] @@ -821,4 +821,4 @@ propcache = ">=0.2.0" [metadata] lock-version = "2.0" python-versions = "^3.11" -content-hash = "6b4d35b268bb3ba397f43d223bf90a995e0e43ccff0c8214ebe59f2373c14fb8" +content-hash = "cbff816ee06d571d4d2e1658682b7695586c2c98e6c971027055ea236509da46" diff --git a/pyproject.toml b/pyproject.toml index 186902c..c6ac3cb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,7 +10,7 @@ repository = "https://github.com/reswitched/robocop-ng" [tool.poetry.dependencies] python = "^3.11" python-dateutil = "^2.8.2" -humanize = "^4.8.0" +humanize = "^4.12.1" parsedatetime = "^2.6" aiohttp = "^3.9.3" gidgethub = "^5.3.0" diff --git a/robocop_ng/__main__.py b/robocop_ng/__main__.py index b724129..6d14cc2 100755 --- a/robocop_ng/__main__.py +++ b/robocop_ng/__main__.py @@ -262,8 +262,7 @@ async def on_message(message: Message): for phrase in config.blocked_phrases.keys(): if phrase in message.content: - await message.channel.send( - content=config.blocked_phrases[phrase]) + await message.channel.send(content=config.blocked_phrases[phrase]) await message.delete() return diff --git a/robocop_ng/cogs/logfilereader.py b/robocop_ng/cogs/logfilereader.py index 7e4b37d..d8c9721 100644 --- a/robocop_ng/cogs/logfilereader.py +++ b/robocop_ng/cogs/logfilereader.py @@ -44,8 +44,13 @@ def is_valid_log_name(attachment: Attachment) -> tuple[bool, bool]: filename = attachment.filename ryujinx_log_file_regex = re.compile(r"^Ryujinx_.*\.log$") log_file = re.compile(r"^.*\.log|.*\.txt$") - is_ryujinx_log_file = re.match(ryujinx_log_file_regex, filename) is not None and "Android" not in filename - is_log_file = re.match(log_file, filename) is not None and "Android" not in filename + is_ryujinx_log_file = ( + re.match(ryujinx_log_file_regex, filename) is not None + and "Android" not in filename + ) + is_log_file = ( + re.match(log_file, filename) is not None and "Android" not in filename + ) return is_log_file, is_ryujinx_log_file @@ -169,7 +174,9 @@ async def blocked_path_action(self, message: Message, blocked_path: str) -> Embe await message.delete() return embed - def format_analysed_log(self, author_name: str, analyser: LogAnalyser, analysed_log): + def format_analysed_log( + self, author_name: str, analyser: LogAnalyser, analysed_log + ): cleaned_game_name = re.sub( r"\s\[(64|32)-bit\]$", "", analysed_log["game_info"]["game_name"] ) @@ -633,7 +640,14 @@ async def analyse_log_message(self, message: Message, attachment_index=0): @commands.cooldown(3, 30, BucketType.channel) @commands.command( - aliases=["analyselog", "analyse_log", "analyze", "analyzelog", "analyze_log", "a"] + aliases=[ + "analyselog", + "analyse_log", + "analyze", + "analyzelog", + "analyze_log", + "a", + ] ) async def analyse(self, ctx: Context, attachment_number=1): await ctx.message.delete() diff --git a/robocop_ng/cogs/logs.py b/robocop_ng/cogs/logs.py index 5465e20..3b6abd6 100644 --- a/robocop_ng/cogs/logs.py +++ b/robocop_ng/cogs/logs.py @@ -19,9 +19,11 @@ message_edited_color = Color.blurple() member_updated_color = Color.blurple() + async def send_log(channel: TextChannel, message: str, color: Color): await channel.send(embed=Embed(description=message, color=color)) + class Logs(Cog): """ Logs join and leave messages, bans and unbans, and member changes. @@ -102,8 +104,7 @@ async def on_member_join(self, member: Member): if age < self.bot.config.min_age: try: await member.send( - f"Your account is too new to " - f"join {member.guild.name}." + f"Your account is too new to " f"join {member.guild.name}." ) sent = True except discord.errors.Forbidden: @@ -216,7 +217,8 @@ async def do_nickcheck(self, message): return msg = ( - f"Rule violating name by {message.author.mention} " f"({message.author.id})." + f"Rule violating name by {message.author.mention} " + f"({message.author.id})." ) spy_channel = self.bot.get_channel(self.bot.config.spylog_channel) @@ -396,7 +398,7 @@ async def on_member_update(self, member_before, member_after): f"ℹ️ **Member update**: {member_after.mention} | " f"{self.bot.escape_message(member_after)}{msg}" ) - await send_log(log_channel, msg,member_updated_color) + await send_log(log_channel, msg, member_updated_color) async def setup(bot): diff --git a/robocop_ng/cogs/verification.py b/robocop_ng/cogs/verification.py index 5d0d6ef..41aaeae 100644 --- a/robocop_ng/cogs/verification.py +++ b/robocop_ng/cogs/verification.py @@ -55,7 +55,7 @@ async def do_reset(self, channel, author, limit: int = 100): else: # we've hit the limit; split! messages += [current_message] - current_message = "\n\u200B\n" + item + "\n\u200B\n" + current_message = "\n\u200b\n" + item + "\n\u200b\n" total = 0 messages += [current_message] diff --git a/robocop_ng/helpers/checks.py b/robocop_ng/helpers/checks.py index 20c255c..099512e 100644 --- a/robocop_ng/helpers/checks.py +++ b/robocop_ng/helpers/checks.py @@ -1,5 +1,6 @@ from robocop_ng import config + def check_if_staff(ctx): if not ctx.guild: return False @@ -35,6 +36,7 @@ def check_if_collaborator(ctx): for r in ctx.author.roles ) + def check_if_pin_channel(ctx): if not ctx.guild: return False diff --git a/robocop_ng/helpers/ryujinx_log_analyser.py b/robocop_ng/helpers/ryujinx_log_analyser.py index e2f00d8..28840b7 100644 --- a/robocop_ng/helpers/ryujinx_log_analyser.py +++ b/robocop_ng/helpers/ryujinx_log_analyser.py @@ -22,6 +22,7 @@ class LogDataError(RuntimeError): def __init__(self, message: str): self.add_note(message) + class RyujinxVersion(IntEnum): STABLE = auto() CANARY = auto() @@ -31,6 +32,7 @@ class RyujinxVersion(IntEnum): MIRROR = auto() CUSTOM = auto() + original_project_version_pattern = re.compile(r"^1\.(0|1)\.\d+$") mainline_version_pattern = re.compile(r"^1\.2\.\d+$") canary_version_pattern = re.compile(r"^c1\.2\.\d+$") @@ -38,6 +40,7 @@ class RyujinxVersion(IntEnum): ldn_version_pattern = re.compile(r"^\d\.\d\.\d-ldn\d+\.\d+(?:\.\d+|$)") mirror_version_pattern = re.compile(r"^r\.(\d|\w){7}$") + class LogAnalyser: _log_text: str _log_errors: list[list[str]] @@ -55,9 +58,7 @@ def is_homebrew(log_file: str) -> bool: @staticmethod def is_using_metal(log_file: str) -> bool: - return ( - re.search("Gpu : Backend \\(Metal\\): Metal", log_file) is not None - ) + return re.search("Gpu : Backend \\(Metal\\): Metal", log_file) is not None @staticmethod def get_filepaths(log_file: str) -> set[str]: @@ -484,7 +485,10 @@ def __get_os_notes(self): "**⚠️ AMD GPU users should consider using Vulkan graphics backend.**" ) - if "macOS" in self._hardware_info["os"] and "Intel" in self._hardware_info["cpu"]: + if ( + "macOS" in self._hardware_info["os"] + and "Intel" in self._hardware_info["cpu"] + ): self._notes.add("**⚠️ Intel Macs are not supported.**") def __get_cpu_notes(self): @@ -525,10 +529,10 @@ def __get_settings_notes(self): if self._settings["shader_cache"] == "Disabled": self._notes.add("🔴 **Shader cache should be enabled.**") - if (self._settings["expand_ram"] is not None) and "4K" not in self._game_info["mods"]: - self._notes.add( - "⚠️ `DRAM size` should only be increased for 4K mods." - ) + if (self._settings["expand_ram"] is not None) and "4K" not in self._game_info[ + "mods" + ]: + self._notes.add("⚠️ `DRAM size` should only be increased for 4K mods.") if self._settings["memory_manager"] == "SoftwarePageTable": self._notes.add( @@ -632,18 +636,26 @@ def __get_notes(self): self.__get_settings_notes() if LogAnalyser.is_using_metal(self._log_text): - self._notes.add("**⚠️ The Metal backend is experimental. If you're experiencing issues, switch to Vulkan or Auto.**") + self._notes.add( + "**⚠️ The Metal backend is experimental. If you're experiencing issues, switch to Vulkan or Auto.**" + ) version_type = self.get_ryujinx_version()[0] if version_type == RyujinxVersion.CUSTOM: self._notes.add("**⚠️ Custom builds are not officially supported**") elif version_type == RyujinxVersion.ORIGINAL_PROJECT_LDN: - raise LogDataError("**The old Ryujinx LDN build no longer works. Please update to [this version](). *Yes, it has LDN functionality.***") + raise LogDataError( + "**The old Ryujinx LDN build no longer works. Please update to [this version](). *Yes, it has LDN functionality.***" + ) elif version_type == RyujinxVersion.ORIGINAL_PROJECT: - raise LogDataError("**⚠️ It seems you're still using the original Ryujinx. Please update to [this version](), as that's what this Discord server is for.**") + raise LogDataError( + "**⚠️ It seems you're still using the original Ryujinx. Please update to [this version](), as that's what this Discord server is for.**" + ) elif version_type == RyujinxVersion.MIRROR: - raise LogDataError("**It seems you're using the other Ryujinx fork, ryujinx-mirror. Please update to [this version](), as that's what this Discord server is for; or go to their Discord server for support.**") + raise LogDataError( + "**It seems you're using the other Ryujinx fork, ryujinx-mirror. Please update to [this version](), as that's what this Discord server is for; or go to their Discord server for support.**" + ) def get_ryujinx_version(self) -> tuple[RyujinxVersion, str]: version_data = self._emu_info["ryu_version"] @@ -651,7 +663,7 @@ def get_ryujinx_version(self) -> tuple[RyujinxVersion, str]: if re.match(mainline_version_pattern, version_data): return RyujinxVersion.STABLE, version_data elif re.match(canary_version_pattern, version_data): - return RyujinxVersion.CANARY, version_data.lstrip('c') + return RyujinxVersion.CANARY, version_data.lstrip("c") if re.match(original_project_version_pattern, version_data): return RyujinxVersion.ORIGINAL_PROJECT, version_data elif re.match(pr_version_pattern, version_data):