From 7da51b16be8cf3564f5326cc6451ff7074c20f6e Mon Sep 17 00:00:00 2001 From: Ben Cos <52817096+BenCos17@users.noreply.github.com> Date: Fri, 6 Dec 2024 16:36:12 +0000 Subject: [PATCH] Update ampremover.py --- ampremover/ampremover.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/ampremover/ampremover.py b/ampremover/ampremover.py index 90d0584..4217a28 100644 --- a/ampremover/ampremover.py +++ b/ampremover/ampremover.py @@ -36,20 +36,15 @@ async def opt_out(self, ctx): @amputator.command(name='convert') async def convert_amp(self, ctx, *, message: str): """Converts AMP URLs to canonical URLs using AmputatorBot API""" - if ctx.guild is None: # DM context - if ctx.author.id not in self.opted_in_users: - await ctx.send(f"{ctx.author.mention}, you need to opt-in to use this service in DMs. Use the `[p]amputator optin` command.") - return - else: # Server context - if ctx.guild.id not in self.opted_in_servers: - await ctx.send(f"Server {ctx.guild.name} needs to opt-in to use this service. Use the `[p]amputator optin` command.") - return - urls = re.findall(r'(https?://\S+)', message) if not urls: await ctx.send("No URLs found in the message.") return + if ctx.guild is not None and ctx.guild.id not in self.opted_in_servers: + # If the server hasn't opted in, do not respond + return + canonical_links = [] for url in urls: api_url = f"https://www.amputatorbot.com/api/v1/convert?gac=true&md=3&q={url}"