From 1e59e5561d0211433c66548a483a4e8ec0ccd3c5 Mon Sep 17 00:00:00 2001 From: Luke Robles Date: Tue, 12 Dec 2023 10:30:52 -0800 Subject: [PATCH] Update social media link corrections for x.com and twitter.com, also update makefile to fix python formatter issues --- Makefile | 3 ++- app/bot.py | 35 +++++++++++++++++++++++------------ 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index f61b4669..90b9d80b 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,8 @@ include .env +# https://github.com/psf/black/issues/1106#issuecomment-547230844 format: - docker run --rm -ti -v ${PWD}:/tmp/python/app python:alpine sh -c "cd /tmp/python; pip install -q black; black ." + docker run --rm -ti -v ${PWD}:/tmp/python/app python:alpine sh -c "apk add --no-cache gcc musl-dev; cd /tmp/python; pip install -q black; black ." clean: docker rm -f dragon-bot-test diff --git a/app/bot.py b/app/bot.py index 8cebcd8f..75c84ac6 100755 --- a/app/bot.py +++ b/app/bot.py @@ -114,18 +114,7 @@ async def convert_heic_to_jpg(ctx): @bot.listen("on_message") -async def annoy_jason(ctx): - if ctx.author.id == 83012791983673344 and "twitter.com" in ctx.content: - # my author id for testing - # if ctx.author.id == core_utils.my_id and "twitter.com" in ctx.content: - await ctx.reply( - "https://tenor.com/view/oomfie-klee-genshin-impact-smook-smokingissad-gif-21571907" - ) - return - - -@bot.listen("on_message") -async def fix_tiktok_links(ctx): +async def fix_social_media_links(ctx): if "https://www.tiktok.com" in ctx.content: await ctx.channel.send( "%s said:\n%s" @@ -137,6 +126,28 @@ async def fix_tiktok_links(ctx): await ctx.delete() return + if "https://twitter.com" in ctx.content: + await ctx.channel.send( + "%s said:\n%s" + % ( + ctx.author.mention, + ctx.content.replace("twitter", "vxtwitter"), + ) + ) + await ctx.delete() + return + + if "https://x.com" in ctx.content: + await ctx.channel.send( + "%s said:\n%s" + % ( + ctx.author.mention, + ctx.content.replace("x", "vxtwitter"), + ) + ) + await ctx.delete() + return + @bot.event async def on_message(ctx):