Make the tiktok and twitter link corrections a bit more pythonic by just using startswith()

This commit is contained in:
Luke Robles 2024-02-26 15:48:02 -08:00
parent 72fa08c2ad
commit e161ea086c
3 changed files with 3 additions and 6 deletions

View File

@ -3,4 +3,4 @@ repos:
rev: 23.10.1
hooks:
- id: black
language_version: python3.11.7
language_version: python3.12.2

View File

@ -3,7 +3,6 @@ from discord.ext import commands
import core_utils
import discord
import os
import re
intents = discord.Intents.default()
intents.message_content = True
@ -140,15 +139,13 @@ async def fix_social_media_links(ctx):
if ctx.author.id == bot.user.id:
return
for k in correct_domains.keys():
if re.search(f"^{k}.*", ctx.content) or re.search(
f"^www.{k}.com.*", ctx.content
):
if ctx.content.startswith(k) or ctx.content.startswith("www.{k}.com"):
await ctx.channel.send(
"%s said:\n%s"
% (
ctx.author.mention,
ctx.content.replace(k, "https://%s.com" % correct_domains[k]).split(
"?s"
"?"
)[0],
)
)

0
app/cogs/cheeky_functions.py Normal file → Executable file
View File