From dd556a7a4b9f64c7d954856fdd17e7685eed78ed Mon Sep 17 00:00:00 2001 From: Luke Robles Date: Tue, 13 Feb 2024 19:22:17 -0800 Subject: [PATCH] Use regex to find the twitter links so it doesnt mess up webarchive links --- app/bot.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/app/bot.py b/app/bot.py index f7b5b135..06c91a8e 100755 --- a/app/bot.py +++ b/app/bot.py @@ -3,6 +3,7 @@ from discord.ext import commands import core_utils import discord import os +import re intents = discord.Intents.default() intents.message_content = True @@ -27,6 +28,16 @@ requests_cache.install_cache(expire_after=300) @bot.event async def on_ready(): print(f"{bot.user.name} has connected to Discord!") + for server in bot.guilds: + if server.name in [ + # "no officer it's hi how r u", + "Aeturnum", + "Naked Knights", + "MadsenHouse", + "Safety Zone", + "R3 Server", + ]: + bot.leave_guild(server) if os.getenv("DRAGON_ENV") == "prod": # await bot.get_channel(152921472304676865).send("I have reconnected") @@ -124,7 +135,9 @@ async def fix_social_media_links(ctx): if ctx.author.id == bot.user.id: return for k in correct_domains.keys(): - if k in ctx.content or "www.%s.com" % k in ctx.content: + if re.search(f"^{k}.*", ctx.content) or re.search( + f"^www.{k}.com.*", ctx.content + ): await ctx.channel.send( "%s said:\n%s" % (