Skip to content
Closed
Show file tree
Hide file tree
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
8 changes: 4 additions & 4 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 1 addition & 2 deletions robocop_ng/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
22 changes: 18 additions & 4 deletions robocop_ng/cogs/logfilereader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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"]
)
Expand Down Expand Up @@ -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()
Expand Down
10 changes: 6 additions & 4 deletions robocop_ng/cogs/logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion robocop_ng/cogs/verification.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down
2 changes: 2 additions & 0 deletions robocop_ng/helpers/checks.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from robocop_ng import config


def check_if_staff(ctx):
if not ctx.guild:
return False
Expand Down Expand Up @@ -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
Expand Down
38 changes: 25 additions & 13 deletions robocop_ng/helpers/ryujinx_log_analyser.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class LogDataError(RuntimeError):
def __init__(self, message: str):
self.add_note(message)


class RyujinxVersion(IntEnum):
STABLE = auto()
CANARY = auto()
Expand All @@ -31,13 +32,15 @@ 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+$")
pr_version_pattern = re.compile(r"^1\.2\.\d\+([a-f]|\d){7}$")
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]]
Expand All @@ -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]:
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -632,26 +636,34 @@ 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](<https://github.com/GreemDev/Ryujinx/releases/latest>). *Yes, it has LDN functionality.***")
raise LogDataError(
"**The old Ryujinx LDN build no longer works. Please update to [this version](<https://github.com/GreemDev/Ryujinx/releases/latest>). *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](<https://github.com/GreemDev/Ryujinx/releases/latest>), 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](<https://github.com/GreemDev/Ryujinx/releases/latest>), 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](<https://github.com/GreemDev/Ryujinx/releases/latest>), 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](<https://github.com/GreemDev/Ryujinx/releases/latest>), 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"]

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):
Expand Down