From c6197ea9f4f7decb0307f58c166542e528b21291 Mon Sep 17 00:00:00 2001 From: nex Date: Mon, 15 May 2023 18:24:06 +0100 Subject: [PATCH] Jimmy now more accurately responds to virgin --- cogs/events.py | 2 +- cogs/other.py | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/cogs/events.py b/cogs/events.py index f362aa7..72046fb 100644 --- a/cogs/events.py +++ b/cogs/events.py @@ -453,7 +453,7 @@ class Events(commands.Cog): "check": (assets / "mine-diamonds.opus").exists } }, - r"v[ei]r[mg]in(\sme(d|m[a]?)ia\W*)?$": { + r"v[ei]r[mg]in(\sme(d|m[a]?)ia\W*)?(\W\w*\W*)?$": { "content": "Get virgin'd", "file": lambda: discord.File( random.choice(list(Path(assets / 'virgin').iterdir())) diff --git a/cogs/other.py b/cogs/other.py index 5bea2b4..e6a7af8 100644 --- a/cogs/other.py +++ b/cogs/other.py @@ -1040,9 +1040,9 @@ class OtherCog(commands.Cog): try: await self.bot.loop.run_in_executor( - None, + None, partial( - subprocess.run, + subprocess.run, ffmpeg_command, check=True ) @@ -1178,8 +1178,8 @@ class OtherCog(commands.Cog): _msg = await interaction.followup.send("Downloading text...") try: response = await _self.http.get( - _url, - headers={"User-Agent": "Mozilla/5.0"}, + _url, + headers={"User-Agent": "Mozilla/5.0"}, follow_redirects=True ) if response.status_code != 200: @@ -1194,10 +1194,10 @@ class OtherCog(commands.Cog): except (ConnectionError, httpx.HTTPError, httpx.NetworkError) as e: await _msg.edit(content="Failed to download text. " + str(e)) return - + else: _msg = await interaction.followup.send("Converting text to MP3... (0 seconds elapsed)") - + async def assurance_task(): while True: await asyncio.sleep(5.5) @@ -1405,9 +1405,10 @@ class OtherCog(commands.Cog): out_file = io.BytesIO(text.encode("utf-8", "replace")) await ctx.respond(file=discord.File(out_file, filename="ocr.txt")) - await ctx.edit( - content="Timings:\n" + "\n".join("%s: %s" % (k.title(), v) for k, v in timings.items()), - ) + if timings: + await ctx.edit( + content="Timings:\n" + "\n".join("%s: %s" % (k.title(), v) for k, v in timings.items()), + ) def setup(bot):