From 9b9c58b1371cd3f95685b575fb2efb62b22d81f6 Mon Sep 17 00:00:00 2001 From: eip <36315290+eip618@users.noreply.github.com> Date: Mon, 26 Aug 2024 22:03:22 +1000 Subject: [PATCH 1/7] @Gruetzig hates duplicate soaps (2) @Gruetzig is annoyed by soap duplicates --- cogs/assistance.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cogs/assistance.py b/cogs/assistance.py index 27b0144b..c88c1cb9 100644 --- a/cogs/assistance.py +++ b/cogs/assistance.py @@ -139,6 +139,9 @@ async def createsoap(self, ctx: GuildContext, helpee: discord.Member): return await ctx.send("The soaps category is not set.") # Channel names can't be longer than 100 characters channel_name = f"3ds-{helpee.name}-soap-🧼"[:100] + for channel in self.soaps_category.text_channels: + if channel.name == channel_name: + return await ctx.send("Soap channel already exists for user.") channel = await self.soaps_category.create_text_channel(name=channel_name) await asyncio.sleep(3) # Fix for discord race condition(?) await channel.set_permissions(helpee, read_messages=True) From ae9e550ec6298d1f2eed33c4a738c62c47d984dc Mon Sep 17 00:00:00 2001 From: Vanny <48239094+VannyBuns@users.noreply.github.com> Date: Tue, 27 Aug 2024 05:31:57 -0400 Subject: [PATCH 2/7] Replace accidental quotation mark with apostrophe --- cogs/assistance-cmds/cfwcheck.wiiu.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cogs/assistance-cmds/cfwcheck.wiiu.md b/cogs/assistance-cmds/cfwcheck.wiiu.md index b96df7a5..2cdffd0b 100644 --- a/cogs/assistance-cmds/cfwcheck.wiiu.md +++ b/cogs/assistance-cmds/cfwcheck.wiiu.md @@ -12,6 +12,6 @@ Indexiine: Launches the Homebrew Launcher automatically while opening the browse Haxchi: Launched from the Wii U Menu, will appear as "Haxchi". -CBHC: Launches on boot with a black screen that says `Autobooting....` and has a `DON"T TOUCH ME` icon. +CBHC: Launches on boot with a black screen that says `Autobooting....` and has a `DON'T TOUCH ME` icon. Tiramisu: Launches either on boot or while launching health and safety, will show a black screen + white line upon launch. From 62686edabe7c2adcda166f9eec56e427780777ad Mon Sep 17 00:00:00 2001 From: lifehackerhansol Date: Wed, 4 Sep 2024 09:38:38 -0700 Subject: [PATCH 3/7] mkey: pad zeroes to the return value The master key input UI wants 5 digits. Provide the user 5 digits with leading zeroes so as to not get confused. --- cogs/assistance.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cogs/assistance.py b/cogs/assistance.py index c88c1cb9..3a4afda5 100644 --- a/cogs/assistance.py +++ b/cogs/assistance.py @@ -296,7 +296,7 @@ async def mkey(self, ctx: KurisuContext, device: Literal['3ds', 'dsi', 'wii', 'w async with self.bot.session.get(api_call) as r: if r.status == 200: ret = await r.json() - return await ctx.send(f'{ctx.author.mention if not ctx.interaction else ""} Your key is {ret["key"]}.', ephemeral=True) + return await ctx.send(f'{ctx.author.mention if not ctx.interaction else ""} Your key is {ret["key"]:05}.', ephemeral=True) else: return await ctx.send(f'{ctx.author.mention if not ctx.interaction else ""} API returned error {r.status}. Please check your values and try again.', ephemeral=True) From e189338319946f3078d8864f051d586653e32c60 Mon Sep 17 00:00:00 2001 From: lifehackerhansol Date: Wed, 28 Aug 2024 18:55:52 -0700 Subject: [PATCH 4/7] assistancewii: Add `wiierror` This leverages Wiimmfi's extensive error code database API to provide users a simple way to describe error codes displayed on the Wii and/or the Nintendo WFC. Add needed __init__ function for the AssistanceWii class to access the Kurisu bot object. --- cogs/assistancewii.py | 36 ++++++++++++++++++++++++++++++++++++ requirements.txt | 3 ++- 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/cogs/assistancewii.py b/cogs/assistancewii.py index d20136fb..6665326c 100644 --- a/cogs/assistancewii.py +++ b/cogs/assistancewii.py @@ -2,10 +2,18 @@ import logging from os.path import dirname, join +from typing import TYPE_CHECKING +import discord from discord.ext import commands +from markdownify import markdownify from utils.mdcmd import add_md_files_as_commands +from utils.utils import ConsoleColor, KurisuCooldown + +if TYPE_CHECKING: + from kurisu import Kurisu + from utils.context import KurisuContext logger = logging.getLogger(__name__) @@ -16,6 +24,34 @@ class AssistanceWii(commands.GroupCog): """ data_dir = join(dirname(__file__), 'assistance-cmds') + def __init__(self, bot: Kurisu): + self.bot: Kurisu = bot + + @commands.dynamic_cooldown(KurisuCooldown(1, 30.0), commands.BucketType.channel) + @commands.command(aliases=["wfcerror"]) + async def wiierror(self, ctx: KurisuContext, error: int): + """ + Get information about an error code displayed on the Wii and/or the Nintendo WFC. + Usage: `wiierror ` + """ + # It seems error codes must be within 6 digits + if error > 999999: + return await ctx.send(f"{ctx.author.mention} This is an invalid error code. Please try again.") + apicall = f"https://wiimmfi.de/error?m=json&e={error}" + async with ctx.typing(): + async with self.bot.session.get(apicall) as r: + if r.status == 200: + response = await r.json() + if response[0]["found"] == 0: + return await ctx.send(f"{ctx.author.mention} This error code does not exist.") + else: + embed = discord.Embed(title=f"Error {error}", colour=ConsoleColor.wii()) + for i in response[0]["infolist"]: + embed.add_field(name=i["type"], value=f'**{i["name"]}**: {markdownify(i["info"])}', inline=False) + return await ctx.send(embed=embed) + else: + return await ctx.send(f'{ctx.author.mention} API returned error {r.status}. Please check your values and try again.') + add_md_files_as_commands(AssistanceWii, console_cmd="wii") diff --git a/requirements.txt b/requirements.txt index 167e3a60..c42eaa64 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,4 +4,5 @@ xkcd==2.4.2 pytz==2024.1 asyncpg==0.29.0 python-Levenshtein==0.25.1 -pillow-heif==0.17.0 \ No newline at end of file +pillow-heif==0.17.0 +markdownify==0.13.1 From 99d749bb6f61344783ad06e6f8dacf1ec4402f42 Mon Sep 17 00:00:00 2001 From: lifehackerhansol Date: Wed, 4 Sep 2024 19:06:17 -0700 Subject: [PATCH 5/7] wiierror: Add a basic cache for Wiimmfi responses This cache will only be alive during runtime; it is not using the db. It (hopefully) saves us from too many API calls. --- cogs/assistancewii.py | 41 +++++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/cogs/assistancewii.py b/cogs/assistancewii.py index 6665326c..b0063ce1 100644 --- a/cogs/assistancewii.py +++ b/cogs/assistancewii.py @@ -27,6 +27,9 @@ class AssistanceWii(commands.GroupCog): def __init__(self, bot: Kurisu): self.bot: Kurisu = bot + # Cached error codes from Wiimmfi + saved_errors = [] + @commands.dynamic_cooldown(KurisuCooldown(1, 30.0), commands.BucketType.channel) @commands.command(aliases=["wfcerror"]) async def wiierror(self, ctx: KurisuContext, error: int): @@ -38,19 +41,33 @@ async def wiierror(self, ctx: KurisuContext, error: int): if error > 999999: return await ctx.send(f"{ctx.author.mention} This is an invalid error code. Please try again.") apicall = f"https://wiimmfi.de/error?m=json&e={error}" - async with ctx.typing(): - async with self.bot.session.get(apicall) as r: - if r.status == 200: - response = await r.json() - if response[0]["found"] == 0: - return await ctx.send(f"{ctx.author.mention} This error code does not exist.") + + errorinfo = {} + + # Check if we have this error cached + for i in self.saved_errors: + if i["error"] == error: + errorinfo = i + + # If our error wasn't cached, go ask Wiimmfi + if not errorinfo: + async with ctx.typing(): + async with self.bot.session.get(apicall) as r: + if r.status == 200: + response = await r.json() + errorinfo = response[0] + # Cache the error + self.saved_errors.append(response[0]) else: - embed = discord.Embed(title=f"Error {error}", colour=ConsoleColor.wii()) - for i in response[0]["infolist"]: - embed.add_field(name=i["type"], value=f'**{i["name"]}**: {markdownify(i["info"])}', inline=False) - return await ctx.send(embed=embed) - else: - return await ctx.send(f'{ctx.author.mention} API returned error {r.status}. Please check your values and try again.') + return await ctx.send(f'{ctx.author.mention} API returned error {r.status}. Please check your values and try again.') + + if errorinfo["found"] == 0: + return await ctx.send(f"{ctx.author.mention} This error code does not exist.") + else: + embed = discord.Embed(title=f"Error {error}", colour=ConsoleColor.wii()) + for i in errorinfo["infolist"]: + embed.add_field(name=i["type"], value=f'**{i["name"]}**: {markdownify(i["info"])}', inline=False) + return await ctx.send(embed=embed) add_md_files_as_commands(AssistanceWii, console_cmd="wii") From c7a319a30968c30f99422b538c3dc6f352eee25d Mon Sep 17 00:00:00 2001 From: ManiacOfGitHub <43019219+ManiacOfGitHub@users.noreply.github.com> Date: Wed, 11 Sep 2024 07:41:44 -0400 Subject: [PATCH 6/7] Fix .nospace typo --- cogs/assistance-cmds/nospace.3ds.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cogs/assistance-cmds/nospace.3ds.md b/cogs/assistance-cmds/nospace.3ds.md index e0d63249..e092d2c8 100644 --- a/cogs/assistance-cmds/nospace.3ds.md +++ b/cogs/assistance-cmds/nospace.3ds.md @@ -9,6 +9,6 @@ cooldown-per: 15 # Steps to create the backup 1. Copy the Nintendo 3DS folder from the root of your SD card to your computer then delete it from **the SD card.** On Mac, empty the Trash. -2. Boot GodMode9 by holding START on boot then preform a normal NAND backup. After that, power off the system. +2. Boot GodMode9 by holding START on boot then perform a normal NAND backup. After that, power off the system. 3. Copy the files in gm9/out on your SD card to a safe spot on your computer. Then, delete the files from **the SD card.** 4. Copy the Nintendo 3DS folder to your SD card root then delete it **from your computer.** From d306f36a81e151494dd3b05f24c819eb7bc8df60 Mon Sep 17 00:00:00 2001 From: lifehackerhansol Date: Mon, 16 Sep 2024 23:00:05 -0700 Subject: [PATCH 7/7] Add wii to createsmallhelp Now that we have a dedicated Wii support thread, why not? --- cogs/assistance.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cogs/assistance.py b/cogs/assistance.py index 3a4afda5..2a8ccb16 100644 --- a/cogs/assistance.py +++ b/cogs/assistance.py @@ -115,7 +115,7 @@ async def staffreq(self, ctx: GuildContext, *, msg_request: str = ""): @is_staff('Helper') @commands.guild_only() @commands.command() - async def createsmallhelp(self, ctx: GuildContext, console: Literal['3ds', 'switch', 'wiiu', 'legacy'], helpee: discord.Member, *, desc: str): + async def createsmallhelp(self, ctx: GuildContext, console: Literal['3ds', 'switch', 'wiiu', 'wii', 'legacy'], helpee: discord.Member, *, desc: str): """Creates a small help channel for a user. Helper+ only.""" if not self.small_help_category: return await ctx.send("The small help category is not set.")